Commit b7e9b242 authored by shajiaiming's avatar shajiaiming

新币种行情

parent 6b6ff4ff
...@@ -43,7 +43,8 @@ class ExchangeBusiness ...@@ -43,7 +43,8 @@ class ExchangeBusiness
14 => 'Zt', 14 => 'Zt',
15 => 'Tsc', 15 => 'Tsc',
16 => 'Binance', 16 => 'Binance',
17 => 'Ceohk' 17 => 'Ceohk',
18 => 'Biki'
]; ];
/** /**
...@@ -56,7 +57,7 @@ class ExchangeBusiness ...@@ -56,7 +57,7 @@ class ExchangeBusiness
public static function getquatation($tag = 'btc') public static function getquatation($tag = 'btc')
{ {
$coin_quotation_disable_items = Yii::$app->params['coin_quotation_disable_items']; $coin_quotation_disable_items = Yii::$app->params['coin_quotation_disable_items'];
if (strtoupper($tag) == 'CCNY') { if (strtoupper($tag) == 'CCNY' || strtoupper($tag) == 'CNYT') {
$exchange = ExchangeFactory::createExchange("Bty"); $exchange = ExchangeFactory::createExchange("Bty");
$rate = $exchange->getTicker("BTY", "USDT"); $rate = $exchange->getTicker("BTY", "USDT");
$rate = (float)$rate['rmb'] / $rate['last']; $rate = (float)$rate['rmb'] / $rate['last'];
...@@ -66,6 +67,16 @@ class ExchangeBusiness ...@@ -66,6 +67,16 @@ class ExchangeBusiness
$quotation['last'] = (float)sprintf("%0.4f", $quotation['rmb'] / $rate); $quotation['last'] = (float)sprintf("%0.4f", $quotation['rmb'] / $rate);
goto doEnd; goto doEnd;
} }
if (strtoupper($tag) == 'YPLUS') {
$quotation = [
'low' => 10,
'high' => 10,
'last' => 10,
'rmb' => 10,
];
goto doEnd;
}
if (strtoupper($tag) == 'BOSS') { if (strtoupper($tag) == 'BOSS') {
$quotation = [ $quotation = [
'low' => 2000, 'low' => 2000,
...@@ -181,6 +192,12 @@ class ExchangeBusiness ...@@ -181,6 +192,12 @@ class ExchangeBusiness
goto doEnd; goto doEnd;
} }
if (in_array(strtoupper($tag), ['KPC8'])) {
$exchange = ExchangeFactory::createExchange("Biki");
$quotation = $exchange->getTicker('KPC8', 'USDT');
goto doEnd;
}
if (in_array(strtoupper($tag), ['SJPY'])) { if (in_array(strtoupper($tag), ['SJPY'])) {
$exchange = ExchangeFactory::createExchange("Boc"); $exchange = ExchangeFactory::createExchange("Boc");
$quotation = $exchange->getTicker('CNY', 'JPY'); $quotation = $exchange->getTicker('CNY', 'JPY');
...@@ -250,7 +267,7 @@ class ExchangeBusiness ...@@ -250,7 +267,7 @@ class ExchangeBusiness
$exchange = ExchangeFactory::createExchange("Go"); $exchange = ExchangeFactory::createExchange("Go");
$rate = $exchange->getTicker("CNY", "USD"); $rate = $exchange->getTicker("CNY", "USD");
$cny_usd_rate = 1 / $rate['last']; $cny_usd_rate = 1 / $rate['last'];
if (in_array(strtoupper($tag), ['FOLI', 'CIC'])) { if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8'])) {
$quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']); $quotation['usd'] = (float)sprintf("%0.4f", $quotation['last']);
$quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate); $quotation['rmb'] = (float)sprintf("%0.4f", $quotation['last'] / $cny_usd_rate);
} else if (in_array(strtoupper($tag), ['SUSD'])) { } else if (in_array(strtoupper($tag), ['SUSD'])) {
......
<?php
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Biki extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_biki';
protected $quotation_prefix = 'quotation_biki_';
protected $base_url = 'https://openapi.biki.com/open/api/get_ticker?symbol=kpc8usdt';
public function symbolExists($tag = 'KPC8', $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 = 'KPC8', $aim = 'USDT')
{
return strtoupper($tag .'_'. $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'KPC8_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 . 'KPC8_USDT';
$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