-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathokex.js
66 lines (60 loc) · 2.29 KB
/
okex.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
'use strict';
// ---------------------------------------------------------------------------
const okcoinusd = require ('./okcoinusd.js');
// ---------------------------------------------------------------------------
module.exports = class okex extends okcoinusd {
describe () {
return this.deepExtend (super.describe (), {
'id': 'okex',
'name': 'OKEX',
'countries': [ 'CN', 'US' ],
'has': {
'CORS': false,
'hutureMarkets': true,
'hasFetchTickers': true,
'fetchTickers': true,
'futureMarkets': true,
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/32552768-0d6dd3c6-c4a6-11e7-90f8-c043b64756a7.jpg',
'api': {
'web': 'https://www.okex.com/v2',
'public': 'https://www.okex.com/api',
'private': 'https://www.okex.com/api',
},
'www': 'https://www.okex.com',
'doc': 'https://www.okex.com/rest_getStarted.html',
'fees': 'https://www.okex.com/fees.html',
},
});
}
commonCurrencyCode (currency) {
const currencies = {
'FAIR': 'FairGame',
};
if (currency in currencies)
return currencies[currency];
return currency;
}
async fetchTickers (symbols = undefined, params = {}) {
await this.loadMarkets ();
let request = {};
let response = await this.publicGetTickers (this.extend (request, params));
let tickers = response['tickers'];
let timestamp = parseInt (response['date']) * 1000;
let result = {};
for (let i = 0; i < tickers.length; i++) {
let ticker = tickers[i];
let market = undefined;
if ('symbol' in ticker) {
let marketId = ticker['symbol'];
if (marketId in this.markets_by_id)
market = this.markets_by_id[marketId];
}
ticker = this.parseTicker (this.extend (tickers[i], { 'timestamp': timestamp }), market);
let symbol = ticker['symbol'];
result[symbol] = ticker;
}
return result;
}
};