Commit 2d53496f authored by shajiaiming's avatar shajiaiming

fix

parent 4e52c5a3
......@@ -31,13 +31,13 @@ class HuobiBuilder
$code = 0;
foreach ($res['data'] as $val) {
foreach ($this->base_coin as $k => $coin) {
$explode_arr = explode($coin, $val['symbol']);
$explode_arr = explode(strtolower($coin), $val['symbol']);
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$ticker[$val['symbol']]['symbol'] = $explode_arr[0] . '/' . $coin;
$ticker[$val['symbol']]['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin;
$ticker[$val['symbol']]['close'] = (float)sprintf("%0.4f", $val['close']);
$ticker[$val['symbol']]['change'] = (float)sprintf(($val['close'] - $val['open']) / $val['open'] * 100);
$ticker[$val['symbol']]['high'] = (float)sprintf("%0.4f", $val['highPrice']);
$ticker[$val['symbol']]['low'] = (float)sprintf("%0.4f", $val['lowPrice']);
$ticker[$val['symbol']]['change'] = (float)sprintf("%0.4f", ($val['close'] - $val['open']) / $val['open'] * 100);
$ticker[$val['symbol']]['high'] = (float)sprintf("%0.4f", $val['high']);
$ticker[$val['symbol']]['low'] = (float)sprintf("%0.4f", $val['low']);
$ticker[$val['symbol']]['vol'] = (float)sprintf("%0.4f", $val['vol']);
}
}
......
......@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
class OkexBuilder
{
protected $base_url = 'https://api.huobi.pro';
protected $base_url = 'https://www.okex.com';
protected $base_coin = ['ETH', 'BTC', 'USDT', 'BTC'];
protected $redis;
protected $supported_symbol = 'supported_symbol_bitfinex_v2';
......@@ -28,7 +28,6 @@ class OkexBuilder
$curl = new Curl();
$api = $this->base_url . '/v2/spot/markets/products';
$res = $curl->get($api, false);
$res = json_decode($res, true);
if (isset($res['code']) && 0 == $res['code']) {
foreach ($res['data'] as $val) {
if ($this->redis->sismember($this->supported_symbol, $val['symbol'])) continue;
......@@ -46,18 +45,17 @@ class OkexBuilder
$code = -1;
$ticker = [];
foreach ($symbols as $symbol) {
$api = $this->base_url . '/market/tickers?symbol=' . $symbol;
$api = $this->base_url . '/api/v1/ticker.do?symbol=' . $symbol;
$res = $curl->get($api, false);
$res = json_decode($res, true);
if (isset($res['ticker'])) {
$code = 0;
$symbol = strtoupper(str_replace('_', '/', $symbol));
$ticker[$symbol]['symbol'] = $symbol;
$ticker[$symbol]['close'] = $res['ticker']['last'];
$ticker[$symbol]['close'] = (float)sprintf("%0.4f", $res['ticker']['last']);
//$ticker[$symbol]['change'] = (float)sprintf(($val['close'] - $val['open']) / $val['open'] * 100);
$ticker[$symbol]['high'] = $res['ticker']['high'];
$ticker[$symbol]['low'] = $res['ticker']['low'];
$ticker[$symbol]['vol'] = $res['ticker']['last'];
$ticker[$symbol]['high'] = (float)sprintf("%0.4f", $res['ticker']['high']);
$ticker[$symbol]['low'] = (float)sprintf("%0.4f", $res['ticker']['low']);
$ticker[$symbol]['vol'] = (float)sprintf("%0.4f", $res['ticker']['last']);
}
}
......
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