Commit 8eb64434 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/ticker' into 'master'

zyc hot ticker See merge request !411
parents 13bf4dc4 d30471e0
...@@ -335,6 +335,22 @@ class TickerController extends BaseController ...@@ -335,6 +335,22 @@ class TickerController extends BaseController
] ]
]; ];
} }
if (52 == $platform_id) {
$datas = [
[
'exchange' => 'huobi',
'symbol' => [
'btcusdt',
'ethusdt'
],
], [
'exchange' => 'ztb',
'symbol' => [
'zycusdt'
],
]
];
}
if (53 == $platform_id) { if (53 == $platform_id) {
$datas = [ $datas = [
[ [
......
...@@ -34,7 +34,7 @@ class Ztb extends Exchange implements ExchangeInterface ...@@ -34,7 +34,7 @@ class Ztb extends Exchange implements ExchangeInterface
*/ */
public function formatSymbol($tag = 'ZYC', $aim = 'USDT') public function formatSymbol($tag = 'ZYC', $aim = 'USDT')
{ {
return strtoupper($tag .'_'. $aim); return strtoupper($tag . $aim);
} }
/** /**
...@@ -44,7 +44,7 @@ class Ztb extends Exchange implements ExchangeInterface ...@@ -44,7 +44,7 @@ class Ztb extends Exchange implements ExchangeInterface
*/ */
public function setSupportedSymbol() public function setSupportedSymbol()
{ {
$this->redis->sadd($this->supported_symbol, 'ZYC_USDT'); $this->redis->sadd($this->supported_symbol, 'ZYCUSDT');
} }
/** /**
...@@ -59,10 +59,10 @@ class Ztb extends Exchange implements ExchangeInterface ...@@ -59,10 +59,10 @@ class Ztb extends Exchange implements ExchangeInterface
if (is_array($content) && isset($content['ticker'])) { if (is_array($content) && isset($content['ticker'])) {
$data = $content['ticker']; $data = $content['ticker'];
foreach ($data as $item) { foreach ($data as $item) {
if (in_array($item['symbol'], ['ZYC_USDT'])) { if (in_array($item['symbol'], ['ZYCUSDT'])) {
$data = $item; $data = $item;
$key = $this->quotation_prefix . $item['symbol']; $key = $this->quotation_prefix . $item['symbol'];
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last']); $this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['last'], 'vol', $data['vol'], 'change', $data['change']);
$this->redis->sadd($this->supported_symbol, $item['symbol']); $this->redis->sadd($this->supported_symbol, $item['symbol']);
} }
} }
......
<?php
/**
* Created by PhpStorm.
* User: jiaming
* Date: 2019/8/15
* Time: 10:10
*/
namespace common\service\exchange\factory;
use common\components\Tools;
use linslin\yii2\curl\Curl;
class ZtbBuilder extends FactoryService
{
protected $base_url = 'https://api.ztb.pro';
protected $supported_symbol = 'supported_symbol_ztb';
protected $supported_symbol_list = 'supported_symbol_ztb_list';
protected $supported_symbol_close_asc = 'supported_symbol_close_asc_ztb';
protected $supported_symbol_close_desc = 'supported_symbol_close_desc_ztb';
protected $supported_symbol_change_asc = 'supported_symbol_change_asc_ztb';
protected $supported_symbol_change_desc = 'supported_symbol_change_desc_ztb';
protected $quotation_prefix = 'quotation_ztb_';
public function getHotTicker($symbol = [])
{
if (empty($symbol)) {
return ['code' => $this->code, 'ticker' => []];
}
$ticker = [];
foreach ($symbol as $val) {
list($low, $high, $change, $last, $vol) = $this->redis->hmget($this->quotation_prefix . strtoupper(str_replace('USDT', '_USDT', $val)), 'low', 'high', 'change', 'last', 'vol');
$explode_arr = explode('usdt', $val);
$temp = [];
$temp['symbol'] = strtoupper($explode_arr[0]) . '/USDT';
$temp['currency'] = strtoupper($explode_arr[0]);
$temp['base_currency'] = 'USDT';
$temp['close'] = (float)sprintf("%0.6f", $last);
$temp['close_usd'] = (float)sprintf("%0.6f", $last * $this->basic_price['USDT']['usd']);
$temp['close_rmb'] = (float)sprintf("%0.4f", $last * $this->basic_price['USDT']['rmb']);
$temp['change'] = $change;
$temp['high_usd'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['usd']);
$temp['low_usd'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['usd']);
$temp['high_rmb'] = (float)sprintf("%0.4f", $high * $this->basic_price['USDT']['rmb']);
$temp['low_rmb'] = (float)sprintf("%0.4f", $low * $this->basic_price['USDT']['rmb']);
$temp['vol'] = (float)sprintf("%0.4f", $vol);
array_push($ticker, $temp);
}
if (count($ticker) > 0) {
$this->code = 0;
}
return ['code' => $this->code, 'ticker' => $ticker];
}
}
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