nautechsystems/nautilus_trader · error · anyhow::Error

Binance Spot L1_MBP supports depth 1 only

Error message

Binance Spot L1_MBP supports depth 1 only

What it means

Binance Spot L1_MBP (top-of-book) book-delta subscriptions map to the bookTicker stream, which has no depth dimension. Requesting BookType::L1_MBP together with an explicit depth other than 1 fails this validation; depth None or Some(1) is accepted.

Source

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

                "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 a4b06ed870)

Solutions

  1. For top-of-book, pass depth None (or Some(1)) with L1_MBP
  2. For deeper books, use L2_MBP with the desired depth (JSON mode maps explicit depths to partial-book streams)

Example fix

# before
client.subscribe_book_deltas(
    instrument_id,
    BookType.L1_MBP,
    depth=5,  # errors: L1 supports depth 1 only
)

# after
client.subscribe_book_deltas(
    instrument_id,
    BookType.L1_MBP,
    depth=None,  # top-of-book via bookTicker
)
Defensive patterns

Strategy: validation

Validate before calling

def valid_l1_request(book_type, depth) -> bool:
    return not (book_type == BookType.L1_MBP and depth is not None and depth != 1)

assert valid_l1_request(book_type, depth), "L1_MBP allows depth None or 1 only"

Type guard

def valid_l1_request(book_type, depth) -> bool:
    return not (book_type == BookType.L1_MBP and depth is not None and depth != 1)

Prevention

When it happens

Trigger: subscribe_book_deltas with book_type = L1_MBP and depth = Some(d) where d != 1 (e.g. 5, 10, 20).

Common situations: Venue-agnostic client code that always forwards a configured depth; porting configs from venues that permit L1 with depth; requesting depth 5 expecting a shallow book instead of the top of book.

Related errors


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