{"record":{"id":"45e878768e509e7a","repo":"nautechsystems/nautilus_trader","slug":"instrument-symbol-not-found-in-cache-ensure-ins-45e878","errorCode":null,"errorMessage":"Instrument {symbol} not found in cache, ensure instruments loaded first","messagePattern":"Instrument (.+?) not found in cache, ensure instruments loaded first","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":1793,"sourceCode":"    }\n\n    /// Any existing instruments with the same symbols will be replaced.\n    pub fn cache_instruments(&self, instruments: &[InstrumentAny]) {\n        self.instruments_cache.rcu(|m| {\n            for instrument in instruments {\n                m.insert(instrument.symbol().inner(), instrument.clone());\n            }\n        });\n        self.cache_initialized.store(true, Ordering::Release);\n    }\n\n    pub fn get_instrument(&self, symbol: &Ustr) -> Option<InstrumentAny> {\n        self.instruments_cache.get_cloned(symbol)\n    }\n\n    fn instrument_from_cache(&self, symbol: &Symbol) -> anyhow::Result<InstrumentAny> {\n        self.get_instrument(&symbol.inner()).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Instrument {symbol} not found in cache, ensure instruments loaded first\"\n            )\n        })\n    }\n\n    #[must_use]\n    fn generate_ts_init(&self) -> UnixNanos {\n        self.clock.get_time_ns()\n    }\n\n    /// Fetches the current server time from Bybit.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - The request fails.\n    /// - The response cannot be parsed.\n    ///","sourceCodeStart":1775,"sourceCodeEnd":1811,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L1775-L1811","documentation":"BybitBybitHttpClient.instrument_from_cache() looks up an instrument in the client's local instruments_cache (populated during instrument loading) and finds none for the given symbol. Since order placement/signing helpers need instrument specs (precision, lot size), the client refuses to proceed rather than guess. It is a fail-fast cache miss, not a network error.","triggerScenarios":"Calling order-related HTTP helpers (e.g. batch place order, query order) for a symbol whose instrument was never loaded into the client's instrument cache; loading instruments for a subset of product types and trading a symbol from another; symbol spelling/format mismatch (e.g. wrong case or missing suffix) so the cache key never matches.","commonSituations":"Starting a live/trading node with a filtered instrument provider that excludes the traded symbol; submitting orders for a newly listed instrument before instrument loading ran; typos in instrument IDs in strategy config.","solutions":["Ensure instruments are loaded before trading: include the symbol in your instrument provider filter (e.g. InstrumentProviderConfig with load_all or the specific symbols)","Call the client's instrument-loading endpoint for the relevant product type before placing orders","Verify the symbol string exactly matches the Bybit instrument name (e.g. BTCUSDT, BTC-28JUN24)","Check which product type the client was configured with; the symbol must belong to that product type's instrument set"],"exampleFix":"// before\nlet client = BybitHttpClient::new(...); // instruments not loaded\nclient.batch_place_orders(orders)?;\n// after\nclient.load_instruments_all(product_types).await?; // populate instruments_cache\nclient.batch_place_orders(orders)?;","handlingStrategy":"validation","validationCode":"let cached = client.get_instrument(&instrument_id.symbol.inner());\nif cached.is_none() {\n    client.load_instruments_all(product_types).await?; // populate cache before trading\n}","typeGuard":"if client.get_instrument(&symbol.inner()).is_none() {\n    return Err(format!(\"instrument {symbol} not loaded\"));\n}","tryCatchPattern":"match client.instrument_from_cache(&symbol) {\n    Ok(instr) => proceed(instr),\n    Err(e) => {\n        client.load_instruments_all(product_types).await?;\n        proceed(client.instrument_from_cache(&symbol)?);\n    }\n}","preventionTips":["Load all needed instruments at node startup and verify counts in logs","Keep instrument provider filters in sync with traded symbols","Validate strategy instrument IDs against loaded instruments before submitting orders"],"tags":["rust","cache","bybit","instrument"],"backgroundTag":"entity-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"}