tardis-dev real-time funding rate and open interest across multiple exchanges

node v12.22.12
version: 1.0.0
endpointsharetweet
const { streamNormalized, normalizeDerivativeTickers, combine } = require('tardis-dev') const exchangesToStream = [ { exchange: 'bitmex', symbols: ['XBTUSD'] }, { exchange: 'deribit', symbols: ['BTC-PERPETUAL'] }, { exchange: 'cryptofacilities', symbols: ['PI_XBTUSD'] }, { exchange: 'okex', symbols: ['BTC-USD-SWAP'] }, { exchange: 'binance-futures', symbols: ['BTCUSDT'] }, { exchange: 'bitfinex-derivatives', symbols: ['BTCF0:USTF0'] } ] const realTimeStreams = exchangesToStream.map(e => { return streamNormalized(e, normalizeDerivativeTickers) }) // combine all real-time message streams into one const messages = combine(...realTimeStreams) const funding = {} // print funding info every 100ms setInterval(() => { console.clear() console.log(new Date().toISOString(), funding) }, 100) async function run() { // update funding info real-time for await (const message of messages) { if (message.type === 'derivative_ticker') { funding[message.exchange] = { symbol: message.symbol, fundingRate: message.fundingRate, lastPrice: message.lastPrice, openInterest: message.openInterest, markPrice: message.markPrice } } } } run()
Loading…

no comments

    sign in to comment