tardis-dev
Version:
Convenient access to tick-level historical and real-time cryptocurrency market data via Node.js
36 lines • 1.27 kB
JavaScript
import { RealTimeFeedBase } from "./realtimefeed.js";
export class BitflyerRealTimeFeed extends RealTimeFeedBase {
wssURL = 'wss://ws.lightstream.bitflyer.com/json-rpc';
mapToSubscribeMessages(filters) {
return filters
.map((filter) => {
if (!filter.symbols || filter.symbols.length === 0) {
throw new Error('BitflyerRealTimeFeed requires explicitly specified symbols when subscribing to live feed');
}
return filter.symbols.map((symbol) => {
return {
method: 'subscribe',
params: {
channel: `${filter.channel}_${symbol}`
}
};
});
})
.flatMap((c) => c);
}
messageIsError(message) {
return message.method !== 'channelMessage';
}
onMessage = (msg) => {
// once we've received book snapshot, let's unsubscribe from it
if (msg.params.channel.startsWith('lightning_board_snapshot')) {
this.send({
method: 'unsubscribe',
params: {
channel: msg.params.channel
}
});
}
};
}
//# sourceMappingURL=bitflyer.js.map