Commit fb742e40 authored by rlgy's avatar rlgy

update

parent ab959de2
......@@ -23,11 +23,12 @@ class ExchangeBusiness
* @var array
*/
private static $exchanges = [
0 => 'HuoBi',
1 => 'Hadax',
2 => 'Bitfinex',
3 => 'Bittrex',
4 => 'Zb',
0 => 'Bty',
1 => 'HuoBi',
2 => 'Hadax',
3 => 'Bitfinex',
4 => 'Bittrex',
5 => 'Zb',
];
/**
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
class Bty extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bty';
protected $quotation_prefix = 'quotation_bty_';
protected $base_url = 'http://40.83.77.188/api/data/Ticker?sort=cname';
/**
* 转化交易对为请求变量
*
* @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['code']) && $content['code'] == 200) {
$data = $content['data']['USDT'];
foreach ($data as $item) {
if ($item['symbol'] == 'BTYUSDT') {
$data = $item;
break;
}
}
$key = $this->quotation_prefix . 'BTYUSDT';
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last'], 'rmb', $data['lastrmb']);
$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