{"record":{"id":"cac8b17531e3cf35","repo":"nautechsystems/nautilus_trader","slug":"python-fillmodel-get-orderbook-for-fill-simulation","errorCode":null,"errorMessage":"Python FillModel.get_orderbook_for_fill_simulation failed: {e}","messagePattern":"Python FillModel\\.get_orderbook_for_fill_simulation failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/python/fill.rs","lineNumber":133,"sourceCode":"        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(\n                \"get_orderbook_for_fill_simulation\",\n                (instrument, order, best_bid, best_ask),\n            )?\n            .extract()\n            .map_err(|e| anyhow::anyhow!(\"{e}\"))\n        })\n        .map_err(|e| {\n            anyhow::anyhow!(\"Python FillModel.get_orderbook_for_fill_simulation failed: {e}\")\n        })\n    }\n}\n\nfn call_bool_method(obj: &Py<PyAny>, method_name: &str) -> anyhow::Result<bool> {\n    Python::attach(|py| -> anyhow::Result<bool> {\n        obj.bind(py)\n            .call_method0(method_name)?\n            .extract()\n            .map_err(|e| anyhow::anyhow!(\"{e}\"))\n    })\n    .map_err(|e| anyhow::anyhow!(\"Python FillModel.{method_name} failed: {e}\"))\n}\n\n/// Extracts a Python fill model object into a Rust [`FillModelAny`].\n///\n/// # Errors\n///","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/python/fill.rs#L115-L151","documentation":"Wraps any failure of the Python FillModel.get_orderbook_for_fill_simulation bridge call with a prefix identifying the failing component. The inner `{e}` carries the Python exception or extraction failure.","triggerScenarios":"Any error propagated from the inner Python FFI call in get_orderbook_for_fill_simulation.","commonSituations":"Custom fill simulation models incompatible with the current NautilusTrader Python API; exceptions raised for illiquid or missing-book instruments.","solutions":["Unwrap the anyhow chain to read the original Python traceback","Fix the Python method's implementation or return type","Align the model with the current FillModel.get_orderbook_for_fill_simulation contract","Cover the model with integration tests before live deployment"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    book = fill_model.get_orderbook_for_fill_simulation(instrument, order, bid, ask)\nexcept Exception as e:\n    log.error(f\"FillModel.get_orderbook_for_fill_simulation failed: {e}\")\n    book = default_book(bid, ask)","preventionTips":["Unwrap the anyhow chain to read the Python traceback","Align with the current fill-simulation API contract","Cover the model with integration tests for edge instruments"],"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"}