tardis-dev combining historical market data from multiple exchanges
const { replayNormalized, normalizeTrades, combine } = require('tardis-dev')
async function replayCombined() {
const bitmexMessages = replayNormalized(
{
exchange: 'bitmex',
symbols: ['XBTUSD'],
from: '2019-05-01',
to: '2019-05-02'
},
normalizeTrades
)
const deribitMessages = replayNormalized(
{
exchange: 'deribit',
symbols: ['BTC-PERPETUAL'],
from: '2019-05-01',
to: '2019-05-02'
},
normalizeTrades
)
const combinedStream = combine(bitmexMessages, deribitMessages)
// order at which messages have historically arrived is preserved
for await (const message of combinedStream) {
if (message.exchange === 'deribit') {
// process deribit trades
console.log(message)
}
if (message.exchange === 'bitmex') {
// process bitmex trades
console.log(message)
}
}
}
replayCombined()
no comments