-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchbtc.php
60 lines (54 loc) · 2.71 KB
/
chbtc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace ccxt;
class chbtc extends zb {
public function describe () {
return array_replace_recursive (parent::describe (), array (
'id' => 'chbtc',
'name' => 'CHBTC',
'countries' => 'CN',
'rateLimit' => 1000,
'version' => 'v1',
'has' => array (
'CORS' => false,
'fetchOrder' => true
),
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/28555659-f0040dc2-7109-11e7-9d99-688a438bf9f4.jpg',
'api' => array (
'public' => 'http://api.chbtc.com/data', // no https for public API
'private' => 'https://trade.chbtc.com/api',
),
'www' => 'https://trade.chbtc.com/api',
'doc' => 'https://www.chbtc.com/i/developer',
),
));
}
public function get_market_field_name () {
return 'currency';
}
public function fetch_markets () {
return array (
'BTC/CNY' => array ( 'id' => 'btc_cny', 'symbol' => 'BTC/CNY', 'base' => 'BTC', 'quote' => 'CNY' ),
'LTC/CNY' => array ( 'id' => 'ltc_cny', 'symbol' => 'LTC/CNY', 'base' => 'LTC', 'quote' => 'CNY' ),
'ETH/CNY' => array ( 'id' => 'eth_cny', 'symbol' => 'ETH/CNY', 'base' => 'ETH', 'quote' => 'CNY' ),
'ETC/CNY' => array ( 'id' => 'etc_cny', 'symbol' => 'ETC/CNY', 'base' => 'ETC', 'quote' => 'CNY' ),
'BTS/CNY' => array ( 'id' => 'bts_cny', 'symbol' => 'BTS/CNY', 'base' => 'BTS', 'quote' => 'CNY' ),
// 'EOS/CNY' => array ( 'id' => 'eos_cny', 'symbol' => 'EOS/CNY', 'base' => 'EOS', 'quote' => 'CNY' ),
'BCH/CNY' => array ( 'id' => 'bcc_cny', 'symbol' => 'BCH/CNY', 'base' => 'BCH', 'quote' => 'CNY' ),
'HSR/CNY' => array ( 'id' => 'hsr_cny', 'symbol' => 'HSR/CNY', 'base' => 'HSR', 'quote' => 'CNY' ),
'QTUM/CNY' => array ( 'id' => 'qtum_cny', 'symbol' => 'QTUM/CNY', 'base' => 'QTUM', 'quote' => 'CNY' ),
);
}
public function request ($path, $api = 'public', $method = 'GET', $params = array (), $headers = null, $body = null) {
$response = $this->fetch2 ($path, $api, $method, $params, $headers, $body);
if ($api == 'private') {
if (is_array ($response) && array_key_exists ('code', $response))
throw new ExchangeError ($this->id . ' ' . $this->json ($response));
}
if (is_array ($response) && array_key_exists ('result', $response)) {
if (!$response['result'])
throw new ExchangeError ($this->id . ' ' . $this->json ($response));
}
return $response;
}
}