-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsx.php
143 lines (134 loc) · 5.21 KB
/
dsx.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
namespace ccxt;
class dsx extends liqui {
public function describe () {
return array_replace_recursive (parent::describe (), array (
'id' => 'dsx',
'name' => 'DSX',
'countries' => 'UK',
'rateLimit' => 1500,
'hasCORS' => false,
'hasFetchOrder' => true,
'hasFetchOrders' => true,
'hasFetchOpenOrders' => true,
'hasFetchClosedOrders' => true,
'hasFetchTickers' => true,
'hasFetchMyTrades' => true,
'urls' => array (
'logo' => 'https://user-images.githubusercontent.com/1294454/27990275-1413158a-645a-11e7-931c-94717f7510e3.jpg',
'api' => array (
'public' => 'https://dsx.uk/mapi', // market data
'private' => 'https://dsx.uk/tapi', // trading
'dwapi' => 'https://dsx.uk/dwapi', // deposit/withdraw
),
'www' => 'https://dsx.uk',
'doc' => array (
'https://api.dsx.uk',
'https://dsx.uk/api_docs/public',
'https://dsx.uk/api_docs/private',
'',
),
),
'api' => array (
// market data (public)
'public' => array (
'get' => array (
'barsFromMoment/{id}/{period}/{start}', // empty reply :\
'depth/{pair}',
'info',
'lastBars/{id}/{period}/{amount}', // period is (m, h or d)
'periodBars/{id}/{period}/{start}/{end}',
'ticker/{pair}',
'trades/{pair}',
),
),
// trading (private)
'private' => array (
'post' => array (
'getInfo',
'TransHistory',
'TradeHistory',
'OrderHistory',
'ActiveOrders',
'Trade',
'CancelOrder',
),
),
// deposit / withdraw (private)
'dwapi' => array (
'post' => array (
'getCryptoDepositAddress',
'cryptoWithdraw',
'fiatWithdraw',
'getTransactionStatus',
'getTransactions',
),
),
),
));
}
public function get_base_quote_from_market_id ($id) {
$uppercase = strtoupper ($id);
$base = mb_substr ($uppercase, 0, 3);
$quote = mb_substr ($uppercase, 3, 6);
$base = $this->common_currency_code($base);
$quote = $this->common_currency_code($quote);
return array ( $base, $quote );
}
public function fetch_balance ($params = array ()) {
$this->load_markets();
$response = $this->privatePostGetInfo ();
$balances = $response['return'];
$result = array ( 'info' => $balances );
$funds = $balances['funds'];
$currencies = array_keys ($funds);
for ($c = 0; $c < count ($currencies); $c++) {
$currency = $currencies[$c];
$uppercase = strtoupper ($currency);
$uppercase = $this->common_currency_code($uppercase);
$account = array (
'free' => $funds[$currency],
'used' => 0.0,
'total' => $balances['total'][$currency],
);
$account['used'] = $account['total'] - $account['free'];
$result[$uppercase] = $account;
}
return $this->parse_balance($result);
}
public function parse_ticker ($ticker, $market = null) {
$timestamp = $ticker['updated'] * 1000;
$symbol = null;
if ($market)
$symbol = $market['symbol'];
return array (
'symbol' => $symbol,
'timestamp' => $timestamp,
'datetime' => $this->iso8601 ($timestamp),
'high' => $this->safe_float($ticker, 'high'),
'low' => $this->safe_float($ticker, 'low'),
'bid' => $this->safe_float($ticker, 'buy'),
'ask' => $this->safe_float($ticker, 'sell'),
'vwap' => null,
'open' => null,
'close' => null,
'first' => null,
'last' => $this->safe_float($ticker, 'last'),
'change' => null,
'percentage' => null,
'average' => 1 / $this->safe_float($ticker, 'avg'),
'baseVolume' => $this->safe_float($ticker, 'vol'),
'quoteVolume' => $this->safe_float($ticker, 'vol_cur'),
'info' => $ticker,
);
}
public function get_order_id_key () {
return 'orderId';
}
public function sign_body_with_secret ($body) {
return $this->decode ($this->hmac ($this->encode ($body), $this->encode ($this->secret), 'sha512', 'base64'));
}
public function get_version_string () {
return ''; // they don't prepend version number to public URLs as other BTC-e clones do
}
}