{"record":{"id":"8d5475c9a5d1d47f","repo":"nautechsystems/nautilus_trader","slug":"backtest-data-client-cannot-fetch-option-chain-ref","errorCode":null,"errorMessage":"backtest data client cannot fetch option-chain reference prices","messagePattern":"backtest data client cannot fetch option-chain reference prices","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/backtest/src/data_client.rs","lineNumber":327,"sourceCode":"        // No-op in backtest: quotes are replayed by the engine\n        Ok(())\n    }\n\n    fn request_trades(&self, _request: RequestTrades) -> anyhow::Result<()> {\n        // No-op in backtest: trades are replayed by the engine\n        Ok(())\n    }\n\n    fn request_bars(&self, _request: RequestBars) -> anyhow::Result<()> {\n        // No-op in backtest: bars are replayed by the engine\n        Ok(())\n    }\n\n    fn request_option_chain_reference_price(\n        &self,\n        _request: RequestOptionChainReferencePrice,\n    ) -> anyhow::Result<()> {\n        anyhow::bail!(\"backtest data client cannot fetch option-chain reference prices\")\n    }\n\n    #[cfg(feature = \"defi\")]\n    fn request_pool_snapshot(&self, _request: RequestPoolSnapshot) -> anyhow::Result<()> {\n        Ok(())\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use nautilus_core::{UUID4, UnixNanos};\n    use nautilus_model::identifiers::{InstrumentId, OptionSeriesId};\n    use rstest::rstest;\n    use ustr::Ustr;\n\n    use super::*;\n\n    #[rstest]","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/data_client.rs#L309-L345","documentation":"The backtest data client intentionally does not implement option-chain reference price fetching — there is no simulated source for that data. Requests are rejected with this error rather than silently returning nothing, so callers know the capability is unsupported in backtest mode.","triggerScenarios":"Calling request_option_chain_reference_price on the BacktestDataClient, which happens when a strategy issues a RequestOptionChainReferencePrice during a backtest.","commonSituations":"A live trading strategy that queries option-chain reference prices is run unmodified in a backtest; porting a live options strategy to the backtest engine without adapting data requests.","solutions":["Remove or guard the RequestOptionChainReferencePrice call when running in backtest mode","Provide the reference prices via injected data/timers in the backtest scenario instead","Use a custom data client or engine extension that supplies simulated option-chain reference prices","Gate the request behind a capability check (only issue it against live data clients)"],"exampleFix":"// before\nself.request_option_chain_reference_price(request);  // called in backtest too\n// after\n#[cfg(not(feature = \"backtest\"))]\nself.request_option_chain_reference_price(request);  // live only","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn supports_option_chain_reference_price(client: &dyn DataClient) -> bool {\n    // backtest data client intentionally does not implement this capability\n    client.as_any().downcast_ref::<BacktestDataClient>().is_none()\n}\nif supports_option_chain_reference_price(&self.client) {\n    self.request_option_chain_reference_price(request);\n}","tryCatchPattern":"match client.request_option_chain_reference_price(request) {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"option-chain reference prices\") => {\n        log::warn!(\"Backtest mode: skipping option-chain reference price request\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Gate live-only data requests behind a mode check","Read the data client capability list before issuing requests","Adapt option strategies when porting from live to backtest"],"tags":["backtest","unsupported-operation","options"],"backgroundTag":"unsupported-operation","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"}