nautechsystems/nautilus_trader · error · anyhow::Error
Binance Futures L1_MBP supports depth 1 only
Error message
Binance Futures L1_MBP supports depth 1 only
What it means
For Binance Futures, L1_MBP (top-of-book) order book subscriptions must use depth exactly 1. The handler explicitly rejects any SubscribeBookDeltas with BookType::L1_MBP and a depth other than 1 (or missing-depth values that aren't 1), because the underlying book-ticker stream only provides best bid/ask.
Solutions
- Set depth to 1 (or leave None, which passes the is_none_or check) when subscribing L1_MBP on Binance Futures
- Use BookType::L2_MBP if you actually need deeper levels
- Adjust per-venue config so depth values are venue-appropriate
Example fix
// before
SubscribeBookDeltas { book_type: L1_MBP, depth: Some(10), .. }
// after
SubscribeBookDeltas { book_type: L1_MBP, depth: Some(1), .. } // or depth: None Defensive patterns
Strategy: validation
Validate before calling
fn valid_l1_depth(depth: Option<Depth>) -> bool {
depth.map_or(true, |d| d.get() == 1)
} Type guard
fn is_l1_depth_valid(cmd: &SubscribeBookDeltas) -> bool {
cmd.book_type != BookType::L1_MBP || cmd.depth.is_none_or(|d| d.get() == 1)
} Try / catch
match client.subscribe_book_deltas(cmd) {
Err(e) if e.to_string().contains("L1_MBP supports depth 1 only") => {
// downgrade: resubmit with depth 1
let cmd = SubscribeBookDeltas { depth: Some(Depth::new(1)?), ..cmd };
client.subscribe_book_deltas(cmd)?;
}
r => r?,
} Prevention
- Clamp depth to 1 whenever book_type is L1_MBP
- Keep per-venue book config tables instead of global depth defaults
- Document that L1 on Binance Futures maps to the book-ticker stream
When it happens
Trigger: Calling SubscribeBookDeltas with book_type L1_MBP and depth set to e.g. 5, 10, 20 on a Binance Futures instrument.
Common situations: Reusing generic strategy code that requests depth-10 L1 snapshots across venues; copying L2 depth settings into an L1 subscription; config-driven depth values not adapted per venue.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- invalid Binance Futures order-book depth
- Invalid depth for Binance Futures order book. Valid values
- invalid depth ; supported depths
- Binance Futures does not support second-level kline…
- Binance Spot order-book depth must be between 1 and 5000
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/8c7d0a0379a77443.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/futures/data.rs:1969
}
fn subscribe_instruments(&mut self, _cmd: SubscribeInstruments) -> anyhow::Result<()> {
log::debug!(
"subscribe_instruments: Binance Futures instruments are fetched via HTTP on connect"
);
Ok(())
}
fn subscribe_instrument(&mut self, _cmd: SubscribeInstrument) -> anyhow::Result<()> {
log::debug!(
"subscribe_instrument: Binance Futures instruments are fetched via HTTP on connect"
);
Ok(())
}
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {
if cmd.book_type == BookType::L1_MBP {
anyhow::ensure!(
cmd.depth.is_none_or(|depth| depth.get() == 1),
"Binance Futures L1_MBP supports depth 1 only"
);
anyhow::ensure!(
!self.book_subscriptions.contains_key(&cmd.instrument_id),
"cannot subscribe L1_MBP and L2_MBP for the same Binance Futures instrument"
);
self.l1_book_subscriptions.rcu(|subscriptions| {
*subscriptions.entry(cmd.instrument_id).or_insert(0) += 1;
});
self.subscribe_top_of_book(cmd.instrument_id);
return Ok(());
}
if cmd.book_type != BookType::L2_MBP {
anyhow::bail!("Binance Futures supports L1_MBP and L2_MBP order book subscriptions");
}
anyhow::ensure!(View on GitHub (pinned to 18893faf8b)