bmoscon / cryptofeed

Cryptocurrency Exchange Websocket Data Feed Handler
Other
2.14k stars 668 forks source link

Fix L3_BOOK feed for Coinbase Pro/Exchange by supporting Modify Order Request (MOR) change messages #923

Open zahnz opened 1 year ago

zahnz commented 1 year ago

Describe the bug The Coinbase implementation in exchanges/coinbase.py does not support Modify Order Requests (MORs), which were put into production by Coinbase as of 2021-Oct-04 (see the announcement at https://docs.cloud.coinbase.com/exchange/docs/changelog#2022-oct-04). This has caused critical issues in maintaining an L3 book.

To Reproduce Steps to reproduce the behavior:

  1. Run cryptofeed capturing L3_BOOK for Coinbase
  2. Eventually, a KeyError order in self.l3_book in exchanges/coinbase.py will occur, as a trade or done message has been received which references a price level which has been added to the order book by an MOR change message which we did not process.

Expected behavior It's expected to support this feature. The problem in question is with this line, https://github.com/bmoscon/cryptofeed/blob/master/cryptofeed/exchanges/coinbase.py#L312, which should also check for and handle cases in which the change message has the keys new_price and old_price, and handle them properly wrt the self.l3_book update.

Cryptofeed Version Latest from pypi