Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
feat: Add ticker_1000 WebSocket channel (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoelr committed Jan 3, 2022
1 parent 6adf233 commit 6c79874
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client/WebSocketClient.test.ts
Expand Up @@ -205,6 +205,22 @@ describe('WebSocketClient', () => {
ws.connect();
});

it('receives typed "ticker" messages from the special "ticker_1000" channel', done => {
const channel = {
name: WebSocketChannelName.TICKER_1000,
product_ids: ['BTC-USD'],
};

const ws = mockWebSocketResponse(done, channel, tickerBTCUSD);

ws.on(WebSocketEvent.ON_MESSAGE_TICKER, tickerMessage => {
expect(tickerMessage.trade_id).toBe(3526965);
ws.unsubscribe(channel);
});

ws.connect();
});

it('receives typed messages from multiple "matches" channels', done => {
const channels = [
{
Expand Down
2 changes: 2 additions & 0 deletions src/client/WebSocketClient.ts
Expand Up @@ -22,6 +22,8 @@ export enum WebSocketChannelName {
STATUS = 'status',
/** The ticker channel provides real-time price updates every time a match happens. It batches updates in case of cascading matches, greatly reducing bandwidth requirements. */
TICKER = 'ticker',
/** A special version of the ticker channel that only provides a ticker update about every 5 seconds. */
TICKER_1000 = 'ticker_1000',
/** This channel is a version of the full channel that only contains messages that include the authenticated user. Consequently, you need to be authenticated to receive any messages. */
USER = 'user',
}
Expand Down

0 comments on commit 6c79874

Please sign in to comment.