Using Binance WebSocket Streams for Market Data and Local Order Books
Summary
This reference describes Binance spot market WebSocket streams for trades, aggregated trades, candles, ticker statistics, best bid and ask quotes, and order book updates. It explains raw and combined stream formats, subscription controls, timestamps, update frequencies, connection limits, and the need to reconnect when a session expires or the server announces shutdown. The examples show what fields each event supplies, including trade price and quantity, candle OHLCV data, and top-of-book prices and sizes.
For local order book construction, the document outlines a synchronization procedure: buffer depth events, obtain a REST snapshot, discard events already covered by the snapshot, then apply subsequent updates in sequence. Gaps in update identifiers require rebuilding the local book. Snapshot depth is limited, so unchanged price levels beyond the snapshot may remain unknown. This is primarily an interface and data-handling reference, not a trading strategy; it describes exchange-specific behavior and does not establish that a feed is complete or suitable for every execution system.
Key ideas
- WebSocket streams provide real-time trades, candles, ticker data, and order book updates.
- Combined streams wrap each event with its stream name, while raw streams deliver the event directly.
- A local order book must be synchronized to a REST snapshot and kept aligned using update identifiers.
- Missed updates require resynchronization, and snapshot depth limits visibility into unchanged price levels.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.