nautechsystems/nautilus_trader · error
{FAILED}: {e}
Error message
{FAILED}: {e} What it means
MarketIfTouchedOrder::new panics with `Condition failed: {e}` when MarketIfTouchedOrder::new_checked returns an OrderError; the `new` wrapper converts Err into a panic. Checks include check_positive_quantity, check_time_in_force (GTD requires expire_time) and OrderInitialized::new_checked invariants. `FAILED` is `"Condition failed"` from crates/core/src/correctness.rs.
Source
Thrown at crates/model/src/orders/market_if_touched.rs:209
trigger_type,
time_in_force,
expire_time,
reduce_only,
quote_quantity,
emulation_trigger,
trigger_instrument_id,
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 MarketIfTouchedOrder {
fn eq(&self, other: &Self) -> bool {
self.client_order_id == other.client_order_id
}
}
impl Deref for MarketIfTouchedOrder {
type Target = OrderCore;
fn deref(&self) -> &Self::Target {
&self.core
}
}
impl DerefMut for MarketIfTouchedOrder {View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the OrderError message inside the panic for the exact failed check.
- Call MarketIfTouchedOrder::new_checked and handle Result.
- Fix inputs: positive quantity, expire_time for GTD, valid side.
- Validate strategy-config values before construction.
Example fix
// before let order = MarketIfTouchedOrder::new(..., TimeInForce::Gtd, None, ...); // panics // after let order = MarketIfTouchedOrder::new_checked(..., TimeInForce::Gtd, Some(expire_unix_nanos), ...)?;
Defensive patterns
Strategy: validation
Validate before calling
fn valid_mit_args(qty: Quantity, tif: TimeInForce, expire_time: Option<UnixNanos>) -> Result<(), String> {
if qty.raw == 0 { return Err("quantity must be positive".into()); }
if tif == TimeInForce::Gtd && expire_time.map_or(true, |t| t.as_u64() == 0) { return Err("GTD requires expire_time".into()); }
Ok(())
} Type guard
if qty.is_zero() || side == OrderSide::NoOrderSide { return None; } Prevention
- Always set expire_time for GTD
- Verify quantity positivity at config load time
- Prefer new_checked at boundaries with untrusted input
When it happens
Trigger: Calling MarketIfTouchedOrder::new (crates/model/src/orders/market_if_touched.rs) with a non-positive quantity, TimeInForce::Gtd with None/zero expire_time, or an invalid init-event invariant such as NoOrderSide.
Common situations: GTD MIT orders created without expire_time; zero quantity from a defaulted strategy config; side lost in an enum round-trip; rebuilding orders from cache/serialized events with missing fields.
Related errors
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/12f7d1fbeec64856.
Report an issue: GitHub.