-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.fetchPositions.js
49 lines (37 loc) · 1.5 KB
/
test.fetchPositions.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
'use strict'
// ----------------------------------------------------------------------------
const assert = require ('assert')
, testPosition = require ('./test.position.js')
// ----------------------------------------------------------------------------
module.exports = async (exchange, symbol) => {
const method = 'fetchPositions'
const skippedExchanges = [
'bitmart',
'rightbtc',
]
if (skippedExchanges.includes (exchange.id)) {
console.log (exchange.id, 'found in ignored exchanges, skipping ' + method + '...')
return
}
if (exchange.has[method]) {
const now = Date.now ()
// without symbol
const positions = await exchange[method] ()
console.log ('fetched', positions.length, 'positions, asserting each...')
assert (positions instanceof Array)
for (let i = 0; i < positions.length; i++) {
const position = positions[i]
testPosition (exchange, position, undefined, now)
}
// with symbol
const positionsForSymbol = await exchange[method] ([ symbol ])
console.log ('fetched', positions.length, 'positions (' + symbol + '), asserting each...')
assert (positionsForSymbol instanceof Array)
for (let i = 0; i < positionsForSymbol.length; i++) {
const position = positionsForSymbol[i]
testPosition (exchange, position, symbol, now)
}
} else {
console.log (method + '() is not supported')
}
}