{"record":{"id":"6aadce370b0e6f2b","repo":"nautechsystems/nautilus_trader","slug":"python-on-order-list-failed-e-6aadce","errorCode":null,"errorMessage":"Python on_order_list failed: {e}","messagePattern":"Python on_order_list failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/python/algorithm.rs","lineNumber":407,"sourceCode":"\nimpl ExecutionAlgorithm for PyExecutionAlgorithm {\n    fn on_order(&mut self, order: OrderAny) -> anyhow::Result<()> {\n        self.dispatch_on_order(order)\n            .map_err(|e| anyhow::anyhow!(\"Python on_order failed: {e}\"))\n    }\n\n    fn on_order_list(\n        &mut self,\n        order_list: OrderList,\n        orders: Vec<OrderAny>,\n    ) -> anyhow::Result<()> {\n        if self\n            .has_python_override(\"on_order_list\")\n            .map_err(|e| anyhow::anyhow!(\"Python override lookup failed: {e}\"))?\n        {\n            return self\n                .dispatch_on_order_list(order_list, orders)\n                .map_err(|e| anyhow::anyhow!(\"Python on_order_list failed: {e}\"));\n        }\n\n        for order in orders {\n            self.on_order(order)?;\n        }\n        Ok(())\n    }\n\n    fn on_start(&mut self) -> anyhow::Result<()> {\n        log::info!(\"Starting {}\", self.exec_algorithm_id());\n        Ok(())\n    }\n\n    fn on_stop(&mut self) -> anyhow::Result<()> {\n        Ok(())\n    }\n\n    fn on_reset(&mut self) -> anyhow::Result<()> {","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/python/algorithm.rs#L389-L425","documentation":"When the Python object overrides `on_order_list`, PyExecutionAlgorithm dispatches the whole list into Python via `dispatch_on_order_list`; any Python exception is re-wrapped as this anyhow error. If there is no override, Rust falls back to looping on_order per order instead.","triggerScenarios":"Python class defines on_order_list and it raises when called with the OrderList plus orders — bad signature, exception in user code, or argument conversion failure (OrderList/orders to Python).","commonSituations":"User Python on_order_list assumes a different tuple/argument layout; conversion of an order in the list fails mid-iteration; a domain exception inside the batch handler.","solutions":["Read the chained `{e}` traceback and fix the Python on_order_list implementation.","Verify the Python signature matches dispatch_on_order_list's expected (order_list, orders) layout.","Test the batch callback with the same OrderList/OrderAny contents in pure Python to reproduce.","If batch handling is not needed, remove the on_order_list override so the Rust per-order fallback runs."],"exampleFix":"// before\ndef on_order_list(self, orders): ...  # wrong signature\n\n// after\ndef on_order_list(self, order_list, orders): ...","handlingStrategy":"try-catch","validationCode":"# Python: verify batch signature before registration\nimport inspect\nsig = inspect.signature(algo.on_order_list)\nassert len(sig.parameters) == 2, \"on_order_list must take (order_list, orders)\"","typeGuard":null,"tryCatchPattern":"match algo.on_order_list(order_list, orders) {\n    Ok(()) => {},\n    Err(e) => log::error!(\"python on_order_list failed: {e:#}\"),\n}","preventionTips":["Match the Python on_order_list signature to (order_list, orders) exactly.","Test the batch handler with the full list contents, including orders that convert edge-case fields.","Fall back to per-order handling (no override) if batch logic is not required."],"tags":["rust","python","pyo3","callback-failed","order-list"],"backgroundTag":"api-error-response","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"}