gateio / gatews

Gate Websocket V4 SDK
89 stars 35 forks source link

Order book WS feed version is way ahead (sometimes >30 seconds) of HTTP #51

Closed Programmierus closed 1 year ago

Programmierus commented 1 year ago

I am maintaining local order book and having problems to init it because even with delay of 30 seconds the version of order book I get from WS subscription is still newer than what I get from regular HTTP REST source, e.g.:

2023-01-16 13:35:10.173 - CWS - INFO - [Gate] Initialising new depth ZBC-USDT < Subscribed to WS Feed SLEEP OF >30 SECONDS 2023-01-16 13:35:41.213 - CWS - INFO - [Gate] [TRY 1] Got initial depth ZBC_USDT version 172136538 < https://api.gateio.ws/api/v4/spot/order_book?with_id=true&currency=ZBC_USDT&limit=1000 2023-01-16 13:35:41.214 - CWS - WARN - [Gate] Update for ZBC-USDT too new: 172136848-172136849 > 172136538 + 1 (+310)

First buffered WS feed update is still 310 versions newer than what I just got via HTTP

What am I missing?

revilwang commented 1 year ago

Try to lower your order book limit, set it to at most 100. 1000-level order book has a very long cache time. Plus, Websocket won't update order book change beyond 100 level.

Programmierus commented 1 year ago

Thank you very much for your prompt reply. This resolved my issue. Consider adding this info to docs :)