UNPKG

tardis-dev

Version:

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

41 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DydxRealTimeFeed = void 0; const realtimefeed_1 = require("./realtimefeed"); class DydxRealTimeFeed extends realtimefeed_1.RealTimeFeedBase { constructor() { super(...arguments); this.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'; } } exports.DydxRealTimeFeed = DydxRealTimeFeed; //# sourceMappingURL=dydx.js.map