Commit 3fcec3c2 authored by shajiaiming's avatar shajiaiming

行情更新

parent 0730c54b
...@@ -154,6 +154,7 @@ class TickerController extends BaseController ...@@ -154,6 +154,7 @@ class TickerController extends BaseController
$temp['low_usd'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['usd']); $temp['low_usd'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $quotation['high'] * $this->basic_price[$tag_second]['rmb']); $temp['high_rmb'] = (float)sprintf("%0.4f", $quotation['high'] * $this->basic_price[$tag_second]['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['rmb']); $temp['low_rmb'] = (float)sprintf("%0.4f", $quotation['low'] * $this->basic_price[$tag_second]['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $quotation['vol']);
$temp['platform_us'] = $val['platform']; $temp['platform_us'] = $val['platform'];
if ('ZHAOBI' == strtoupper($val['platform'])) { if ('ZHAOBI' == strtoupper($val['platform'])) {
$temp['platform_zh'] = '找币'; $temp['platform_zh'] = '找币';
......
...@@ -44,7 +44,8 @@ class ExchangeBusiness ...@@ -44,7 +44,8 @@ class ExchangeBusiness
15 => 'Tsc', 15 => 'Tsc',
16 => 'Binance', 16 => 'Binance',
17 => 'Ceohk', 17 => 'Ceohk',
18 => 'Biki' 18 => 'Biki',
19 => 'Bilaxy'
]; ];
/** /**
......
<?php
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Bilaxy extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bilaxy';
protected $quotation_prefix = 'quotation_bilaxy_';
protected $base_url = 'https://api.bilaxy.com/v1/tickers';
public function symbolExists($tag = 'BVA', $aim = "USDT")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public function formatSymbol($tag = 'BVA', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'BVA_USDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['data'])) {
$data = $content['data'];
$key = $this->quotation_prefix . 'BVA_USDT';
foreach ($data as $item) {
if ( 260 == $item['symbol']) {
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']);
$this->redis->sadd($this->supported_symbol, 'KPC8_USDT');
}
}
}
}
}
\ 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