What you will accomplish
- Subscribe to a live symbol
- Parse bid and ask depth separately
- Enforce message and freshness limits
- Reconnect without using stale state
Before you begin
- A WebSocket client
- An active symbol from exchange information
- A logging and reconnect strategy
Connect to the documented public stream
Use wss://app.quote.trade/ws/liquidity. A public liquidity subscription does not require account credentials.
Subscribe with the documented request
Send symbol and unsubscribe=0. Keep the requested symbol in your local subscription state.
{"symbol":"BTC","unsubscribe":0}Parse without binary floating-point assumptions
The documentation example uses p and q fields. Preserve them as strings or convert with a decimal library before calculating spreads or VWAP.
Implement heartbeat, reconnect, and resubscribe
Use a bounded exponential backoff with jitter, cap retries, and resubscribe only after the socket is open. Record receive time. Do not infer sequence guarantees that the docs do not state.
Unsubscribe cleanly and reload state
Send unsubscribe=1 before planned shutdown. After reconnect, retrieve a fresh REST depth snapshot instead of assuming no data was missed.
{"symbol":"BTC","unsubscribe":1}Common problems and fixes
The socket closes after rapid subscriptions
Throttle ping, pong, subscribe, and unsubscribe control messages below the documented limit.
The book appears crossed or stale
Validate receive times and sequence/update fields, discard invalid state, and request a fresh stream.
No messages arrive
Confirm the symbol is active and the subscription JSON matches the current documentation.