Commit 55eac7b2 authored by shajiaiming's avatar shajiaiming

add new coin

parent c68b8d6f
......@@ -32,6 +32,7 @@ class ExchangeBusiness
3 => 'Bitfinex',
4 => 'Bittrex',
5 => 'Zb',
6 => 'Ha'
];
/**
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
class Ha extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_ha';
protected $quotation_prefix = 'quotation_ha_';
protected $base_url = 'http://www.token7.club/exapi/api/v1/allTicker';
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtoupper($tag . $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'BTYUSDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$content = $this->ch->get($this->base_url, false);
if (is_array($content) && isset($content['date']) && isset($content['ticker'])) {
$data = $content['ticker'];
foreach ($data as $item) {
if (in_array($item['symbol'], ['GM_HA', 'BSTC_HA'])) {
$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']);
}
}
}
}
}
\ 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