tardis-dev computing order book snapshots and custom trade bars
const { streamNormalized, normalizeTrades, normalizeBookChanges,
compute, computeTradeBars, computeBookSnapshots } = require('tardis-dev')
const bitmexMessages = streamNormalized(
{
exchange: 'bitmex',
symbols: ['XBTUSD']
},
normalizeTrades,
normalizeBookChanges
)
const messagesWithComputedTypes = compute(
bitmexMessages,
// 10 seconds time bars
computeTradeBars({ kind: 'time', interval: 10 * 1000 }),
// top 20 levels 50 millisecond order book snapshots
computeBookSnapshots({ depth: 20, interval: 50 }),
// volume based trade bar - 1 million vol buckets
computeTradeBars({ kind: 'volume', interval: 1000 * 1000 })
)
async function run() {
for await (const message of messagesWithComputedTypes) {
if (message.type === 'book_snapshot' || message.type === 'trade_bar') {
console.log(message)
}
}
}
await run()
no comments