-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.fetchMyTrades.js
44 lines (29 loc) · 1.06 KB
/
test.fetchMyTrades.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
'use strict'
// ----------------------------------------------------------------------------
const assert = require ('assert')
, testTrade = require ('./test.trade.js')
// ----------------------------------------------------------------------------
module.exports = async (exchange, symbol) => {
const method = 'fetchMyTrades'
const skippedExchanges = [
'bitso',
]
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 ('fetched', trades.length, 'trades')
const now = Date.now ()
for (let i = 0; i < trades.length; i++) {
testTrade (exchange, trades[i], symbol, now)
if (i > 0) {
assert (trades[i].timestamp >= trades[i - 1].timestamp)
}
}
} else {
console.log (method + '() is not supported')
}
}