跳到主要内容

How to Manage a Local Order Book

Because Sparky has no sequence-numbered diff stream, keeping a local book is simpler than on Binance — and less flexible.

  1. Subscribe to orderbook:<symbol>. The first message is a full snapshot (top 30 levels per side).
  2. Replace your local book with every subsequent orderbook message; do not try to merge. Messages arrive at most every 500 ms while the book changes.
  3. If you need more than 30 levels, poll GET /fapi/v1/depth?limit=… — but note its lastUpdateId is a timestamp, not a sequence number, so there is nothing to reconcile against the stream.
  4. Use the timestamp field only for staleness detection (e.g. reconnect if no update for several seconds during active trading).

A per-level diff stream with U / u sequence ids is on the roadmap; track the Changelog.