-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathokex-fetch-ohlcv-since-limit.js
38 lines (30 loc) · 1.2 KB
/
okex-fetch-ohlcv-since-limit.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
const ccxt = require ('../../ccxt.js')
, log = require ('ololog')
, ansi = require ('ansicolor').nice
;(async () => {
const exchange = new ccxt['okex']()
exchange.enableRateLimit = true
let limit = undefined
let symbol = 'BTC/USDT'
let interval = '15m'
// enable either of the following two lines
exchange.options['warnOnFetchOHLCVLimitArgument'] = false
// limit = 3
const dates = [
'2014-01-01T00:00:00', // okex did not exist then
'2016-02-01T00:00:00',
'2018-02-15T00:00:00',
'2018-02-25T00:00:00',
'2018-02-27T00:00:00',
]
const results = await Promise.all (dates.map (async date => {
since = exchange.parse8601 (date)
const ohlcv = await exchange.fetchOHLCV (symbol, interval, since, limit)
const fetchingFrom = date.green
const firstCandleDate = ohlcv.length ? exchange.iso8601 (ohlcv[0][0]).yellow : undefined
const lastCandleDate = ohlcv.length ? exchange.iso8601 (ohlcv[ohlcv.length - 1][0]).yellow : undefined
const count = ohlcv.length.toString ().red
return { fetchingFrom, firstCandleDate, lastCandleDate, count, ohlcv }
}))
log (results)
}) ()