Commit 21bd64ae authored by shajiaiming's avatar shajiaiming

fix

parent 21f3b6a7
......@@ -11,12 +11,17 @@ namespace common\service\exchange;
use linslin\yii2\curl\Curl;
use Yii;
class Hadax extends HuoBi
class Hadax extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_hadax';
protected $quotation_prefix = 'quotation_hadax_';
protected $base_url = 'https://api.hadax.com';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtolower(trim($tag) . trim($aim));
}
public function setSupportedSymbol()
{
$curl = new Curl();
......@@ -30,4 +35,19 @@ class Hadax extends HuoBi
}
}
}
public function setQuotation()
{
$curl = new Curl();
$api = $this->base_url . '/market/tickers';
$res = $curl->get($api, false);
if ($res && $res['status'] == 'ok') {
$datas = $res['data'];
foreach ($datas as $item) {
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $item['low'], 'high', $item['high'], 'last', $item['close']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
}
}
}
}
\ No newline at end of file
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