{"record":{"id":"10dd21506866e67e","repo":"nautechsystems/nautilus_trader","slug":"cannot-subscribe-for-synthetic-instrument-instrum-10dd21","errorCode":null,"errorMessage":"Cannot subscribe for synthetic instrument `InstrumentStatus` data","messagePattern":"Cannot subscribe for synthetic instrument `InstrumentStatus` data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/mod.rs","lineNumber":1099,"sourceCode":"            SubscribeCommand::Quotes(cmd) if cmd.instrument_id.is_synthetic() => {\n                self.subscribe_synthetic_quotes(cmd.instrument_id);\n                return Ok(());\n            }\n            SubscribeCommand::Quotes(cmd)\n                if self.is_spread_quote_command(cmd.instrument_id, cmd.params.as_ref()) =>\n            {\n                self.subscribe_spread_quotes(cmd);\n                return Ok(());\n            }\n            SubscribeCommand::Trades(cmd) if cmd.instrument_id.is_synthetic() => {\n                self.subscribe_synthetic_trades(cmd.instrument_id);\n                return Ok(());\n            }\n            SubscribeCommand::Instrument(cmd) if cmd.instrument_id.is_synthetic() => {\n                anyhow::bail!(\"Cannot subscribe for synthetic instrument `Instrument` data\");\n            }\n            SubscribeCommand::InstrumentStatus(cmd) if cmd.instrument_id.is_synthetic() => {\n                anyhow::bail!(\"Cannot subscribe for synthetic instrument `InstrumentStatus` data\");\n            }\n            SubscribeCommand::InstrumentClose(cmd) if cmd.instrument_id.is_synthetic() => {\n                anyhow::bail!(\"Cannot subscribe for synthetic instrument `InstrumentClose` data\");\n            }\n            SubscribeCommand::OptionGreeks(cmd) if cmd.instrument_id.is_synthetic() => {\n                anyhow::bail!(\"Cannot subscribe for synthetic instrument `OptionGreeks` data\");\n            }\n            _ => {} // Do nothing else\n        }\n\n        let retained = cmd.clone();\n\n        // Book ownership, including failed acquisitions, is already counted by the engine\n        let retain_on_failure = !matches!(\n            &cmd,\n            SubscribeCommand::BookDeltas(_) | SubscribeCommand::BookDepth10(_)\n        );\n","sourceCodeStart":1081,"sourceCodeEnd":1117,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/mod.rs#L1081-L1117","documentation":"InstrumentStatus data is venue-reported and has no meaning for synthetic instruments, which are generated locally. When a SubscribeCommand for InstrumentStatus targets a synthetic instrument ID, the engine bails immediately rather than forwarding an impossible command to a client.","triggerScenarios":"Subscribing to InstrumentStatus with an InstrumentId where is_synthetic() is true — e.g. blanket status subscriptions applied to all instrument IDs including synthetic ones.","commonSituations":"Generic subscription loops over a catalog that mixes real and synthetic instruments; strategy code copied from a real-instrument setup and retargeted at synthetic IDs.","solutions":["Exclude synthetic instrument IDs from InstrumentStatus subscriptions (skip ids where is_synthetic() is true).","Subscribe to a supported synthetic stream (e.g. synthetic Trades) instead if generated data is needed.","Only issue InstrumentStatus subscriptions for instruments that exist on a real venue."],"exampleFix":"// before\nengine.subscribe_instrument_status(synthetic_id)?;\n// after\nif !synthetic_id.is_synthetic() {\n    engine.subscribe_instrument_status(synthetic_id)?;\n}","handlingStrategy":"type-guard","validationCode":"// Rust\nif !instrument_id.is_synthetic() {\n    engine.subscribe_instrument_status(instrument_id)?;\n}","typeGuard":"// Rust\nfn supports_instrument_status(id: &InstrumentId) -> bool {\n    !id.is_synthetic()\n}","tryCatchPattern":"// Rust\nif let Err(e) = engine.subscribe_instrument_status(id) {\n    if e.to_string().contains(\"synthetic instrument `InstrumentStatus`\") {\n        log::warn!(\"InstrumentStatus unavailable for synthetic {id}\");\n    } else {\n        return Err(e.into());\n    }\n}","preventionTips":["Never issue venue-derived data (status/close) subscriptions for synthetic IDs.","Apply an is_synthetic() filter at the single helper that issues all subscriptions.","Audit mixed instrument catalogs before bulk subscribing."],"tags":["rust","data-engine","synthetic-instrument","subscription"],"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"}