{"record":{"id":"922b65e49f95787c","repo":"nautechsystems/nautilus_trader","slug":"python-fillmodel-fill-limit-inside-spread-failed","errorCode":null,"errorMessage":"Python FillModel.fill_limit_inside_spread failed: {e}","messagePattern":"Python FillModel\\.fill_limit_inside_spread failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/python/fill.rs","lineNumber":107,"sourceCode":"        call_bool_method(&self.obj, \"is_limit_filled\")\n    }\n\n    fn is_slipped(&mut self) -> anyhow::Result<bool> {\n        call_bool_method(&self.obj, \"is_slipped\")\n    }\n\n    fn fill_limit_inside_spread(&self) -> anyhow::Result<bool> {\n        Python::attach(|py| -> anyhow::Result<bool> {\n            let obj = self.obj.bind(py);\n            if !obj.hasattr(\"fill_limit_inside_spread\")? {\n                return Ok(false);\n            }\n\n            obj.call_method0(\"fill_limit_inside_spread\")?\n                .extract()\n                .map_err(|e| anyhow::anyhow!(\"{e}\"))\n        })\n        .map_err(|e| anyhow::anyhow!(\"Python FillModel.fill_limit_inside_spread failed: {e}\"))\n    }\n\n    fn get_orderbook_for_fill_simulation(\n        &mut self,\n        instrument: &InstrumentAny,\n        order: &OrderAny,\n        best_bid: Price,\n        best_ask: Price,\n    ) -> anyhow::Result<Option<OrderBook>> {\n        Python::attach(|py| -> anyhow::Result<Option<OrderBook>> {\n            let obj = self.obj.bind(py);\n            if !obj.hasattr(\"get_orderbook_for_fill_simulation\")? {\n                return Ok(None);\n            }\n\n            let instrument = instrument_any_to_pyobject(py, instrument.clone())?;\n            let order = order_any_to_pyobject(py, order.clone())?;\n            obj.call_method1(","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/python/fill.rs#L89-L125","documentation":"Fired when the Rust FillModel wrapper calls the Python object's fill_limit_inside_spread() method and extracting the returned value as a bool fails (the method raised, returned a non-bool, or is missing). The message wraps the underlying Python exception so the cross-language failure surfaces as a Rust anyhow error.","triggerScenarios":"Any error propagated from the inner Python FFI call — Python exception raised inside the method or a non-boolean return value.","commonSituations":"Custom fill models written for older NautilusTrader versions; Python methods returning Option/None for 'no decision'; typo'd return types.","solutions":["Unwrap the anyhow error chain to see the original Python traceback","Fix the Python fill_limit_inside_spread to return a bool and take no arguments","Pin/align the custom model with the current NautilusTrader FillModel API","Test the model through the Python-facing API before attaching it to a live/backsim config"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    inside = fill_model.fill_limit_inside_spread()\nexcept Exception as e:\n    log.error(f\"FillModel.fill_limit_inside_spread failed: {e}\")\n    inside = False","preventionTips":["Keep the model aligned with the current FillModel Python API","Test via the Rust bridge before live/backsim runs","Log the full anyhow chain to capture the Python traceback"],"tags":["python-interop","fill-model","error-wrapping"],"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"}