{"record":{"id":"353bdc0b95e6375b","repo":"nautechsystems/nautilus_trader","slug":"polymarket-only-supports-l2-mbp-order-book-deltas","errorCode":null,"errorMessage":"Polymarket only supports L2_MBP order book deltas, received {:?}","messagePattern":"Polymarket only supports L2_MBP order book deltas, received (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/data/mod.rs","lineNumber":648,"sourceCode":"        );\n        let changed = self.rtds_feed.track_subscribe(cmd.data_type)?;\n        if !changed {\n            return Ok(());\n        }\n\n        if !self.is_connected() {\n            return Ok(());\n        }\n\n        self.rtds_feed\n            .request_reconcile(crate::rtds::ReconcileReason::DesiredChanged);\n\n        Ok(())\n    }\n\n    fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {\n        if cmd.book_type != BookType::L2_MBP {\n            anyhow::bail!(\n                \"Polymarket only supports L2_MBP order book deltas, received {:?}\",\n                cmd.book_type\n            );\n        }\n\n        let instrument_id = cmd.instrument_id;\n        self.ensure_live_subscription_allowed(instrument_id)?;\n        let cached = self.instruments.load().contains_key(&instrument_id);\n\n        if !cached && !self.config.auto_load_missing_instruments {\n            anyhow::bail!(\n                \"Instrument {instrument_id} not found, and `auto_load_missing_instruments` is disabled\"\n            );\n        }\n\n        // Mark intent before routing so unsubscribe can race-safely clear it.\n        if !self.add_delta_subscription_intent(instrument_id) {\n            return Ok(());","sourceCodeStart":630,"sourceCodeEnd":666,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/data/mod.rs#L630-L666","documentation":"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.","triggerScenarios":"Calling subscribe_book_deltas with a SubscribeBookDeltas command whose book_type is anything other than BookType::L2_MBP.","commonSituations":"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.","solutions":["Change the subscription/order-book config so book_type is L2_MBP.","If L3 data is required, use an adapter/venue that actually provides it.","Validate the configured book type at strategy startup and fail fast with a clear message."],"exampleFix":"// before\nlet cmd = SubscribeBookDeltas { book_type: BookType::L3_MBP, .. };\n\n// after\nlet cmd = SubscribeBookDeltas { book_type: BookType::L2_MBP, .. };","handlingStrategy":"validation","validationCode":"if cmd.book_type != BookType::L2_MBP {\n    return Err(anyhow::anyhow!(\"Polymarket requires L2_MBP\"));\n}","typeGuard":"fn is_l2(book_type: BookType) -> bool { matches!(book_type, BookType::L2_MBP) }","tryCatchPattern":null,"preventionTips":["Set book_type: L2_MBP for all Polymarket data subscriptions.","Validate book type per venue in shared subscription helpers."],"tags":["polymarket","order-book","unsupported","book-type"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}