{"record":{"id":"20e7579e20f536f3","repo":"nautechsystems/nautilus_trader","slug":"cannot-subscribe-for-synthetic-instrument-instrum-20e757","errorCode":null,"errorMessage":"Cannot subscribe for synthetic instrument `InstrumentClose` data","messagePattern":"Cannot subscribe for synthetic instrument `InstrumentClose` data","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/mod.rs","lineNumber":1102,"sourceCode":"            }\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\n        #[cfg(feature = \"streaming\")]\n        let cmd = self.subscribe_command_with_prefilled_start_ns(cmd)?;\n","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/mod.rs#L1084-L1120","documentation":"InstrumentClose data comes from venues at session close and cannot be produced for locally generated synthetic instruments. The engine rejects SubscribeCommand::InstrumentClose for any synthetic instrument ID with this error.","triggerScenarios":"Subscribing to InstrumentClose with an InstrumentId where is_synthetic() is true, typically via a loop subscribing to every data type for every instrument.","commonSituations":"Wide-net subscription utilities that cover all data types; porting real-market subscription configs to synthetic instrument strategies.","solutions":["Skip synthetic instrument IDs when subscribing to InstrumentClose data.","Use the supported synthetic streams (e.g. Trades) for synthetic instruments.","Restrict InstrumentClose subscriptions to real venue-listed instruments."],"exampleFix":"// before\nsubscribe_all(engine, synthetic_id); // includes InstrumentClose\n// after\nif !synthetic_id.is_synthetic() {\n    subscribe_all(engine, synthetic_id);\n}","handlingStrategy":"type-guard","validationCode":"// Rust\nfn can_subscribe_instrument_close(id: InstrumentId) -> bool { !id.is_synthetic() }","typeGuard":"// Rust\nfn is_venue_instrument(id: &InstrumentId) -> bool {\n    !id.is_synthetic()\n}","tryCatchPattern":"// Rust\nmatch engine.subscribe_instrument_close(id) {\n    Err(e) if e.to_string().contains(\"synthetic instrument `InstrumentClose`\") => Ok(()),\n    r => r,\n}","preventionTips":["Skip InstrumentClose subscriptions for synthetic IDs in bulk-subscribe helpers.","Document which data types are real-venue-only and enforce it centrally.","Prefer explicit per-type subscription lists over 'subscribe to everything' helpers."],"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-14T05:17:10.506Z"}