nautechsystems/nautilus_trader · error

{FAILED}: {e}

Error message

{FAILED}: {e}

What it means

MarketToLimitOrder::new panics with `Condition failed: {e}` when MarketToLimitOrder::new_checked returns an OrderError; `new` converts Err into a panic. Checks include check_positive_quantity, check_display_qty, and OrderInitialized::new_checked invariants. `FAILED` is `"Condition failed"` from crates/core/src/correctness.rs.

Source

Thrown at crates/model/src/orders/market_to_limit.rs:199

            quantity,
            time_in_force,
            expire_time,
            post_only,
            reduce_only,
            quote_quantity,
            display_qty,
            contingency_type,
            order_list_id,
            linked_order_ids,
            parent_order_id,
            exec_algorithm_id,
            exec_algorithm_params,
            exec_spawn_id,
            tags,
            init_id,
            ts_init,
        )
        .unwrap_or_else(|e| panic!("{FAILED}: {e}"))
    }
}

impl PartialEq for MarketToLimitOrder {
    fn eq(&self, other: &Self) -> bool {
        self.client_order_id == other.client_order_id
    }
}

impl Deref for MarketToLimitOrder {
    type Target = OrderCore;

    fn deref(&self) -> &Self::Target {
        &self.core
    }
}

impl DerefMut for MarketToLimitOrder {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Read the `{e}` OrderError text to identify which check failed.
  2. Use MarketToLimitOrder::new_checked and handle the Result.
  3. Correct inputs: positive quantity, display_qty <= quantity, valid OrderSide.
  4. Sanitize config/deserialized values before construction.

Example fix

// before
let order = MarketToLimitOrder::new(..., Quantity::from(0), ...); // panics
// after
let order = MarketToLimitOrder::new_checked(..., Quantity::from(100), ...)?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_mtl_args(qty: Quantity, display_qty: Option<Quantity>) -> Result<(), String> {
    if qty.raw == 0 { return Err("quantity must be positive".into()); }
    if let Some(dq) = display_qty { if dq > qty { return Err("display_qty exceeds quantity".into()); } }
    Ok(())
}

Type guard

if qty.is_zero() || side == OrderSide::NoOrderSide { return None; }

Prevention

When it happens

Trigger: Calling MarketToLimitOrder::new (crates/model/src/orders/market_to_limit.rs) with a non-positive quantity, display_qty greater than quantity, or an OrderInitialized::new_checked invariant violation (NoOrderSide, invalid contingency/linked-order configuration).

Common situations: Iceberg-style display_qty above total quantity; zero quantity from a strategy template; side defaulting through an unvalidated conversion; orders rebuilt from serialized events with invalid metadata.

Related errors


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