coinbase-pro-node icon indicating copy to clipboard operation
coinbase-pro-node copied to clipboard

Proposal: Switch to level 2 book

Open fb55 opened this issue 9 years ago • 14 comments

We recently switched the website (https://www.gdax.com) to a level 2 book (only price levels, no specific orders). This vastly reduced the bandwidth requirements for clients and allows us to send the entire book when initially subscribing. It also means clients do not need to take care of potentially dropped messages on the full feed.

The goal of this issue is to get some feedback on whether this switch would be an option for this library as well. Most trading bots probably aren't interested in the exact orders — perhaps to get an idea of the execution order (as this is FIFO), but even that should be rare.

Please leave a comment if you have any concerns!

fb55 avatar Jul 26 '17 14:07 fb55

In my mind, ability to choose level (1-3) of sync order book would be the great feature.

dmalukov avatar Jul 27 '17 14:07 dmalukov

@pranksterN1 Level 3 books are way more complex than level 2 books. While I agree that this would be generally a nice feature, the goal of this to both improve the performance and reduce the complexity of this library.

Level 1 might be a nice future addition, but as the level 2 book already contains that information having that probably suffices.

fb55 avatar Aug 01 '17 14:08 fb55

Is this about the Orderbook Sync (Websocket feed)? If yes:

According to the API documentation, level 2 only returns the top 50 bids and asks. How is the client supposed to keep the full order book in sync, without knowing the state of the remaining bids and asks?

As far as I can tell from the docs, level 2 cannot be configured for the Websocket feed. (However, https://www.gdax.com does seem to provide a channels parameter though it is undocumented so I deem it unfit.)

It'd be great to use level 2, instead of level 3, to keep a synchronized full order book, but with the current API I'm unsure how.

b-zee avatar Aug 15 '17 23:08 b-zee

The website already retrieves full level 2 snapshots via the feed. We are currently finishing up the flow for subscribing to channels, as soon as that's done the docs will be updated accordingly.

fb55 avatar Aug 15 '17 23:08 fb55

@fb55, Do you have an approximate date for completing that work ?

dmalukov avatar Aug 21 '17 09:08 dmalukov

@pranksterN1 No exact date, but it shouldn't be much later than the first week of September.

fb55 avatar Aug 25 '17 18:08 fb55

We finally rolled this out yesterday. Docs are live at https://docs.gdax.com/#websocket-feed — this hasn't been officially announced yet (we will do so next week), but for now feel free to experiment with it.

The trading toolkit we published this week already uses the new channels and I'd like to switch this library to something similar.

fb55 avatar Sep 07 '17 21:09 fb55

@fb55, Thank you for your answers. I faced the problem with the new ws feed API. Could you clarify why the first message I received doesn't have side, time, trade_id, last_size fields? Or should I skip all messages until "subscriptions" message will be received?

ws messages [click here to expand]

request:

{  
   "type":"subscribe",
   "product_ids":[  
      "BTC-USD"
   ],
   "channels":[  
      "ticker"
   ]
}

received data:

{  
   "type":"ticker",
   "sequence":4077559280,
   "product_id":"BTC-USD",
   "price":"3595.00000000",
   "open_24h":"3869.02000000",
   "volume_24h":"16938.74579088",
   "low_24h":"3595.00000000",
   "high_24h":"3875.54000000",
   "volume_30d":"470252.79261935",
   "best_bid":"3592.84",
   "best_ask":"3595.04"
}
{  
   "type":"subscriptions",
   "channels":[  
      {  
         "name":"ticker",
         "product_ids":[  
            "BTC-USD"
         ]
      }
   ]
}
{  
   "type":"ticker",
   "sequence":4077560540,
   "product_id":"BTC-USD",
   "price":"3598.65000000",
   "open_24h":"3869.02000000",
   "volume_24h":"16938.74579365",
   "low_24h":"3598.65000000",
   "high_24h":"3875.54000000",
   "volume_30d":"470252.79262212",
   "best_bid":"3592.9",
   "best_ask":"3598.65",
   "side":"buy",
   "time":"2017-09-22T13:29:42.602000Z",
   "trade_id":21221450,
   "last_size":"0.00000277"
}

dmalukov avatar Sep 22 '17 14:09 dmalukov

The first message is intended to give you an instant impression of the current market conditions, analogous to the snapshot message you get when you subscribe to the level 2 channel. Definitely something we need to document.

fb55 avatar Sep 23 '17 17:09 fb55

Was this ever rolled out? I see in the orderbook_sync lib that there is a "bookLevel = 3" argument but changing it to level 2 results in assertion errors.

Arombalski avatar Dec 17 '17 18:12 Arombalski

Was this ever rolled out? I see in the orderbook_sync lib that there is a "bookLevel = 3" argument but changing it to level 2 results in assertion errors.

@Arombalski The main GDAX Websocket API added level 2 support to the websocket feed, but no, this has not been implemented in gdax-node yet. OrderbookSync still relies on level 3.

rmm5t avatar Dec 27 '17 18:12 rmm5t

Hi, I am using orderbookSync of gdax-node and I am facing same issue where orderbook data randomly becomes stale. Is there a timeline in gdax-node to integrate level2? Or if there is another way of keeping my orderbook updated (writing own logic to use level2 updates doesn't work either as mentioned above by few members)? Does gdax trading toolkit help with keeping orderbook in sync with level2 reliably?

adityamertia avatar Feb 07 '18 05:02 adityamertia

Hello, Is this done yet or planned for anytime soon?

adityamertia avatar Aug 16 '18 14:08 adityamertia

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

drewrothstein avatar Jan 16 '20 05:01 drewrothstein