Commit 65e005bf authored by shajiaiming's avatar shajiaiming

添加新行情

parent a89fbf6f
...@@ -32,7 +32,8 @@ class ExchangeBusiness ...@@ -32,7 +32,8 @@ class ExchangeBusiness
3 => 'Bitfinex', 3 => 'Bitfinex',
4 => 'Bittrex', 4 => 'Bittrex',
5 => 'Zb', 5 => 'Zb',
6 => 'Token7' 6 => 'Token7',
7 => 'S'
]; ];
/** /**
...@@ -88,6 +89,13 @@ class ExchangeBusiness ...@@ -88,6 +89,13 @@ class ExchangeBusiness
return $quotation; return $quotation;
} }
if(in_array(strtoupper($tag),['BECC'])){
$exchange = ExchangeFactory::createExchange("S");
$quotation = $exchange->getTicker($tag, 'ST');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
return $quotation;
}
foreach (self::$exchanges as $exchange) { foreach (self::$exchanges as $exchange) {
/** /**
* @var $exchange \common\service\exchange\Exchange * @var $exchange \common\service\exchange\Exchange
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class S extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_s';
protected $quotation_prefix = 'quotation_s_';
protected $base_url = 'https://exapi.s.top/api/v1/market/detail?symbol=becc_st';
public function symbolExists($tag = 'BECC', $aim = "ST")
{
$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 = 'BECC', $aim = 'ST')
{
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()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content) && isset($content['data']) && 200 === $content['code']) {
$data = $content['data'];
$key = $this->quotation_prefix . 'BECC_ST';
$this->redis->hmset($key, 'low', $data['low'], 'high', $data['high'], 'last', $data['close']);
$this->redis->sadd($this->supported_symbol, 'BECC_ST');
}
}
}
\ 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