Commit 9f92b16e authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

hdc change See merge request !425
parents bf69f24e 68e7c2c8
...@@ -14,7 +14,7 @@ class Hd extends Exchange implements ExchangeInterface ...@@ -14,7 +14,7 @@ class Hd extends Exchange implements ExchangeInterface
{ {
protected $supported_symbol = 'supported_symbol_hd'; protected $supported_symbol = 'supported_symbol_hd';
protected $quotation_prefix = 'quotation_hd_'; protected $quotation_prefix = 'quotation_hd_';
protected $base_url = 'https://app.honordecent.com/exchange/getHdcCurrPrice'; protected $base_url = 'https://app.honordecent.com/exchange/getNowData';
public function symbolExists($tag = 'HDC', $aim = "USDT") public function symbolExists($tag = 'HDC', $aim = "USDT")
{ {
...@@ -58,7 +58,7 @@ class Hd extends Exchange implements ExchangeInterface ...@@ -58,7 +58,7 @@ class Hd extends Exchange implements ExchangeInterface
$res = $curl->get($this->base_url, false); $res = $curl->get($this->base_url, false);
if (is_array($res) && 1 == $res['code']) { if (is_array($res) && 1 == $res['code']) {
$key = $this->quotation_prefix . 'HDCUSDT'; $key = $this->quotation_prefix . 'HDCUSDT';
$this->redis->hmset($key, 'low', $res['data'], 'high', $res['data'], 'last', $res['data']); $this->redis->hmset($key, 'low', $res['data']['currPrice'], 'high', $res['data']['currPrice'], 'last', $res['data']['currPrice'], 'change', $res['data']['range']);
if (!$this->redis->sismember($this->supported_symbol, 'HDCUSDT')) { if (!$this->redis->sismember($this->supported_symbol, 'HDCUSDT')) {
$this->redis->sadd($this->supported_symbol, 'HDCUSDT'); $this->redis->sadd($this->supported_symbol, 'HDCUSDT');
} }
......
...@@ -30,7 +30,7 @@ class HdBuilder extends FactoryService ...@@ -30,7 +30,7 @@ class HdBuilder extends FactoryService
$ticker = []; $ticker = [];
foreach ($symbol as $val) { foreach ($symbol as $val) {
list($low, $high, $last) = $this->redis->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last'); list($low, $high, $last, $change) = $this->redis->hmget($this->quotation_prefix . strtoupper($val), 'low', 'high', 'last', 'change');
$explode_arr = explode('usdt', $val); $explode_arr = explode('usdt', $val);
$temp = []; $temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT'; $temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT';
...@@ -39,7 +39,7 @@ class HdBuilder extends FactoryService ...@@ -39,7 +39,7 @@ class HdBuilder extends FactoryService
$temp['close'] = (float)sprintf("%0.6f", $last); $temp['close'] = (float)sprintf("%0.6f", $last);
$temp['close_usd'] = (float)sprintf("%0.6f", $last * $this->basic_price['USDT']['usd']); $temp['close_usd'] = (float)sprintf("%0.6f", $last * $this->basic_price['USDT']['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $last * $this->basic_price['USDT']['rmb']); $temp['close_rmb'] = (float)sprintf("%0.4f", $last * $this->basic_price['USDT']['rmb']);
$temp['change'] = (0 == $low) ? 0 : (float)sprintf("%0.2f", ($last - $low) / $low * 100); $temp['change'] = (float)sprintf("%0.2f", $change);
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']); $temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']); $temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']); $temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']);
......
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