Commit 322e8854 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

fix See merge request !389
parents bc76b3ca 2755cf58
......@@ -36,18 +36,17 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
if (is_array($res) && isset($res['data'])) {
$data = $res['data']['ticker'];
foreach ($data as $key => $item) {
if (strpos(strtoupper($key), '_CNYT') !== false) {
continue;
if (in_array(strtoupper($item['symbol']), ['BNCUSAT', 'BTCUSAT', 'ETCUSAT', 'ETHUSAT', 'GHPUSAT', 'LTCUSAT'])) {
$low = isset($item['low']) ? $item['low'] : 0;
$high = isset($item['high']) ? $item['high'] : 0;
$last = isset($item['last']) ? $item['last'] : 0;
$open = isset($item['last']) ? $item['last'] : 0;
$vol = isset($item['vol']) ? $item['vol'] : 0;
$change = isset($item['rose']) ? $item['rose'] : 0;
$cache_key = strtolower($this->quotation_prefix . $item['symbol']);
$this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open, 'vol', $vol, 'change', $change);
$this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
}
$low = isset($item['low']) ? $item['low'] : 0;
$high = isset($item['high']) ? $item['high'] : 0;
$last = isset($item['last']) ? $item['last'] : 0;
$open = isset($item['last']) ? $item['last'] : 0;
$vol = isset($item['vol']) ? $item['vol'] : 0;
$change = isset($item['rose']) ? $item['rose'] : 0;
$cache_key = strtolower($this->quotation_prefix . $item['symbol']);
$this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open, 'vol', $vol, 'change', $change);
$this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
}
}
}
......
......@@ -62,7 +62,8 @@ class BitnasdaqBuilder extends FactoryService
$ticker = [];
foreach ($keys as $val) {
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($val));
$temp_symbol = str_replace('USAT', 'USDT', $val);
$explode_arr = explode(strtoupper($coin), strtoupper($temp_symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
if (false != $condition) {
list($low, $high, $close, $open, $vol, $change) = $this->redis_ticker->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'open', 'vol', 'change');
......@@ -70,9 +71,9 @@ class BitnasdaqBuilder extends FactoryService
list($low, $high, $close, $open, $vol, $change) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol', 'change');
}
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin;
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USAT';
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = strtoupper($coin);
$temp['base_currency'] = 'USAT';
$temp['close'] = rtrim(sprintf('%.8f', floatval($close)), '0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($close * $this->basic_price[$coin]['usd'])), '0');
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
......@@ -111,12 +112,13 @@ class BitnasdaqBuilder extends FactoryService
$temp = [];
$temp['symbol'] = strtoupper($symbol);
$temp['close'] = $close;
foreach ($this->basic_coin as $k => $coin) {
$explode_arr = explode(strtoupper($coin), strtoupper($symbol));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
}
}
//为什么要加close_rmb作为排序
// foreach ($this->basic_coin as $k => $coin) {
// $explode_arr = explode(strtoupper($coin), strtoupper($symbol));
// if (2 == count($explode_arr) && empty($explode_arr[1])) {
// $temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
// }
// }
$temp['low'] = $low;
$temp['high'] = $high;
$temp['open'] = $open;
......@@ -127,7 +129,7 @@ class BitnasdaqBuilder extends FactoryService
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol, 'change', $change);
}
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$ticker_sort_close = Tools::arraySort($ticker, 'close');
$this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc);
foreach ($ticker_sort_close as $val) {
......
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