-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.fetchFundingRateHistory.js
41 lines (31 loc) · 1.17 KB
/
test.fetchFundingRateHistory.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')
// ----------------------------------------------------------------------------
module.exports = async (exchange) => {
const method = 'fetchFundingRateHistory'
const format = {
'currency': 'USDT',
'info': {}, // Or []
'timestamp': 1638230400000,
'datetime': '2021-11-30T00:00:00.000Z',
'rate': 0.0006,
}
if (exchange.has[method]) {
const fundingRates = await exchange[method] ()
console.log ('fetched all', fundingRates.length, 'funding rates')
for (let i = 0; i < fundingRates.length; i++) {
const fundingRate = fundingRates[i]
const keys = Object.keys (format)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
assert (key in fundingRate)
}
assert (fundingRate['rate'] >= 0)
assert (fundingRate['timestamp'] >= 1199145600000) // 2008-01-01 00:00:00
}
return fundingRates
} else {
console.log (method + '() is not supported')
}
}