{"record":{"id":"d8f53fc31829a8f2","repo":"nautechsystems/nautilus_trader","slug":"python-feemodel-get-commission-with-context-failed","errorCode":null,"errorMessage":"Python FeeModel.get_commission_with_context failed: {e}","messagePattern":"Python FeeModel\\.get_commission_with_context failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/python/fee.rs","lineNumber":229,"sourceCode":"                return obj\n                    .call_method1(\n                        \"get_commission\",\n                        (order, fill_quantity, fill_px, instrument),\n                    )?\n                    .extract()\n                    .map_err(|e| anyhow::anyhow!(\"{e}\"));\n            }\n\n            let order = order_any_to_pyobject(py, order.clone())?;\n            let instrument = instrument_any_to_pyobject(py, instrument.clone())?;\n            obj.call_method1(\n                \"get_commission_with_context\",\n                (order, fill_quantity, fill_px, instrument, underlying_px),\n            )?\n            .extract()\n            .map_err(|e| anyhow::anyhow!(\"{e}\"))\n        })\n        .map_err(|e| anyhow::anyhow!(\"Python FeeModel.get_commission_with_context failed: {e}\"))\n    }\n}\n\nfn has_method_override_before_base(\n    py: Python<'_>,\n    obj: &Bound<'_, PyAny>,\n    method_name: &str,\n) -> PyResult<bool> {\n    let base_type = py.get_type::<PyFeeModel>();\n    for cls in obj.get_type().getattr(\"__mro__\")?.try_iter()? {\n        let cls = cls?;\n        if cls.is(base_type.as_any()) {\n            return Ok(false);\n        }\n\n        if cls.getattr(\"__dict__\")?.contains(method_name)? {\n            return Ok(true);\n        }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/python/fee.rs#L211-L247","documentation":"Wraps any failure of the Python FeeModel.get_commission_with_context call with a descriptive prefix identifying the failing bridge boundary. The `{e}` carries the inner cause: either the Python call raised an exception or the result could not be extracted to the expected Rust type.","triggerScenarios":"Any error propagated from the inner Python FFI call in get_commission_with_context — Python exception, argument conversion failure, or extract() type mismatch.","commonSituations":"Deploying a custom fee model written against an older NautilusTrader Python API; returning a custom object instead of a numeric commission; Python exceptions such as KeyError on instrument_id.","solutions":["Inspect the full anyhow error chain (source of this message) to find the original Python exception","Fix the Python FeeModel implementation or its return type","Match the current NautilusTrader FeeModel.get_commission_with_context signature","Add unit tests for the Python model against representative orders/instruments"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    commission = fee_model.get_commission_with_context(order, qty, px, instrument, underlying_px)\nexcept Exception as e:\n    log.error(f\"FeeModel.get_commission_with_context failed: {e}\")\n    commission = fallback_commission(qty, px)","preventionTips":["Print the full anyhow chain ({e:#}) to see the root Python exception","Test the Python model through the Rust-facing integration path","Pin model implementations to the NautilusTrader version in use"],"tags":["python-interop","fee-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-14T00:17:10.932Z"}