{"record":{"id":"dc7e59262ae4cb1a","repo":"nautechsystems/nautilus_trader","slug":"instrumentlookuperror-not-found-instrument-id","errorCode":null,"errorMessage":"InstrumentLookupError::not_found(instrument_id)","messagePattern":"InstrumentLookupError::not_found\\(instrument_id\\)","errorType":"exception","errorClass":"InstrumentLookupError","httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/data/mod.rs","lineNumber":663,"sourceCode":"            was_empty\n        };\n\n        if was_empty {\n            let ws = self.ws_client.clone();\n            self.spawn_command(async move {\n                if let Err(e) = ws.subscribe(CoinbaseWsChannel::Status, &[]).await {\n                    log::error!(\"Failed to subscribe to status channel: {e:?}\");\n                }\n            });\n        }\n        Ok(())\n    }\n\n    fn subscribe_bars(&mut self, subscription: SubscribeBars) -> anyhow::Result<()> {\n        let instrument_id = subscription.bar_type.instrument_id();\n\n        if !self.instruments.contains_key(&instrument_id) {\n            anyhow::bail!(InstrumentLookupError::not_found(instrument_id));\n        }\n\n        let bar_type = subscription.bar_type;\n        let subscribed_id = Self::product_id(instrument_id);\n        let wire_id = self.resolve_wire_product_id(subscribed_id);\n        if wire_id != subscribed_id {\n            self.ws_client\n                .register_subscription_alias(wire_id, subscribed_id);\n        }\n        let key = wire_id.to_string();\n\n        // Register on the original client so the bar type persists across clones\n        self.ws_client.register_bar_type(key.clone(), bar_type);\n\n        let mut ws = self.ws_client.clone();\n\n        self.spawn_command(async move {\n            ws.add_bar_type(key, bar_type).await;","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/data/mod.rs#L645-L681","documentation":"subscribe_bars requires the bar subscription's instrument to already exist in the client's local instruments cache. If subscription.bar_type.instrument_id() is not present, it fails with InstrumentLookupError::not_found, meaning the instrument must be loaded/added before bars can be subscribed.","triggerScenarios":"Subscribing to bars for an instrument_id that was never added via instrument provider loading (e.g. a typo'd symbol like 'BTC-USDT.PERP' when only 'BTC-USD' is loaded, or subscribing before connect loaded instruments).","commonSituations":"Config symbol mismatch with the loaded instrument provider; subscribing immediately after client construction without waiting for instrument load; requesting bars for a product Coinbase does not list.","solutions":["Load the instrument first (include it in the instrument provider config / call add_instrument) before subscribing to bars","Verify the instrument_id string matches a Coinbase product exactly (e.g. BTC-USD)","Ensure instruments are loaded during connect before any data subscriptions are issued","Check resolve_wire_product_id mapping if using mapped wire product IDs"],"exampleFix":"// before\nclient.subscribe_bars(bars_cmd)?; // instrument never loaded\n\n// after\nassert!(client.instruments().contains_key(&instrument_id));\nclient.subscribe_bars(bars_cmd)?;","handlingStrategy":"validation","validationCode":"if !client.instruments_cache_contains(&subscription.bar_type.instrument_id()) {\n    return Err(anyhow!(\"load instrument before subscribing to bars\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Load all instruments you intend to subscribe to during client construction/connect","Keep instrument_id strings exactly matching Coinbase product IDs (e.g. BTC-USD)","Subscribe to data only after connect() completes instrument loading","Validate bar_type.instrument_id() against the loaded instrument set in config parsing"],"tags":["instrument","lookup","bars","rust"],"backgroundTag":"record-not-found","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"}