forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.leverageTier.js
43 lines (40 loc) · 1.44 KB
/
test.leverageTier.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
'use strict';
const assert = require ('assert');
function testLeverageTier (exchange, method, tier) {
const format = {
'tier': 1,
'minNotional': 0,
'maxNotional': 5000,
'maintenanceMarginRate': 0.01,
'maxLeverage': 25,
'info': {},
};
const keys = Object.keys (format);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
assert (key in tier, exchange.id + ' ' + method + ' ' + key + ' missing from response');
}
if (tier['tier'] !== undefined) {
assert (typeof tier['tier'] === 'number');
assert (tier['tier'] >= 0);
}
if (tier['minNotional'] !== undefined) {
assert (typeof tier['minNotional'] === 'number');
assert (tier['minNotional'] >= 0);
}
if (tier['maxNotional'] !== undefined) {
assert (typeof tier['maxNotional'] === 'number');
assert (tier['maxNotional'] >= 0);
}
if (tier['maxLeverage'] !== undefined) {
assert (typeof tier['maxLeverage'] === 'number');
assert (tier['maxLeverage'] >= 1);
}
if (tier['maintenanceMarginRate'] !== undefined) {
assert (typeof tier['maintenanceMarginRate'] === 'number');
assert (tier['maintenanceMarginRate'] <= 1);
}
console.log (exchange.id, method, tier['tier'], tier['minNotional'], tier['maxNotional'], tier['maintenanceMarginRate'], tier['maxLeverage']);
return tier;
}
module.exports = testLeverageTier;