{"record":{"id":"094dcb4c15053384","repo":"nautechsystems/nautilus_trader","slug":"instrument-symbol-not-in-cache","errorCode":null,"errorMessage":"Instrument {symbol} not in cache","messagePattern":"Instrument (.+?) not in cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":2601,"sourceCode":"\n    /// Generates a timestamp for initialization.\n    fn generate_ts_init(&self) -> UnixNanos {\n        self.clock.get_time_ns()\n    }\n\n    fn command_validation_error(message: impl Into<String>) -> anyhow::Error {\n        anyhow::anyhow!(BinanceSpotHttpError::ValidationError(message.into()))\n    }\n\n    fn response_parse_error(message: impl Into<String>) -> anyhow::Error {\n        anyhow::anyhow!(BinanceSpotHttpError::ResponseParseError(message.into()))\n    }\n\n    /// Retrieves an instrument from the cache.\n    fn instrument_from_cache(&self, symbol: Ustr) -> anyhow::Result<InstrumentAny> {\n        self.instruments_cache\n            .get_cloned(&symbol)\n            .ok_or_else(|| anyhow::anyhow!(\"Instrument {symbol} not in cache\"))\n    }\n\n    /// Caches multiple instruments.\n    pub fn cache_instruments(&self, instruments: Vec<InstrumentAny>) {\n        self.instruments_cache.rcu(move |cache| {\n            for instrument in &instruments {\n                cache.insert(instrument.raw_symbol().inner(), instrument.clone());\n            }\n        });\n    }\n\n    /// Replaces the complete instrument cache.\n    pub fn replace_instruments(&self, instruments: &[InstrumentAny]) {\n        let cache = instruments\n            .iter()\n            .map(|instrument| (instrument.raw_symbol().inner(), instrument.clone()))\n            .collect();\n        self.instruments_cache.store(cache);","sourceCodeStart":2583,"sourceCodeEnd":2619,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L2583-L2619","documentation":"instrument_from_cache looks up the adapter-local instrument cache by Binance symbol; when absent it errors. The HTTP client needs the InstrumentAny to map prices/quantities to correct precision, so requests like trades/bars/cancel-replace fail without it.","triggerScenarios":"Requesting historical trades, bars, or issuing commands for a symbol that was never loaded — e.g. subscribing/requests made before instruments are initialized, or a symbol not part of the configured instrument provider.","commonSituations":"Strategy referencing symbols not in the configured load_all/load_ids filter; a race where data requests fire before instrument warm-up completes; typo in symbol casing (Binance symbols are uppercase, e.g. BTCUSDT).","solutions":["Include the symbol in InstrumentProviderConfig load_ids or set load_all=True","Ensure instruments are initialized (venue 'connect'/instrument provider load) before requesting data","Verify the exact Binance symbol string (uppercase, no separators)","Check for request races in your actor's on_start ordering"],"exampleFix":"// before\nconfig = BinanceDataClientConfig(...)  # no load_ids -> symbol missing\n# after\nconfig = BinanceDataClientConfig(instrument_provider=InstrumentProviderConfig(load_ids=[\"BINANCE.BTCUSDT\"]))","handlingStrategy":"validation","validationCode":"if client.get_instrument(&symbol).is_none() {\n    return Err(format!(\"symbol {symbol} not loaded; add to instrument provider load_ids\"));\n}","typeGuard":"fn instrument_loaded(cache: &Cache, symbol: Ustr) -> bool { cache.instrument(&InstrumentId::from(format!(\"{symbol}.BINANCE\"))).is_some() }","tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"not in cache\") => load_instruments_then_retry(), Err(e) => return Err(e), Ok(i) => Ok(i) }","preventionTips":["Configure InstrumentProviderConfig load_ids (or load_all) with every traded symbol","Gate data requests behind instrument initialization in on_start","Use exact uppercase Binance symbol strings"],"tags":["binance","cache","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-14T05:17:10.506Z"}