Commit 0f1a0bb2 authored by shajiaiming's avatar shajiaiming

ljz ticker

parent 4a818f76
......@@ -209,9 +209,9 @@ class ExchangeBusiness
goto doEnd;
}
if (in_array(strtoupper($tag), ['GHT'])) {
if (in_array(strtoupper($tag), ['GHT','JD'])) {
$exchange = ExchangeFactory::createExchange("Ljz");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation = $exchange->getTicker($tag, 'CNYD');
$quotation['rmb'] = $quotation['last'];
goto doEnd;
}
......
......@@ -14,9 +14,9 @@ class Ljz extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_ljz';
protected $quotation_prefix = 'quotation_ljz_';
protected $base_url = 'http://api.ydqkl.com.cn/market/exchange-rate/cny/GHT';
protected $base_url = 'http://api.ydqkl.com.cn/market/overview';
public function symbolExists($tag = 'GHT', $aim = "USDT")
public function symbolExists($tag = 'GHT', $aim = "CNYD")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
......@@ -32,7 +32,7 @@ class Ljz extends Exchange implements ExchangeInterface
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'GHT', $aim = 'USDT')
public function formatSymbol($tag = 'GHT', $aim = 'CNYD')
{
return strtoupper($tag .'_'. $aim);
}
......@@ -56,13 +56,14 @@ class Ljz extends Exchange implements ExchangeInterface
{
$curl = new Curl();
$res = $curl->get($this->base_url, false);
if (is_array($res) && 0 == $res['code']) {
$key = $this->quotation_prefix . 'GHT_USDT';
$this->redis->hmset($key, 'low', $res['data'], 'high', $res['data'], 'last', $res['data'], 'change', $res['data']);
if (!$this->redis->sismember($this->supported_symbol, 'GHTUSDT')) {
$this->redis->sadd($this->supported_symbol, 'GHTUSDT');
if (is_array($res) && count($res['changeRank']) > 0) {
foreach ($res['changeRank'] as $val){
$key = $this->quotation_prefix . str_replace('/','_', $val['symbol']);
$this->redis->hmset($key, 'low', $val['low'], 'high', $val['high'], 'last', $val['close'], 'change', $val['change'],'open', $val['open'],'vol',$val['volume']);
if (!$this->redis->sismember($this->supported_symbol, str_replace('/','', $val['symbol']))) {
$this->redis->sadd($this->supported_symbol, str_replace('/','', $val['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