Commit 536399a2 authored by shajiaiming's avatar shajiaiming

dag ticker

parent 30f735a0
...@@ -33,21 +33,21 @@ class ExchangeBusiness ...@@ -33,21 +33,21 @@ class ExchangeBusiness
4 => 'Bittrex', 4 => 'Bittrex',
5 => 'Zb', 5 => 'Zb',
6 => 'Token7', 6 => 'Token7',
7 => 'S', 7 => 'Zg',
8 => 'Zg', 8 => 'Go',
9 => 'Go', 9 => 'Zhaobi',
10 => 'Zhaobi', 10 => 'Ex',
11 => 'Gdpro', 11 => 'Zt',
12 => 'Ex', 12 => 'Tsc',
13 => 'Zt', 13 => 'Binance',
14 => 'Tsc', 14 => 'Biki',
15 => 'Binance', 15 => 'Bilaxy',
16 => 'Ceohk', 16 => 'Bitnasdaq',
17 => 'Biki', 17 => 'Dag',
18 => 'Bilaxy', 18 => 'Boc',
19 => 'Bitnasdaq', //7 => 'S',//已挂
20 => 'Boc' //11 => 'Gdpro',//已挂
//16 => 'Ceohk', //已挂
]; ];
/** /**
...@@ -100,7 +100,7 @@ class ExchangeBusiness ...@@ -100,7 +100,7 @@ class ExchangeBusiness
goto doEnd; goto doEnd;
} }
if (strtoupper($tag) == 'GST' || strtoupper($tag) == 'JNTK' || strtoupper($tag) == 'SPT' ||strtoupper($tag) == 'STO' || strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') { if (strtoupper($tag) == 'GST' || strtoupper($tag) == 'JNTK' || strtoupper($tag) == 'SPT' || strtoupper($tag) == 'STO' || strtoupper($tag) == 'GM' || strtoupper($tag) == 'BSTC' || strtoupper($tag) == 'RYH' || strtoupper($tag) == 'CNDT' || strtoupper($tag) == 'WL' || strtoupper($tag) == 'ETS' || strtoupper($tag) == 'LIMS' || strtoupper($tag) == 'AT' || strtoupper($tag) == 'BTJ') {
$quotation = [ $quotation = [
'low' => 0, 'low' => 0,
'high' => 0, 'high' => 0,
...@@ -123,6 +123,13 @@ class ExchangeBusiness ...@@ -123,6 +123,13 @@ class ExchangeBusiness
goto doEnd; goto doEnd;
} }
if (in_array(strtoupper($tag), ['DAG'])) {
$exchange = ExchangeFactory::createExchange("Dag");
$quotation = $exchange->getTicker($tag, 'USDT');
$quotation['rmb'] = (float)sprintf("%0.2f", $quotation['last']);
goto doEnd;
}
if (in_array(strtoupper($tag), ['GM', 'BSTC'])) { if (in_array(strtoupper($tag), ['GM', 'BSTC'])) {
$exchange = ExchangeFactory::createExchange("Token7"); $exchange = ExchangeFactory::createExchange("Token7");
$quotation = $exchange->getTicker($tag, 'HA'); $quotation = $exchange->getTicker($tag, 'HA');
......
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace common\service\exchange;
use linslin\yii2\curl\Curl;
class Dag extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_dag';
protected $quotation_prefix = 'quotation_dag_';
protected $base_url = 'https://www.7xex.com/m/ticker/DAGUSDT';
public function symbolExists($tag = 'DAG', $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 = 'DAG', $aim = 'USDT')
{
return strtoupper($tag . $aim);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public function setSupportedSymbol()
{
$this->redis->sadd($this->supported_symbol, 'DAGUSDT');
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public function setQuotation()
{
$curl = new Curl();
$content = $curl->get($this->base_url, false);
if (is_array($content)) {
$key = $this->quotation_prefix . 'DAGUSDT';
$this->redis->hmset($key, 'low', $content['low'], 'high', $content['high'], 'last', $content['close'], 'vol', $content['volume']);
$this->redis->sadd($this->supported_symbol, 'DAGUSDT');
}
}
}
\ 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