Commit 91335aac authored by shajiaiming's avatar shajiaiming

issumit ticker

parent bc198bfe
...@@ -44,7 +44,8 @@ class ExchangeBusiness ...@@ -44,7 +44,8 @@ class ExchangeBusiness
15 => 'Bitnasdaq', 15 => 'Bitnasdaq',
16 => 'Dag', 16 => 'Dag',
17 => 'Coinka', 17 => 'Coinka',
18 => 'Boc', 18 => 'Isummit',
19 => 'Boc',
//1 => 'Hadax', //不需要 //1 => 'Hadax', //不需要
...@@ -139,6 +140,12 @@ class ExchangeBusiness ...@@ -139,6 +140,12 @@ class ExchangeBusiness
} }
$f = false; $f = false;
$quotation = []; $quotation = [];
if (in_array(strtoupper($tag), ['SUM', 'USDW', 'FUT'])) {
$exchange = ExchangeFactory::createExchange("Isummit");
$quotation = $exchange->getTicker($tag, 'USDT');
goto doEnd;
}
if (in_array(strtoupper($tag), ['PAX'])) { if (in_array(strtoupper($tag), ['PAX'])) {
$exchange = ExchangeFactory::createExchange("HuoBi"); $exchange = ExchangeFactory::createExchange("HuoBi");
$quotation = $exchange->getTicker($tag, 'husd'); $quotation = $exchange->getTicker($tag, 'husd');
...@@ -337,7 +344,7 @@ class ExchangeBusiness ...@@ -337,7 +344,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', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT', 'TSC'])) { if (in_array(strtoupper($tag), ['FOLI', 'CIC', 'KPC8', 'BVA', 'DAG', 'BNC', 'GHP', 'DRA', 'ETC', 'PAX', 'STH', 'XJH', 'SFT', 'TSC', 'SUM', 'USDW', 'FUT'])) {
$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
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-26
* Time: 下午7:21
*/
namespace common\service\exchange;
use Yii;
use linslin\yii2\curl\Curl;
class Isummit extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_isummit';
protected $quotation_prefix = 'quotation_isummit_';
protected $base_url = 'http://www.isummit.top';
public function formatSymbol($tag = 'BTC', $aim = 'USDT')
{
return strtolower(trim($tag) . trim($aim));
}
public function setSupportedSymbol()
{
}
public function setQuotation()
{
$curl = new Curl();
$api = $this->base_url . '/api/coins/market';
$res = $curl->get($api, false);
if (isset($res['code']) && 200 == $res['code'] && isset($res['data'])) {
foreach ($res['data'] as $item) {
if (in_array(strtoupper($item['coin']), ['SUM', 'USDW', 'FUT'])) {
$low = isset($item['price']) ? $item['price'] : 0;
$high = isset($item['price']) ? $item['price'] : 0;
$last = isset($item['price']) ? $item['price'] : 0;
$open = isset($item['price']) ? $item['price'] : 0;
$cache_key = $this->quotation_prefix . strtolower($item['coin'] . 'USDT');
$this->redis->hmset($cache_key, 'low', $low, 'high', $high, 'last', $last, 'open', $open);
}
}
}
}
}
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