Commit 12a08c2e authored by shajiaiming's avatar shajiaiming

hl行情接口更新

parent 7a73e2c8
......@@ -14,7 +14,7 @@ class Zg extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_zg';
protected $quotation_prefix = 'quotation_zg_';
protected $base_url = 'https://api1.zg.com/tickers';
protected $base_url = 'https://api.zg.com/openapi/quote/v1/ticker/24hr';
public function symbolExists($tag = 'HL', $aim = "USDT")
{
......@@ -24,6 +24,7 @@ class Zg extends Exchange implements ExchangeInterface
}
return false;
}
/**
* 转化交易对为请求变量
*
......@@ -33,7 +34,7 @@ class Zg extends Exchange implements ExchangeInterface
*/
public function formatSymbol($tag = 'HL', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
return strtoupper($tag . '_' . $aim);
}
/**
......@@ -58,14 +59,19 @@ class Zg extends Exchange implements ExchangeInterface
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
]);
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['ticker'])) {
$data = $content['ticker'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['HL_USDT', 'GHP_CNZ'])) {
if (is_array($content)) {
foreach ($content as $item) {
if (in_array($item['symbol'], ['HLUSDT', 'GHPUSDT'])) {
if ($item['symbol'] == 'HLUSDT') {
$symbol = 'HL_USDT';
}
if ($item['symbol'] == 'GHPUSDT') {
$symbol = 'GHP_CNZ';
}
$data = $item;
$key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']);
$this->redis->sadd($this->supported_symbol, $item['symbol']);
$key = $this->quotation_prefix . $symbol;
$this->redis->hmset($key, 'low', $data['lowPrice'], 'high', $data['highPrice'], 'last', $data['lastPrice'], 'open', $data['openPrice']);
$this->redis->sadd($this->supported_symbol, $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