Commit 59f05ea0 authored by shajiaiming's avatar shajiaiming

bitnasdaq

parent 88659d4a
...@@ -15,7 +15,7 @@ class Bitnasdaq extends Exchange implements ExchangeInterface ...@@ -15,7 +15,7 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
{ {
protected $supported_symbol = 'supported_symbol_bitnasdaq'; protected $supported_symbol = 'supported_symbol_bitnasdaq';
protected $quotation_prefix = 'quotation_bitnasdaq_'; protected $quotation_prefix = 'quotation_bitnasdaq_';
protected $base_url = 'https://www.bitnasdaq.com/'; protected $base_url = 'https://openapi.bitnasdaq.pro/';
public function formatSymbol($tag = 'BTC', $aim = 'USDT') public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{ {
...@@ -24,35 +24,29 @@ class Bitnasdaq extends Exchange implements ExchangeInterface ...@@ -24,35 +24,29 @@ class Bitnasdaq extends Exchange implements ExchangeInterface
public function setSupportedSymbol() public function setSupportedSymbol()
{ {
$curl = new Curl();
$api = $this->base_url . '/api/v1/ticker/24hr';
$res = $curl->get($api, false);//json
if (is_array($res)) {
foreach ($res as $item) {
$this->redis->sadd($this->supported_symbol, strtolower($item['symbol']));
}
}
} }
public function setQuotation() public function setQuotation()
{ {
$curl = new Curl(); $curl = new Curl();
$api = $this->base_url . '/app/tradeMarket/coinPrice'; $api = $this->base_url . '/open/api/get_allticker';
$res = $curl->get($api, false); $res = $curl->get($api, false);
if (is_array($res) && isset($res['obj'])) {
$data = $res['obj']; if (is_array($res) && isset($res['data'])) {
$data = $res['data']['ticker'];
foreach ($data as $key => $item) { foreach ($data as $key => $item) {
if(strpos(strtoupper($key),'_CNYT') !== false){ if (strpos(strtoupper($key), '_CNYT') !== false) {
continue; continue;
} }
$low = isset($item['minPrice']) ? $item['minPrice'] : 0; $low = isset($item['low']) ? $item['low'] : 0;
$high = isset($item['maxPrice']) ? $item['maxPrice'] : 0; $high = isset($item['high']) ? $item['high'] : 0;
$last = isset($item['currentExchangPrice']) ? $item['currentExchangPrice'] : 0; $last = isset($item['last']) ? $item['last'] : 0;
$open = isset($item['openPrice']) ? $item['openPrice'] : 0; $open = isset($item['last']) ? $item['last'] : 0;
$vol = isset($item['transactionSum']) ? $item['transactionSum'] : 0; $vol = isset($item['vol']) ? $item['vol'] : 0;
$cache_key = strtolower($this->quotation_prefix . str_replace('_', '', $key)); $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);
$this->redis->sadd($this->supported_symbol, strtoupper(str_replace('_', '', $key))); $this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
} }
} }
} }
......
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