UNPKG

tardis-dev

Version:

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

34 lines 1.2 kB
import { RealTimeFeedBase } from "./realtimefeed.js"; export class DydxRealTimeFeed extends RealTimeFeedBase { wssURL = 'wss://api.dydx.exchange/v3/ws'; mapToSubscribeMessages(filters) { const subs = filters .map((filter) => { if (filter.channel === 'v3_markets') { return [ { type: 'subscribe', channel: 'v3_markets' } ]; } if (!filter.symbols || filter.symbols.length === 0) { throw new Error('DydxRealTimeFeed requires explicitly specified symbols when subscribing to live feed'); } return filter.symbols.map((symbol) => { return { type: 'subscribe', channel: filter.channel, id: symbol, includeOffsets: filter.channel === 'v3_orderbook' ? true : undefined }; }); }) .flatMap((f) => f); return subs; } messageIsError(message) { return message.type === 'error'; } } //# sourceMappingURL=dydx.js.map