-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.tradingFee.js
34 lines (29 loc) · 1.17 KB
/
test.tradingFee.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
'use strict'
// ----------------------------------------------------------------------------
const assert = require ('assert')
// ---------------------------------------------------------------------------
function testTradingFee (symbol, fee) {
assert (fee, 'fee is undefined')
const sampleFee = {
'info': { 'a': 1, 'b': 2, 'c': 3 },
'symbol': 'ETH/BTC',
'maker': 0.002,
'taker': 0.003,
}
const keys = Object.keys (sampleFee)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
assert (key in fee, 'fee key ' + key + ' not found')
}
assert (fee['symbol'] === symbol, 'trade symbol is not equal to requested symbol: trade: ' + fee['symbol'] + ' requested: ' + symbol)
assert (typeof fee['maker'] === 'number', 'maker fee is not a number')
assert (typeof fee['taker'] === 'number', 'taker fee is not a number')
if ('percentage' in fee) {
assert (typeof fee['percentage'] === 'boolean', 'percentage is not a boolean')
}
if ('tierBased' in fee) {
assert (typeof fee['tierBased'] === 'boolean', 'percentage is not a boolean')
}
return fee
}
module.exports = testTradingFee