nautechsystems/nautilus_trader · error

Deribit only supports L2_MBP order book deltas

Error message

Deribit only supports L2_MBP order book deltas

What it means

subscribe_book_deltas rejects the subscription because the requested book type is not L2_MBP; Deribit's order book channel only exposes merged/level-2 data, so L1 or L3 book types cannot be served.

Source

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

            .clone();

        log::debug!(
            "Subscribing to instrument state for {instrument_id} (channel: {kind}.{currency})"
        );

        // Subscribe to broader kind/currency channel (filter in handler)
        self.spawn_command(async move {
            if let Err(e) = ws.subscribe_instrument_status(&kind, &currency).await {
                log::error!("Failed to subscribe to instrument status for {instrument_id}: {e}");
            }
        });

        Ok(())
    }

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

        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 depth = cmd
            .depth
            .map(|d| d.get() as u32)
            .or_else(|| {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set book_type to BookType::L2_MBP on the subscription request
  2. If L3 granularity is required, use a venue that supports it; Deribit cannot serve it
  3. Validate book_type at config/command-construction time before submitting the subscription

Example fix

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

Strategy: validation

Validate before calling

if cmd.book_type != BookType::L2_MBP {
    return Err(anyhow::anyhow!("Deribit 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_deltas(cmd).await {
    if e.to_string().contains("L2_MBP") { switch_venue_or_downgrade_book_type(); }
}

Prevention

When it happens

Trigger: Calling subscribe_book_deltas with a SubscribeBookDeltas command whose book_type is anything other than BookType::L2_MBP (e.g. L3_MBP).

Common situations: Reusing a generic subscription builder configured for L3 venues; copying subscription code from a different adapter that supports L3; defaulting book_type incorrectly when constructing data commands programmatically.

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/dbbbaf07bc5eaee4. Report an issue: GitHub.