nautechsystems/nautilus_trader · error

Polymarket only supports L2_MBP order book deltas, received

Error message

Polymarket only supports L2_MBP order book deltas, received {:?}

What it means

Polymarket's data adapter implements order books only as managed L2_MBP (market-by-price level-2) delta streams. Any request for order book deltas with a different BookType (e.g. L3_MBP) is rejected outright, since the upstream Polymarket feed cannot produce that granularity.

Source

Thrown at crates/adapters/polymarket/src/data/mod.rs:648

        );
        let changed = self.rtds_feed.track_subscribe(cmd.data_type)?;
        if !changed {
            return Ok(());
        }

        if !self.is_connected() {
            return Ok(());
        }

        self.rtds_feed
            .request_reconcile(crate::rtds::ReconcileReason::DesiredChanged);

        Ok(())
    }

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

        let instrument_id = cmd.instrument_id;
        self.ensure_live_subscription_allowed(instrument_id)?;
        let cached = self.instruments.load().contains_key(&instrument_id);

        if !cached && !self.config.auto_load_missing_instruments {
            anyhow::bail!(
                "Instrument {instrument_id} not found, and `auto_load_missing_instruments` is disabled"
            );
        }

        // Mark intent before routing so unsubscribe can race-safely clear it.
        if !self.add_delta_subscription_intent(instrument_id) {
            return Ok(());

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the subscription/order-book config so book_type is L2_MBP.
  2. If L3 data is required, use an adapter/venue that actually provides it.
  3. Validate the configured book type at strategy startup and fail fast with a clear message.

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!("Polymarket requires L2_MBP"));
}

Type guard

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

Prevention

When it happens

Trigger: Calling subscribe_book_deltas with a SubscribeBookDeltas command whose book_type is anything other than BookType::L2_MBP.

Common situations: Strategies configured with a global default book type of L3; copied strategy configs from other adapters (e.g. crypto venues) that support deeper book types; code that forwards a user-configured depth/book type without validation.

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