forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.fetchTrades.js
41 lines (29 loc) · 1.16 KB
/
test.fetchTrades.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
'use strict'
// ----------------------------------------------------------------------------
const assert = require ('assert')
, testTrade = require ('./test.trade.js')
// ----------------------------------------------------------------------------
module.exports = async (exchange, symbol) => {
const method = 'fetchTrades'
const skippedExchanges = []
if (skippedExchanges.includes (exchange.id)) {
console.log (exchange.id, 'found in ignored exchanges, skipping ' + method + '...')
return
}
if (exchange.has[method]) {
const trades = await exchange[method] (symbol)
assert (trades instanceof Array)
console.log (symbol, 'fetched', Object.values (trades).length, 'trades')
const now = Date.now ()
for (let i = 0; i < trades.length; i++) {
testTrade (exchange, trades[i], symbol, now)
if (i > 0) {
if (trades[i].timestamp && trades[i - 1].timestamp) {
assert (trades[i].timestamp >= trades[i - 1].timestamp)
}
}
}
} else {
console.log (symbol, method + '() is not supported')
}
}