Commit f837e880 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

fix See merge request !202
parents 1adc57b4 f5e0dbd2
...@@ -14,7 +14,7 @@ use common\service\exchange\ExchangeBuilderFactory; ...@@ -14,7 +14,7 @@ use common\service\exchange\ExchangeBuilderFactory;
class TickerController extends BaseController class TickerController extends BaseController
{ {
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY']; protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY', 'CNYT'];
protected $basic_price = []; protected $basic_price = [];
public function actionIndex() public function actionIndex()
...@@ -76,6 +76,7 @@ class TickerController extends BaseController ...@@ -76,6 +76,7 @@ class TickerController extends BaseController
"btc,btc", "btc,btc",
"usdt,ethereum", "usdt,ethereum",
"bty,bty", "bty,bty",
"cnyt,bitnasdaqchain"
] ]
]; ];
$params = json_encode($data); $params = json_encode($data);
......
...@@ -34,7 +34,7 @@ class BitnasdaqBuilder extends FactoryService ...@@ -34,7 +34,7 @@ class BitnasdaqBuilder extends FactoryService
$keys = $this->redis->smembers($this->supported_symbol); $keys = $this->redis->smembers($this->supported_symbol);
if (false == $this->redis->exists($this->supported_symbol_list)) { if (false == $this->redis->exists($this->supported_symbol_list)) {
foreach ($keys as $val) { foreach ($keys as $val) {
if (in_array(strtoupper($val), ['BNCUSDT','BTCUSDT','CNYTUSDT','ETCUSDT','ETHUSDT','GHPUSDT','LTCUSDT'])) { if (in_array(strtoupper($val), ['BNCUSDT', 'BTCUSDT', 'CNYTUSDT', 'ETCUSDT', 'ETHUSDT', 'GHPUSDT', 'LTCUSDT', 'BTCCNYT', 'ETCCNYT', 'ETHCNYT', 'GHPCNYT', 'LTCCNYT'])) {
$this->redis->lpush($this->supported_symbol_list, strtoupper($val)); $this->redis->lpush($this->supported_symbol_list, strtoupper($val));
} }
} }
...@@ -73,8 +73,8 @@ class BitnasdaqBuilder extends FactoryService ...@@ -73,8 +73,8 @@ class BitnasdaqBuilder extends FactoryService
$temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin; $temp['symbol'] = strtoupper($explode_arr[0]) . '/' . $coin;
$temp['currency'] = strtoupper($explode_arr[0]); $temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = strtoupper($coin); $temp['base_currency'] = strtoupper($coin);
$temp['close'] = rtrim(sprintf('%.8f', floatval($close)),'0'); $temp['close'] = rtrim(sprintf('%.8f', floatval($close)), '0');
$temp['close_usd'] = rtrim(sprintf('%.6f', floatval($close * $this->basic_price[$coin]['usd'])),'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['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'] = (false == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['usd']); $temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price[$coin]['usd']);
......
...@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl; ...@@ -13,7 +13,7 @@ use linslin\yii2\curl\Curl;
abstract class FactoryService abstract class FactoryService
{ {
protected $code = -1; protected $code = -1;
protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY']; protected $basic_coin = ['ETH', 'BTC', 'USDT', 'BTY', 'CNYT'];
protected $basic_price = []; protected $basic_price = [];
protected $redis; protected $redis;
...@@ -30,7 +30,8 @@ abstract class FactoryService ...@@ -30,7 +30,8 @@ abstract class FactoryService
"eth,ethereum", "eth,ethereum",
"btc,btc", "btc,btc",
"usdt,ethereum", "usdt,ethereum",
"bty,bty" "bty,bty",
"cnyt,bitnasdaqchain"
] ]
]; ];
$params = json_encode($data); $params = json_encode($data);
......
...@@ -108,13 +108,15 @@ class ZhaobiBuilder extends FactoryService ...@@ -108,13 +108,15 @@ class ZhaobiBuilder extends FactoryService
if (2 == count($explode_arr) && empty($explode_arr[1])) { if (2 == count($explode_arr) && empty($explode_arr[1])) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']); $temp['close_rmb'] = (float)sprintf("%0.4f", $close * $this->basic_price[$coin]['rmb']);
} }
if ('SFTCNY' == strtoupper($symbol)) {
$temp['close_rmb'] = (float)sprintf("%0.4f", $close * 1);
}
} }
$temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100); $temp['change'] = (0 == $open) ? 0 : (float)sprintf("%0.2f", ($close - $open) / $open * 100);
array_push($ticker, $temp); array_push($ticker, $temp);
$key = $this->quotation_prefix . strtoupper($symbol); $key = $this->quotation_prefix . strtoupper($symbol);
$this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol); $this->redis_ticker->hmset($key, 'low', $low, 'high', $high, 'last', $close, 'open', $open, 'vol', $vol);
} }
$ticker_sort_close = Tools::arraySort($ticker, 'close_rmb'); $ticker_sort_close = Tools::arraySort($ticker, 'close_rmb');
$this->redis_ticker->del($this->supported_symbol_close_asc); $this->redis_ticker->del($this->supported_symbol_close_asc);
$this->redis_ticker->del($this->supported_symbol_close_desc); $this->redis_ticker->del($this->supported_symbol_close_desc);
......
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