Commit 03e87e57 authored by rlgy's avatar rlgy

bittrex api

parent 43ee5f02
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-6-28
* Time: 上午9:25
*/
namespace common\service\exchange;
use Yii;
class Bittrex extends Exchange implements ExchangeInterface
{
protected $supported_symbol = 'supported_symbol_bittrex';
protected $quotation_prefix = 'quotation_bittrex_';
public function formatSymbol($tag = 'BTC', $aim = 'USD')
{
return strtoupper(trim($tag) . '-' . trim($aim));
}
public function setSupportedSymbol()
{
$api = 'https://bittrex.com/api/v1.1/public/getmarkets';
$rev = $this->ch->get($api, false);
if ($rev && $rev['success']) {
$lists = $rev['result'];
foreach ($lists as $item) {
$this->redis->sadd($this->supported_symbol, $item['MarketName']);
}
}
}
public function setQuotation()
{
$api = 'https://bittrex.com/api/v1.1/public/getmarketsummaries';
$rev = $this->ch->get($api, false);
if ($rev && $rev['success']) {
$lists = $rev['result'];
foreach ($lists as $item) {
$this->redis->hmset($this->quotation_prefix . $item['MarketName'], 'low', $item['Low'], 'high',
$item['High'], 'last', $item['Last']);
}
}
}
}
\ 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