-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdsx.js
147 lines (136 loc) · 5.09 KB
/
dsx.js
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
144
145
146
147
"use strict";
// ---------------------------------------------------------------------------
const liqui = require ('./liqui.js')
// ---------------------------------------------------------------------------
module.exports = class dsx extends liqui {
describe () {
return this.deepExtend (super.describe (), {
'id': 'dsx',
'name': 'DSX',
'countries': 'UK',
'rateLimit': 1500,
'hasCORS': false,
'hasFetchOrder': true,
'hasFetchOrders': true,
'hasFetchOpenOrders': true,
'hasFetchClosedOrders': true,
'hasFetchTickers': true,
'hasFetchMyTrades': true,
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/27990275-1413158a-645a-11e7-931c-94717f7510e3.jpg',
'api': {
'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': [
'https://api.dsx.uk',
'https://dsx.uk/api_docs/public',
'https://dsx.uk/api_docs/private',
'',
],
},
'api': {
// market data (public)
'public': {
'get': [
'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': {
'post': [
'getInfo',
'TransHistory',
'TradeHistory',
'OrderHistory',
'ActiveOrders',
'Trade',
'CancelOrder',
],
},
// deposit / withdraw (private)
'dwapi': {
'post': [
'getCryptoDepositAddress',
'cryptoWithdraw',
'fiatWithdraw',
'getTransactionStatus',
'getTransactions',
],
},
},
});
}
getBaseQuoteFromMarketId (id) {
let uppercase = id.toUpperCase ();
let base = uppercase.slice (0, 3);
let quote = uppercase.slice (3, 6);
base = this.commonCurrencyCode (base);
quote = this.commonCurrencyCode (quote);
return [ base, quote ];
}
async fetchBalance (params = {}) {
await this.loadMarkets ();
let response = await this.privatePostGetInfo ();
let balances = response['return'];
let result = { 'info': balances };
let funds = balances['funds'];
let currencies = Object.keys (funds);
for (let c = 0; c < currencies.length; c++) {
let currency = currencies[c];
let uppercase = currency.toUpperCase ();
uppercase = this.commonCurrencyCode (uppercase);
let account = {
'free': funds[currency],
'used': 0.0,
'total': balances['total'][currency],
};
account['used'] = account['total'] - account['free'];
result[uppercase] = account;
}
return this.parseBalance (result);
}
parseTicker (ticker, market = undefined) {
let timestamp = ticker['updated'] * 1000;
let symbol = undefined;
if (market)
symbol = market['symbol'];
return {
'symbol': symbol,
'timestamp': timestamp,
'datetime': this.iso8601 (timestamp),
'high': this.safeFloat (ticker, 'high'),
'low': this.safeFloat (ticker, 'low'),
'bid': this.safeFloat (ticker, 'buy'),
'ask': this.safeFloat (ticker, 'sell'),
'vwap': undefined,
'open': undefined,
'close': undefined,
'first': undefined,
'last': this.safeFloat (ticker, 'last'),
'change': undefined,
'percentage': undefined,
'average': 1 / this.safeFloat (ticker, 'avg'),
'baseVolume': this.safeFloat (ticker, 'vol'),
'quoteVolume': this.safeFloat (ticker, 'vol_cur'),
'info': ticker,
};
}
getOrderIdKey () {
return 'orderId';
}
signBodyWithSecret (body) {
return this.decode (this.hmac (this.encode (body), this.encode (this.secret), 'sha512', 'base64'));
}
getVersionString () {
return ''; // they don't prepend version number to public URLs as other BTC-e clones do
}
}