tardis-dev seamless switching between real-time streaming and historical market data replay
const {
replayNormalized,
streamNormalized,
normalizeTrades,
compute,
computeTradeBars
} = require('tardis-dev')
async function produceVolumeBasedTradeBars(messages) {
const withVolumeTradeBars = compute(
messages,
computeTradeBars({
kind: 'volume',
interval: 100 * 1000 // aggregate by 100k contracts volume
})
)
for await (const message of withVolumeTradeBars) {
if (message.type === 'trade_bar') {
console.log(message.name, message)
}
}
}
const historicalMessages = replayNormalized(
{ exchange: 'bitmex', symbols: ['XBTUSD'], from: '2019-08-01', to: '2019-08-02' },
normalizeTrades
)
const realTimeMessages = streamNormalized(
{ exchange: 'bitmex', symbols: ['XBTUSD'] },
normalizeTrades
)
produceVolumeBasedTradeBars(historicalMessages)
// or for real time data
// await produceVolumeBasedTradeBars(realTimeMessages)
no comments