Skip to content

Fix Binance futures L2_BOOK stream name for the default 250ms interval - #1136

Merged
bmoscon merged 1 commit into
bmoscon:masterfrom
MMcollab-dotcom:fix-binance-futures-250ms-depth
Sep 26, 2026
Merged

bmoscon merged 1 commit into
bmoscon:masterfrom
MMcollab-dotcom:fix-binance-futures-250ms-depth

Conversation

@MMcollab-dotcom

Copy link
Copy Markdown
Contributor

Description of code - what bug does this fix / what feature does this add?

BinanceFutures and BinanceDelivery list '250ms' in valid_depth_intervals. With depth_interval='250ms', _stream_names() subscribes to <symbol>@depth@250ms. Binance accepts that subscription but never sends data on it, so L2_BOOK produces nothing and no error is raised.

250ms is Binance's default diff-depth speed on the futures endpoints, and it's served on the bare <symbol>@depth stream. This PR adds a default_depth_interval class attribute: '250ms' on BinanceFutures and BinanceDelivery, None on BinanceBase. _stream_names() leaves out the suffix when the configured interval equals it. Spot is unchanged; @1000ms and the bare stream both work there.

Live check on 2026-09-26, median gap between E of consecutive events:

Endpoint Stream Result
fstream /public btcusdt@depth 252 ms
fstream /public btcusdt@depth@250ms no message within 5 s
fstream /public btcusdt@depth@100ms 102 ms
fstream /public btcusdt@depth@500ms 502 ms
dstream btcusd_perp@depth ~265 ms
dstream btcusd_perp@depth@250ms no message within 6 s
stream.binance.com btcusdt@depth@1000ms 1000 ms

With this branch, a FeedHandler with BinanceFutures and BinanceDelivery at depth_interval='250ms' received L2_BOOK deltas every 252 ms and 260 ms (median over 12 s).

  • - Tested (live, see above)
  • - Changelog updated
  • - Tests run and pass (tests/unit: 68 passed; the new test fails on master for the two 250ms cases)
  • - Flake8 run and all errors/warnings resolved (ruff check passes on changed files; flake8 shows only existing E501/W391 in untouched lines)
  • - Contributors file updated (optional)

Binance Futures and Binance Delivery accept a subscription to
<symbol>@Depth@250ms but never send data on it. 250ms is the default
update speed and is served on the bare <symbol>@Depth stream, so
depth_interval='250ms' silently produced no L2_BOOK data.
@bmoscon
bmoscon merged commit d652d65 into bmoscon:master Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants