nautechsystems/nautilus_trader · error

Deribit only supports L2_MBP order book depth

Error message

Deribit only supports L2_MBP order book depth

What it means

subscribe_book_depth10 rejects the request because the requested book type is not L2_MBP; Deribit's fixed depth-10 book channel only provides level-2 merged price levels.

Source

Thrown at crates/adapters/deribit/src/data.rs:963

            let result = if interval == Some(DeribitUpdateInterval::Raw) {
                ws.subscribe_book(instrument_id, interval).await
            } else {
                ws.subscribe_book_grouped(instrument_id, &group, depth, interval)
                    .await
            };

            if let Err(e) = result {
                log::error!("Failed to subscribe to book deltas for {instrument_id}: {e}");
            }
        });

        Ok(())
    }

    fn subscribe_book_depth10(&mut self, cmd: SubscribeBookDepth10) -> anyhow::Result<()> {
        if cmd.book_type != BookType::L2_MBP {
            anyhow::bail!("Deribit only supports L2_MBP order book depth");
        }

        let instrument_id = cmd.instrument_id;
        let needs_load = self.prepare_subscribe(instrument_id)?;

        let ws = self
            .ws_client
            .as_ref()
            .ok_or_else(|| anyhow::anyhow!("WebSocket client not initialized"))?
            .clone();
        let http_client = self.http_client.clone();
        let instruments = Arc::clone(&self.instruments);
        let interval = self.get_interval(&cmd.params);
        let group = cmd
            .params
            .as_ref()
            .and_then(|p| p.get_str("group"))
            .unwrap_or(DERIBIT_BOOK_DEFAULT_GROUP)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set book_type to BookType::L2_MBP on the depth10 subscription request
  2. Use subscribe_book_deltas/subscribe_book_depth10 only for L2 data on Deribit
  3. Validate book_type when constructing the command or client config

Example fix

// before
let cmd = SubscribeBookDepth10 { book_type: BookType::L3_MBP, .. };
// after
let cmd = SubscribeBookDepth10 { book_type: BookType::L2_MBP, .. };
Defensive patterns

Strategy: validation

Validate before calling

if cmd.book_type != BookType::L2_MBP {
    return Err(anyhow::anyhow!("Deribit depth10 requires BookType::L2_MBP"));
}

Type guard

fn is_l2(book_type: BookType) -> bool { matches!(book_type, BookType::L2_MBP) }

Try / catch

if let Err(e) = client.subscribe_book_depth10(cmd).await {
    if e.to_string().contains("L2_MBP") { cmd.book_type = BookType::L2_MBP; retry(); }
}

Prevention

When it happens

Trigger: Calling subscribe_book_depth10 with a SubscribeBookDepth10 command whose book_type is not BookType::L2_MBP.

Common situations: Generic strategy code that builds depth subscriptions with a venue-agnostic book_type; copying from Binance/Crypto.com style L3 examples; misconfigured DataEngine default book_type.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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