Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

tardis-dev saving historical funding, index and open interest data to CSV file

node v12.22.12
version: 1.0.0
endpointsharetweet
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')
Loading…

no comments

    sign in to comment