nautechsystems/nautilus_trader · error

Python FillModel.get_orderbook_for_fill_simulation failed: {

Error message

Python FillModel.get_orderbook_for_fill_simulation failed: {e}

What it means

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.

Source

Thrown at crates/execution/src/python/fill.rs:133

        best_ask: Price,
    ) -> anyhow::Result<Option<OrderBook>> {
        Python::attach(|py| -> anyhow::Result<Option<OrderBook>> {
            let obj = self.obj.bind(py);
            if !obj.hasattr("get_orderbook_for_fill_simulation")? {
                return Ok(None);
            }

            let instrument = instrument_any_to_pyobject(py, instrument.clone())?;
            let order = order_any_to_pyobject(py, order.clone())?;
            obj.call_method1(
                "get_orderbook_for_fill_simulation",
                (instrument, order, best_bid, best_ask),
            )?
            .extract()
            .map_err(|e| anyhow::anyhow!("{e}"))
        })
        .map_err(|e| {
            anyhow::anyhow!("Python FillModel.get_orderbook_for_fill_simulation failed: {e}")
        })
    }
}

fn call_bool_method(obj: &Py<PyAny>, method_name: &str) -> anyhow::Result<bool> {
    Python::attach(|py| -> anyhow::Result<bool> {
        obj.bind(py)
            .call_method0(method_name)?
            .extract()
            .map_err(|e| anyhow::anyhow!("{e}"))
    })
    .map_err(|e| anyhow::anyhow!("Python FillModel.{method_name} failed: {e}"))
}

/// Extracts a Python fill model object into a Rust [`FillModelAny`].
///
/// # Errors
///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Unwrap the anyhow chain to read the original Python traceback
  2. Fix the Python method's implementation or return type
  3. Align the model with the current FillModel.get_orderbook_for_fill_simulation contract
  4. Cover the model with integration tests before live deployment
Defensive patterns

Strategy: try-catch

Try / catch

try:
    book = fill_model.get_orderbook_for_fill_simulation(instrument, order, bid, ask)
except Exception as e:
    log.error(f"FillModel.get_orderbook_for_fill_simulation failed: {e}")
    book = default_book(bid, ask)

Prevention

When it happens

Trigger: Any error propagated from the inner Python FFI call in get_orderbook_for_fill_simulation.

Common situations: Custom fill simulation models incompatible with the current NautilusTrader Python API; exceptions raised for illiquid or missing-book instruments.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/cac8b17531e3cf35. Report an issue: GitHub.