{"record":{"id":"5c87e2604ee48c2c","repo":"nautechsystems/nautilus_trader","slug":"python-on-historical-quotes-failed-e","errorCode":null,"errorMessage":"Python on_historical_quotes failed: {e}","messagePattern":"Python on_historical_quotes failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/python/actor.rs","lineNumber":1228,"sourceCode":"            };\n            self.dispatch_on_historical_data(py_data)\n                .map_err(|e| anyhow::anyhow!(\"Python on_historical_data failed: {e}\"))\n        })\n    }\n\n    fn on_historical_book_deltas(&mut self, deltas: &[OrderBookDelta]) -> anyhow::Result<()> {\n        self.dispatch_on_historical_book_deltas(deltas.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_book_deltas failed: {e}\"))\n    }\n\n    fn on_historical_book_depth(&mut self, depths: &[OrderBookDepth10]) -> anyhow::Result<()> {\n        self.dispatch_on_historical_book_depth(depths.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_book_depth failed: {e}\"))\n    }\n\n    fn on_historical_quotes(&mut self, quotes: &[QuoteTick]) -> anyhow::Result<()> {\n        self.dispatch_on_historical_quotes(quotes.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_quotes failed: {e}\"))\n    }\n\n    fn on_historical_trades(&mut self, trades: &[TradeTick]) -> anyhow::Result<()> {\n        self.dispatch_on_historical_trades(trades.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_trades failed: {e}\"))\n    }\n\n    fn on_historical_funding_rates(\n        &mut self,\n        funding_rates: &[FundingRateUpdate],\n    ) -> anyhow::Result<()> {\n        self.dispatch_on_historical_funding_rates(funding_rates.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_funding_rates failed: {e}\"))\n    }\n\n    fn on_historical_bars(&mut self, bars: &[Bar]) -> anyhow::Result<()> {\n        self.dispatch_on_historical_bars(bars.to_vec())\n            .map_err(|e| anyhow::anyhow!(\"Python on_historical_bars failed: {e}\"))","sourceCodeStart":1210,"sourceCodeEnd":1246,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/python/actor.rs#L1210-L1246","documentation":"Raised by `DataActor::on_historical_quotes` (crates/common/src/python/actor.rs:1228) when dispatching a slice of `QuoteTick` historical data to the Python actor's `on_historical_quotes` callback fails. The dispatch clones the quotes into a Vec and calls the Python method via pyo3; a Python exception inside the handler, a missing method, or quote-to-Python conversion failure is reported as `Python on_historical_quotes failed: {e}`.","triggerScenarios":"Occurs when historical quote ticks are delivered (e.g. result of `request_quotes`) and the Python `on_historical_quotes` callback raises, the Python object lacks the method, or the quotes fail to convert to Python objects.","commonSituations":"Handler code doing pandas conversions that raise on empty lists or unexpected fields; strategies that request historical quotes without implementing the handler; mixing up on_historical_quotes vs on_quote_tick; version drift in QuoteTick fields.","solutions":["Inspect the embedded `{e}` cause (Python traceback) and fix the failing `on_historical_quotes` handler code.","Implement `on_historical_quotes(self, quotes)` on the Python actor if quotes are requested.","Guard against empty quote lists before processing (e.g. computing mid from the first quote).","Verify quote field access (bid/ask/bid_size/ask_size) matches your installed nautilus version."],"exampleFix":"# before\ndef on_historical_quotes(self, quotes):\n    mid = (quotes[0].bid_price + quotes[0].ask_price) / 2  # IndexError on empty\n\n# after\ndef on_historical_quotes(self, quotes):\n    if not quotes:\n        self.log.warning(\"No historical quotes received\")\n        return\n    mid = (quotes[0].bid_price + quotes[0].ask_price) / 2","handlingStrategy":"try-catch","validationCode":"assert callable(getattr(actor, 'on_historical_quotes', None)), \"actor must implement on_historical_quotes\"\n","typeGuard":"def has_quotes_handler(obj):\n    return callable(getattr(obj, 'on_historical_quotes', None))\n","tryCatchPattern":"try:\n    actor.on_historical_quotes(quotes)\nexcept Exception as e:\n    log.error(f\"on_historical_quotes failed: {e}\", exc_info=True)\n","preventionTips":["Check for empty quote lists before index/aggregation math","Implement the handler on any actor that calls request_quotes","Distinguish on_historical_quotes from on_quote_tick handlers","Keep quote field access in sync with the installed nautilus version"],"tags":["python","historical-data","quotes","callback","rust"],"backgroundTag":"api-request-failed","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"}