forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.marginModification.js
41 lines (37 loc) · 1.38 KB
/
test.marginModification.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');
function testMarginModification (exchange, marginModification) {
const format = {
info: {},
type: 'add',
amount: 0.1,
total: 0.29934828,
code: 'USDT',
symbol: 'ADA/USDT:USDT',
status: 'ok',
};
const keys = Object.keys(format);
for (let i = 0; i < keys.length; i++) {
assert (keys[i] in marginModification);
}
assert (typeof marginModification['info'] === 'object');
if (marginModification['type'] !== undefined) {
assert (marginModification['type'] === 'add' || marginModification['type'] === 'reduce' || marginModification['type'] === 'set');
}
if (marginModification['amount'] !== undefined) {
assert (typeof marginModification['amount'] === 'number');
}
if (marginModification['total'] !== undefined) {
assert (typeof marginModification['total'] === 'number');
}
if (marginModification['code'] !== undefined) {
assert (typeof marginModification['code'] === 'string');
}
if (marginModification['symbol'] !== undefined) {
assert (typeof marginModification['symbol'] === 'string');
}
if (marginModification['status'] !== undefined) {
assert (exchange.inArray (marginModification['status'], [ 'ok', 'pending', 'canceled', 'failed' ]));
}
}
module.exports = testMarginModification;