{"record":{"id":"d20231ac0e4e8ea0","repo":"nautechsystems/nautilus_trader","slug":"instrument-not-found-in-cache-instrument-id","errorCode":null,"errorMessage":"instrument not found in cache: {instrument_id}","messagePattern":"instrument not found in cache: (.+?)","errorType":"exception","errorClass":"InstrumentLookupError","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/data.rs","lineNumber":992,"sourceCode":"\n        Ok(())\n    }\n\n    fn subscribe_funding_rates(&mut self, cmd: SubscribeFundingRates) -> anyhow::Result<()> {\n        let ws = self.ws_client.clone();\n        let instrument_id = cmd.instrument_id;\n\n        self.spawn_task(\"subscribe_funding_rates\", async move {\n            ws.subscribe_funding_rates(instrument_id).await\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        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 ws = self.ws_client.clone();\n\n        self.spawn_task(\"subscribe_bars\", async move {\n            ws.subscribe_bars(bar_type).await\n        });\n\n        Ok(())\n    }\n\n    fn unsubscribe_instrument(&mut self, _cmd: &UnsubscribeInstrument) -> anyhow::Result<()> {\n        // `subscribe_instrument` only emits the cached instrument; it opens no\n        // venue channel, so there is nothing to tear down here.\n        Ok(())\n    }\n","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/data.rs#L974-L1010","documentation":"subscribe_bars looks up the instrument for the bar's instrument_id in the client's local instruments cache before registering the WebSocket candle subscription. If the instrument was never loaded into the cache (instruments not requested at startup, or an unknown/synthetic symbol), it raises an InstrumentLookupError::not_found instead of subscribing blindly.","triggerScenarios":"Calling subscribe_bars with a bar_type whose instrument_id is absent from self.instruments — e.g. subscribing to bars for an instrument not requested during instrument initialization, or a typo'd/synthetic instrument id.","commonSituations":"Strategies subscribing to bars on instruments that exist on other venues but not Hyperliquid; symbol format mismatches (wrong suffix/venue in the instrument id); skipping the instruments subscription at client start; replay data referencing stale instruments.","solutions":["Request/subscribe to the instrument (subscribe_instruments) or ensure the client loaded all Hyperliquid instruments before subscribing to bars.","Verify the instrument_id exactly matches a tradable Hyperliquid symbol including venue suffix.","Check for typos or stale instrument definitions in strategy config; reload instruments after listing changes."],"exampleFix":"// before\nself.data_engine.subscribe_bars(bar_type) // instrument never loaded\n// after\nself.data_engine.subscribe_instruments(); // ensure cache populated first\nself.data_engine.subscribe_bars(bar_type);","handlingStrategy":"validation","validationCode":"if !client.instrument_ids().contains(&bar_type.instrument_id()) {\n    return Err(format!(\"{} not loaded; subscribe instruments first\", bar_type.instrument_id()));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always subscribe to instruments before subscribing to bars.","Verify instrument_id spelling and venue suffix against cached instruments.","Refresh the instrument cache when Hyperliquid listings change."],"tags":["instrument-lookup","bars","cache","hyperliquid"],"backgroundTag":"resource-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"}