Commit 2c3253af authored by shajiaiming's avatar shajiaiming

接入新交易行情

parent 82e67e81
......@@ -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,7 +27,8 @@ class ExchangeBusiness
*/
private static $exchanges = [
0 => 'Bty',
1 => 'HuoBi',
#1 => 'HuoBi',
1 => 'Wbf',
2 => 'Hadax',
3 => 'Bitfinex',
4 => 'Bittrex',
......
<?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