{"record":{"id":"ec242e11adad159f","repo":"nautechsystems/nautilus_trader","slug":"instrument-symbol-missing-from-cache","errorCode":null,"errorMessage":"Instrument {symbol} missing from cache","messagePattern":"Instrument (.+?) missing from cache","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":7025,"sourceCode":"            return Ok(InstrumentResolution::Found(Box::new(instrument)));\n        }\n\n        let in_scope = match scope {\n            None => true,\n            Some(scope) if is_spread => scope.load_spreads,\n            Some(scope) => {\n                scope.instrument_types.contains(&inst_type)\n                    || scope.instrument_types.contains(&OKXInstrumentType::Any)\n            }\n        };\n\n        if !in_scope {\n            log::debug!(\"Skipping report for out-of-scope instrument: symbol={symbol}\");\n            return Ok(InstrumentResolution::Skip);\n        }\n\n        if is_open_or_position {\n            anyhow::bail!(\"Instrument {symbol} missing from cache\");\n        }\n\n        log::warn!(\"Instrument {symbol} missing from cache\");\n        Ok(InstrumentResolution::Incomplete)\n    }\n\n    pub(crate) async fn request_spread_order_status_report(\n        &self,\n        account_id: AccountId,\n        instrument_id: InstrumentId,\n        client_order_id: Option<ClientOrderId>,\n        venue_order_id: Option<VenueOrderId>,\n    ) -> anyhow::Result<Option<OrderStatusReport>> {\n        let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let mut params_builder = GetSpreadOrderParamsBuilder::default();\n\n        match (client_order_id, venue_order_id) {\n            (Some(client_order_id), None) => {","sourceCodeStart":7007,"sourceCodeEnd":7043,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L7007-L7043","documentation":"This message covers two cases in OKX report resolution when an instrument is missing from cache: for open instruments or positions (`is_open_or_position`) the adapter hard-fails because a valid instrument is mandatory; for closed/historical instruments it logs a warning and returns `InstrumentResolution::Incomplete`, letting the report skip detailed resolution. The hard bail prevents generating reports for live positions without instrument metadata.","triggerScenarios":"`resolve_instrument`-style lookup finds the symbol absent from the cache while generating order/position reports: an open order/position references an instrument that was never loaded, or was excluded by the scope filter.","commonSituations":"Cache loaded with a narrow instrument scope that excludes an instrument with open orders/positions; newly listed or delisted instruments; restarts where cached instruments were not restored before report generation.","solutions":["Load the missing instrument into the cache before generating reports (include it in the instrument-loading scope).","Check the log line `Skipping report for out-of-scope instrument` to see if the scope filter is excluding it, and widen the scope.","For closed/historical instruments the warning variant is non-fatal — reports proceed as `Incomplete`; verify that is acceptable for your reconciliation.","Confirm the symbol string matches OKX naming (e.g. `BTC-USDT-SWAP`) with no stale/expired contract IDs."],"exampleFix":"// before: scope excludes the instrument with open orders\nlet scope = InstrumentScope::only(\"BTC-USDT.OKX\");\n// after: include all instruments with open interest\nlet scope = InstrumentScope::all();","handlingStrategy":"validation","validationCode":"// pre-flight: every open order/position symbol must resolve in cache\nfor symbol in open_symbols() {\n    let inst_id = InstrumentId::from(format!(\"{symbol}.OKX\"));\n    assert!(cache.instrument(&inst_id).is_some(), \"{inst_id} missing from cache\");\n}","typeGuard":null,"tryCatchPattern":"// treat Incomplete resolution as skip; hard-fail on open instruments\nmatch resolution {\n    InstrumentResolution::Found(inst) => use(inst),\n    InstrumentResolution::Incomplete => log::warn!(\"report incomplete; instrument not cached\"),\n    InstrumentResolution::Skip | Err => continue,\n}","preventionTips":["Load the full instrument universe before reconciliation/report generation.","Never narrow the scope below instruments with open orders or positions.","Check the out-of-scope debug log when reports are unexpectedly skipped.","Refresh instrument caches when OKX lists or expires contracts."],"tags":["okx","cache-miss","instruments","reports"],"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"}