Commit 25f35cc8 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

Feature/ticker See merge request !405
parents 82e67e81 6eaa2453
......@@ -414,7 +414,7 @@ class CoinController extends BaseController
$request = Yii::$app->request;
$platform = $request->post('platform', '');
if ($platform) {
$brower_url = Yii::$app->redis->hget('platform_brower_info', $platform);
$brower_url = Yii::$app->redis->hget('platform_brower_info', strtolower($platform));
return ['code' => 0, 'data' => $brower_url];
} else {
return ['code' => 1, 'data' => [], 'msg' => '平台参数不能为空'];
......
......@@ -335,6 +335,22 @@ class TickerController extends BaseController
]
];
}
if (53 == $platform_id) {
$datas = [
[
'exchange' => 'huobi',
'symbol' => [
'btcusdt',
'ethusdt'
],
], [
'exchange' => 'wbf',
'symbol' => [
'leleusdt'
],
]
];
}
$ticker = [];
foreach ($datas as $data) {
$builder = ExchangeBuilderFactory::create($data['exchange']);
......
......@@ -27,26 +27,21 @@ class ExchangeBusiness
*/
private static $exchanges = [
0 => 'Bty',
1 => 'HuoBi',
#1 => 'HuoBi',
1 => 'Wbf',
2 => 'Hadax',
3 => 'Bitfinex',
4 => 'Bittrex',
5 => 'Zb',
6 => 'Token7',
7 => 'Zg',
8 => 'Go',
9 => 'Zhaobi',
10 => 'Ex',
11 => 'Zt',
12 => 'Tsc',
13 => 'Binance',
14 => 'Bilaxy',
15 => 'Bitnasdaq',
16 => 'Dag',
17 => 'Coinka',
18 => 'Isummit',
19 => 'Boc',
20 => 'Jinwang'
6 => 'Zg',
7 => 'Go',
8 => 'Zhaobi',
9 => 'Binance',
10 => 'Bilaxy',
11 => 'Bitnasdaq',
12 => 'Isummit',
13 => 'Boc',
14 => 'Jinwang'
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
......@@ -58,6 +53,12 @@ class ExchangeBusiness
//7 => 'Gdpro',//已挂
//8 => 'Ceohk', //已挂
//14 => 'Biki',//已挂
// 6 => 'Token7',//已挂
// 10 => 'Ex',//已挂
// 11 => 'Zt',//已挂
// 12 => 'Tsc',//已挂
// 16 => 'Dag',//已挂
// 17 => 'Coinka',//已挂
];
/**
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Wbf extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_wbf';
protected $quotation_prefix = 'quotation_wbf_';
protected $base_url = 'https://openapi.wbf.live/open/api/get_allticker';
public function symbolExists($tag = 'LELE', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'LELE', $aim = 'USDT')
{
return strtoupper($tag . $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$res = $curl->get($this->base_url, false);
if (is_array($res) && isset($res['data'])) {
$data = $res['data']['ticker'];
foreach ($data as $item) {
$key = $this->quotation_prefix . strtoupper($item['symbol']);
$this->redis->hmset($key, 'low', $item['low'], 'high', $item['high'], 'last', $item['last'], 'vol', $item['vol'], 'change', $item['change']);
if (!$this->redis->sismember($this->supported_symbol, strtoupper($item['symbol']))){
$this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment