tardis-dev saving historical funding, index and open interest data to CSV file
const { replayNormalized, normalizeDerivativeTickers } = require('tardis-dev')
const fs = require('fs')
const csv = require('fast-csv')
const fileStream = fs.createWriteStream('./deribit_funding.csv')
const csvStream = csv.format({ headers: true })
csvStream.pipe(fileStream)
const messages = replayNormalized(
{
exchange: 'deribit',
from: '2019-04-01',
to: '2019-04-02',
symbols: ['BTC-PERPETUAL']
},
normalizeDerivativeTickers
)
async function write() {
for await (const message of messages) {
if (message.type === 'derivative_ticker') {
csvStream.write({
fundingRate: message.fundingRate,
lastPrice: message.lastPrice,
openInterest: message.openInterest,
indexPrice: message.indexPrice,
timestamp: message.timestamp.toISOString()
})
}
}
}
await write()
console.log('done')
no comments