coinbase / coinbase-pro-node

DEPRECATED — The official Node.js library for Coinbase Pro
Apache License 2.0
844 stars 316 forks source link

The `snapshot` event does not get emitted when subscribing to the `level2` channel. #312

Closed brianmcallister closed 4 years ago

brianmcallister commented 6 years ago

I'm basing this off of this section in the documentation: https://docs.gdax.com/#the-code-classprettyprintlevel2code-channel

When I open up a subscription using WebsocketClient, it looks like there's no snapshot event being emitted.

Here's what I'm doing (lots of real code omitted for clarity):

const Gdax = require('gdax');
const websocket = new Gdax.WebsocketClient(
  ['BTC-USD'],
  'wss://ws-feed-public.sandbox.gdax.com',
  null,
  { channels: ['ticker', 'level2'] },
);

websocket.on('message', (data) => {
  if (data.type === 'snapshot') {
    // do snapshoty stuff
  }
});

I did see in the README of this repo that an open event gets emitted by the client so I tried listening to that for a snapshot, but I haven't seen open ever be emitted.

Is the code I have here correct, or am I doing something wrong?

I am able to get the order books I care about from the REST API, but I'd prefer to just use the websocket client by itself.

Nulinf commented 5 years ago

I had the same issue but I think the idea is that the 'snapshot' event provides the initial conditions of the orderbook and the subsequent 'l2update' events are used to update the state of the orderbook.

brianmcallister commented 5 years ago

Yep, understood. The issue is that the snapshot event is never getting emitted.

avmarko commented 5 years ago

Having the same issue. Did you manage to find a solution to this?

drewrothstein commented 4 years ago

Hi, we are closing out PRs + Issues as this project is being archived.