{"record":{"id":"66dfef6f3fdaff83","repo":"nautechsystems/nautilus_trader","slug":"instrument-symbol-not-found-in-cache","errorCode":null,"errorMessage":"Instrument {symbol} not found in cache","messagePattern":"Instrument (.+?) not found in cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":1520,"sourceCode":"    }\n\n    /// Requests an order book snapshot from Ax and builds a Nautilus [`OrderBook`].\n    ///\n    /// Requires the instrument to be cached.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - The instrument is not found in the cache.\n    /// - The HTTP request fails.\n    pub async fn request_book_snapshot(\n        &self,\n        symbol: Ustr,\n        depth: Option<usize>,\n    ) -> anyhow::Result<OrderBook> {\n        let instrument = self\n            .get_instrument(&symbol)\n            .ok_or_else(|| anyhow::anyhow!(\"Instrument {symbol} not found in cache\"))?;\n\n        let resp = self\n            .inner\n            .get_book(symbol, Some(2))\n            .await\n            .map_err(|e| anyhow::anyhow!(e))?;\n\n        let instrument_id = instrument.id();\n        let mut book = OrderBook::new(instrument_id, BookType::L2_MBP);\n\n        let price_precision = instrument.price_precision();\n        let size_precision = instrument.size_precision();\n        let ts_event = ax_timestamp_stn_to_unix_nanos(resp.book.ts, resp.book.tn)?;\n\n        for (i, level) in resp.book.b.iter().enumerate() {\n            if depth.is_some_and(|d| i >= d) {\n                break;\n            }","sourceCodeStart":1502,"sourceCodeEnd":1538,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L1502-L1538","documentation":"`request_order_book` (book snapshot via `get_book`) requires the target instrument to already exist in the client's local instrument cache; `get_instrument(&symbol)` returning None raises \"Instrument {symbol} not found in cache\". The adapter refuses to build an order book for a symbol it has no parsed instrument definition for.","triggerScenarios":"Calling `request_order_book(symbol, depth)` before the instrument provider has been loaded/initialized, or with a symbol string that doesn't exactly match a cached AX instrument (case/format mismatch, delisted instrument).","commonSituations":"Subscribing to order book data before `initialize()` loaded instruments; using an exchange-native symbol variant that differs from the cached Ustr; stale cache after an instrument was delisted.","solutions":["Initialize/load the instrument provider (call the client's initialize/load instruments) before requesting order books.","Verify the symbol matches the cached instrument exactly (use the InstrumentId/Ustr obtained from the provider, not a hand-built string).","Confirm the instrument is currently listed on AX; refresh instruments if it was newly listed.","If the symbol should exist, check for whitespace/case differences in the configured symbol."],"exampleFix":"// before\nclient.request_order_book(\"btcusdt-perp\".into(), Some(10)).await?; // not in cache\n\n// after\nclient.initialize().await?; // loads instruments into cache\nlet instrument_id = InstrumentId::from(\"BTCUSDT-PERP.AX\");\nclient.request_order_book(instrument_id.symbol.as_ustr(), Some(10)).await?;","handlingStrategy":"validation","validationCode":"// before request_order_book\nclient.initialize().await?; // ensures instruments are cached\nif client.get_instrument(&symbol).is_none() {\n    eprintln!(\"{symbol} not cached; loading instruments first\");\n    // reload instrument provider or abort subscription\n}","typeGuard":null,"tryCatchPattern":"match client.request_order_book(symbol, Some(10)).await {\n    Ok(book) => book,\n    Err(e) if e.to_string().contains(\"not found in cache\") => {\n        client.initialize().await?; // (re)load instruments, then retry once\n        client.request_order_book(symbol, Some(10)).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always call the client's initialize/instrument-load step before any data requests.","Subscribe using InstrumentIds obtained from the provider, not hand-built symbol strings.","On startup, log cached symbols so mismatches are visible immediately.","Refresh the instrument cache when subscribing to newly listed instruments."],"tags":["cache","instrument","order-book","rust"],"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"}