nautechsystems/nautilus_trader · error

Binance Spot L1_MBP supports depth 1 only

Error message

Binance Spot L1_MBP supports depth 1 only

What it means

When subscribing to L1_MBP (top-of-book) order book data on Binance Spot, an explicit depth other than 1 was requested. L1 book subscription maps to Binance's depth-1 partial book stream, so any depth parameter must be 1 or None.

Solutions

  1. Set depth to None or Depth(1) for L1_MBP subscriptions.
  2. If deeper book data is needed, subscribe with BookType::L2_MBP instead.
  3. Adjust the node/strategy config that builds the SubscribeBookDeltas command.

Example fix

// before
client.subscribe_book_deltas(sub_command(BookType::L1_MBP, Some(Depth::new(10))))?;
// after
client.subscribe_book_deltas(sub_command(BookType::L1_MBP, None))?; // or Some(Depth::new(1))
Defensive patterns

Strategy: validation

Validate before calling

fn validate_l1_depth(book_type: BookType, depth: Option<Depth>) -> Result<(), String> {
    if book_type == BookType::L1_MBP && depth.map_or(false, |d| d.get() != 1) {
        Err("L1_MBP supports depth 1 only".into())
    } else { Ok(()) }
}

Type guard

fn is_valid_l1_request(book_type: BookType, depth: Option<Depth>) -> bool {
    book_type != BookType::L1_MBP || 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") => {
        log::warn!("falling back to depth 1");
        let cmd = with_depth(cmd, None);
        client.subscribe_book_deltas(cmd)?;
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling subscribe_book_deltas with book_type L1_MBP and cmd.depth set to Some(5/10/20/...) on the Binance Spot data client.

Common situations: Reusing a subscription config written for L2 depth streams; shared strategy code requesting depth 10/20 while choosing L1 book type; copy-pasted subscription from a Futures/L2 setup.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/2b360970eed2a621. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/binance/src/spot/data.rs:1832

                "ticker subscription",
            );
        }
        Ok(())
    }

    fn subscribe_instruments(&mut self, _cmd: SubscribeInstruments) -> anyhow::Result<()> {
        log::debug!("subscribe_instruments: Binance instruments are fetched via HTTP on connect");
        Ok(())
    }

    fn subscribe_instrument(&mut self, _cmd: SubscribeInstrument) -> anyhow::Result<()> {
        log::debug!("subscribe_instrument: Binance 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 Spot 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 Spot 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 Spot supports L1_MBP and L2_MBP order book subscriptions");
        }
        anyhow::ensure!(

View on GitHub (pinned to 18893faf8b)