Commit 04100c0a authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

fix See merge request !413
parents cd40ebed 8627d6db
......@@ -14,7 +14,7 @@ class Ztb extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_ztb';
protected $quotation_prefix = 'quotation_ztb_';
protected $base_url = 'https://www.ztb.com/api/v1/tickers';
protected $base_url = 'https://www.ztb.com/api/v1/tickers';
public function symbolExists($tag = 'ZYC', $aim = "USDT")
......@@ -25,6 +25,7 @@ class Ztb extends Exchange implements ExchangeInterface
}
return false;
}
/**
* 转化交易对为请求变量
*
......@@ -55,15 +56,16 @@ class Ztb extends Exchange implements ExchangeInterface
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
$content = $curl->get($this->base_url, true);
$content = json_decode($content, true);
if (is_array($content) && isset($content['ticker'])) {
$data = $content['ticker'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['ZYCUSDT'])) {
if (in_array($item['symbol'], ['ZYC_USDT'])) {
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$key = $this->quotation_prefix . str_replace('_', '', $item['symbol']);
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last'], 'vol', $data['vol'], 'change', $data['change']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
$this->redis->sadd($this->supported_symbol, str_replace('_', '', $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