Commit 0d8acaa5 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

fix See merge request !385
parents 8131e4aa baa91f25
......@@ -44,8 +44,9 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
$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);
$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']));
}
}
......
......@@ -65,9 +65,9 @@ class BitnasdaqBuilder extends FactoryService
$explode_arr = explode(strtoupper($coin), strtoupper($val));
if (2 == count($explode_arr) && empty($explode_arr[1])) {
if (false != $condition) {
list($low, $high, $close, $open, $vol) = $this->redis_ticker->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'open', 'vol');
list($low, $high, $close, $open, $vol, $change) = $this->redis_ticker->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'open', 'vol', 'change');
} else {
list($low, $high, $close, $open, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($val), 'low', 'high', 'last', 'open', 'vol');
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;
......@@ -76,7 +76,7 @@ class BitnasdaqBuilder extends FactoryService
$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']);
$temp['change'] = (false == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['change'] = (float)sprintf("%0.2f", $change);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price[$coin]['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['rmb']);
......@@ -106,7 +106,7 @@ class BitnasdaqBuilder extends FactoryService
$ticker = [];
for ($i = 0; $i < $len; $i++) {
$symbol = $this->redis->lindex($this->supported_symbol_list, $i);
list($close, $open, $low, $high, $vol) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open', 'low', 'high', 'vol');
list($close, $open, $low, $high, $vol, $change) = $this->redis->hmget($this->quotation_prefix . strtolower($symbol), 'last', 'open', 'low', 'high', 'vol', 'change');
if ('0.00000000' == $close) continue;
$temp = [];
$temp['symbol'] = strtoupper($symbol);
......@@ -121,7 +121,7 @@ class BitnasdaqBuilder extends FactoryService
$temp['high'] = $high;
$temp['open'] = $open;
$temp['vol'] = $vol;
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['change'] = (float)sprintf("%0.2f", $change);
array_push($ticker, $temp);
$key = $this->quotation_prefix . strtoupper($symbol);
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
......
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