Commit 2e66ec0a authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

Feature/ticker See merge request !487
parents 7c1d219d 8d915681
......@@ -32,19 +32,16 @@ class ExchangeBusiness
2 => 'Hadax',
3 => 'Bittrex',
4 => 'Zb',
5 => 'Zg',
6 => 'Go',
7 => 'Zhaobi',
8 => 'Binance',
9 => 'Bilaxy',
10 => 'Bitnasdaq',
11 => 'Isummit',
12 => 'Boc',
13 => 'Jinwang',
14 => 'Hd',
15 => 'Ztb',
16 => 'Wbf',
17 => 'Gwa'
5 => 'Go',
6 => 'Zhaobi',
7 => 'Binance',
8 => 'Bilaxy',
9 => 'Bitnasdaq',
10 => 'Isummit',
11 => 'Boc',
12 => 'Ztb',
13 => 'Wbf',
14 => 'Gwa'
//1 => 'Hadax', //不需要
//2 => 'Bitfinex', //不需要
......@@ -61,6 +58,9 @@ class ExchangeBusiness
//12 => 'Tsc',//已挂
//16 => 'Dag',//已挂
//17 => 'Coinka',//已挂
//5 => 'Zg',//已挂
//13 => 'Jinwang',//已挂
//14 => 'Hd',//已挂
];
/**
......@@ -442,9 +442,9 @@ class ExchangeBusiness
goto doEnd;
}
if (in_array(strtoupper($tag), ['GWA'])) {
if (in_array(strtoupper($tag), ['GWA','KLG'])) {
$exchange = ExchangeFactory::createExchange("Gwa");
$quotation = $exchange->getTicker('GWA', 'USDT');
$quotation = $exchange->getTicker(strtoupper($tag), 'USDT');
goto doEnd;
}
......
......@@ -12,9 +12,9 @@ use linslin\yii2\curl\Curl;
class Gwa extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_gwa';
protected $quotation_prefix = 'quotation_gwa_';
protected $base_url = 'https://api.gwaworld.io/getBalance';
protected $supported_symbol = 'supported_symbol_gwaworld';
protected $quotation_prefix = 'quotation_gwaworld_';
protected $base_url = 'http://154.85.53.6:8001/getTokenBalance';
public function symbolExists($tag = 'GWA', $aim = "USDT")
{
......@@ -56,11 +56,19 @@ class Gwa extends Exchange implements ExchangeInterface
{
$curl = new Curl();
$res = $curl->get($this->base_url, false);
if (is_array($res) && 1 == $res['code']) {
$key = $this->quotation_prefix . 'GWAUSDT';
$this->redis->hmset($key, 'low', $res['data']['currPrice'], 'high', $res['data']['currPrice'], 'last', $res['data']['currPrice'], 'change', $res['data']['range']);
if (!$this->redis->sismember($this->supported_symbol, 'GWAUSDT')) {
$this->redis->sadd($this->supported_symbol, 'GWAUSDT');
if (is_array($res) && isset($res['data'])) {
$data = $res['data']['ticker'];
foreach ($data as $item) {
$key = $this->quotation_prefix . strtoupper($item['symbol']);
$low = isset($item['low']) ? $item['low'] : 0;
$high = isset($item['high']) ? $item['high'] : 0;
$last = isset($item['last']) ? $item['last'] : 0;
$vol = isset($item['vol']) ? $item['vol'] : 0;
$change = isset($item['range']) ? $item['range'] : 0;
$this->redis->hmset($key, 'low', $low, 'high', $high, 'last', $last, 'vol', $vol, 'change', $change);
if (!$this->redis->sismember($this->supported_symbol, strtoupper($item['symbol']))){
$this->redis->sadd($this->supported_symbol, strtoupper($item['symbol']));
}
}
}
}
......
......@@ -14,13 +14,13 @@ use linslin\yii2\curl\Curl;
class GwaBuilder extends FactoryService
{
protected $base_url = 'https://api.gwaworld.io';
protected $supported_symbol = 'supported_symbol_gwa';
protected $supported_symbol_list = 'supported_symbol_gwa_list';
protected $supported_symbol = 'supported_symbol_gwaworld';
protected $supported_symbol_list = 'supported_symbol_gwaworld_list';
protected $supported_symbol_close_asc = 'supported_symbol_close_asc_gwa';
protected $supported_symbol_close_desc = 'supported_symbol_close_desc_gwa';
protected $supported_symbol_change_asc = 'supported_symbol_change_asc_gwa';
protected $supported_symbol_change_desc = 'supported_symbol_change_desc_gwa';
protected $quotation_prefix = 'quotation_gwa_';
protected $quotation_prefix = 'quotation_gwaworld_';
public function getHotTicker($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