Commit e42f9351 authored by shajiaiming's avatar shajiaiming

debug

parent b5b4cb8a
...@@ -65,6 +65,13 @@ class ExchangeBusiness ...@@ -65,6 +65,13 @@ class ExchangeBusiness
* @var $exchange \common\service\exchange\Exchange * @var $exchange \common\service\exchange\Exchange
*/ */
$exchange = ExchangeFactory::createExchange($exchange); $exchange = ExchangeFactory::createExchange($exchange);
if('GM' == $tag || 'BSTC' == $tag){
$quotation = $exchange->getTickerToken7($tag, 'HA');
$f = true;
break;
}
$exchange = ExchangeFactory::createExchange($exchange);
if ($exchange->symbolExists($tag)) { if ($exchange->symbolExists($tag)) {
$quotation = $exchange->getTicker($tag); $quotation = $exchange->getTicker($tag);
$f = true; $f = true;
......
...@@ -81,4 +81,12 @@ abstract class Exchange ...@@ -81,4 +81,12 @@ abstract class Exchange
$values = $this->redis->hvals($this->quotation_prefix . $symbol); $values = $this->redis->hvals($this->quotation_prefix . $symbol);
return array_combine($keys, $values); return array_combine($keys, $values);
} }
public function getTickerToken7($tag = 'BTC', $aim = "USDT")
{
$symbol = $this->formatSymbol($tag, $aim);
$keys = $this->redis->hkeys($this->quotation_prefix . $symbol);
$values = $this->redis->hvals($this->quotation_prefix . $symbol);
return array_combine($keys, $values);
}
} }
\ No newline at end of file
...@@ -14,6 +14,15 @@ class Token7 extends Exchange implements ExchangeInterface ...@@ -14,6 +14,15 @@ class Token7 extends Exchange implements ExchangeInterface
protected $quotation_prefix = 'quotation_token7_'; protected $quotation_prefix = 'quotation_token7_';
protected $base_url = 'http://www.token7.club/exapi/api/v1/allTicker'; protected $base_url = 'http://www.token7.club/exapi/api/v1/allTicker';
public function symbolExists($tag = 'BTC', $aim = "USD")
{
$supported = $this->redis->smembers($this->supported_symbol);
if (is_array($supported) && in_array($this->formatSymbol($tag, $aim), $supported)) {
return true;
}
return false;
}
/** /**
* 转化交易对为请求变量 * 转化交易对为请求变量
* *
...@@ -21,9 +30,9 @@ class Token7 extends Exchange implements ExchangeInterface ...@@ -21,9 +30,9 @@ class Token7 extends Exchange implements ExchangeInterface
* @param string $aim * @param string $aim
* @return mixed * @return mixed
*/ */
public function formatSymbol($tag = 'BTC', $aim = 'USDT') public function formatSymbol($tag = 'GM', $aim = 'HA')
{ {
return strtoupper($tag . $aim); return strtoupper($tag .'_'. $aim);
} }
/** /**
...@@ -44,6 +53,35 @@ class Token7 extends Exchange implements ExchangeInterface ...@@ -44,6 +53,35 @@ class Token7 extends Exchange implements ExchangeInterface
public function setQuotation() public function setQuotation()
{ {
$content = $this->ch->get($this->base_url, false); $content = $this->ch->get($this->base_url, false);
$content = [
"date" => "2019-03-27 14:28:08",
"ticker" => [
[
"symbol"=>"GM_HA",
"vol"=>"759301.65",
"high"=>"2.608",
"last"=>"2.607",
"low"=>"2.607",
"sell"=>"2.615",
"buy"=>"2.613",
"yesterdayPrice"=>"2.609",
"change"=>"-0.077",
"lastExchangPrice"=>"2.608"
],
[
"symbol"=>"BSTC_HA",
"vol"=>"321550.59",
"high"=>"0.029",
"last"=>"0.029",
"low"=>"0.029",
"sell"=>"0.029",
"buy"=>"0.028",
"yesterdayPrice"=>"0.027",
"change"=>"7.407",
"lastExchangPrice"=>"0.029"]
]
];
if (is_array($content) && isset($content['date']) && isset($content['ticker'])) { if (is_array($content) && isset($content['date']) && isset($content['ticker'])) {
$data = $content['ticker']; $data = $content['ticker'];
foreach ($data as $item) { foreach ($data as $item) {
......
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