UNPKG

tardis-dev

Version:

Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js

33 lines 1.11 kB
import { RealTimeFeedBase } from "./realtimefeed.js"; export class DydxV4RealTimeFeed extends RealTimeFeedBase { wssURL = 'wss://indexer.dydx.trade/v4/ws'; mapToSubscribeMessages(filters) { const subs = filters .map((filter) => { if (filter.channel === 'v4_markets') { return [ { type: 'subscribe', channel: 'v4_markets' } ]; } if (!filter.symbols || filter.symbols.length === 0) { throw new Error('DydxV4RealTimeFeed requires explicitly specified symbols when subscribing to live feed'); } return filter.symbols.map((symbol) => { return { type: 'subscribe', channel: filter.channel, id: symbol }; }); }) .flatMap((f) => f); return subs; } messageIsError(message) { return message.type === 'error'; } } //# sourceMappingURL=dydx_v4.js.map