nautechsystems/nautilus_trader · error
{FAILED}: {e}
Error message
{FAILED}: {e} What it means
MarketOrder::new panics with `Condition failed: {e}` when MarketOrder::new_checked returns an OrderError; `new` unwraps into a panic. MarketOrder runs check_positive_quantity and the OrderInitialized::new_checked invariants (it has no price/expire-time checks). `FAILED` is `"Condition failed"` from crates/core/src/correctness.rs.
Source
Thrown at crates/model/src/orders/market.rs:188
instrument_id,
client_order_id,
order_side,
quantity,
time_in_force,
init_id,
ts_init,
reduce_only,
quote_quantity,
contingency_type,
order_list_id,
linked_order_ids,
parent_order_id,
exec_algorithm_id,
exec_algorithm_params,
exec_spawn_id,
tags,
)
.unwrap_or_else(|e| panic!("{FAILED}: {e}"))
}
}
impl Deref for MarketOrder {
type Target = OrderCore;
fn deref(&self) -> &Self::Target {
&self.core
}
}
impl DerefMut for MarketOrder {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.core
}
}
impl PartialEq for MarketOrder {View on GitHub (pinned to 18893faf8b)
Solutions
- Read the `{e}` OrderError text — for market orders it is almost always the positive-quantity check.
- Use MarketOrder::new_checked and handle the Result instead of panicking.
- Ensure quantity > 0 and a concrete OrderSide before construction.
- Sanitize deserialized order payloads before rebuilding MarketOrder.
Example fix
// before let order = MarketOrder::new(..., OrderSide::NoOrderSide, Quantity::from(0), ...); // panics // after let order = MarketOrder::new_checked(..., OrderSide::Buy, Quantity::from(100), ...)?;
Defensive patterns
Strategy: validation
Validate before calling
fn valid_market_args(side: OrderSide, qty: Quantity) -> Result<(), String> {
if qty.raw == 0 { return Err("quantity must be positive".into()); }
if side == OrderSide::NoOrderSide { return Err("side must be Buy or Sell".into()); }
Ok(())
} Type guard
if qty.is_zero() || side == OrderSide::NoOrderSide { return None; } Prevention
- Check quantity > 0 before any order construction
- Map external side enums to OrderSide::Buy/Sell with a validated fallback
- Use new_checked at deserialization boundaries
When it happens
Trigger: Calling MarketOrder::new (crates/model/src/orders/market.rs) with a zero/non-positive Quantity, OrderSide::NoOrderSide, or an OrderInitialized::new_checked violation (invalid contingency/linked_order_ids, already-invalid identifier or metadata combination).
Common situations: Market orders built with a quantity defaulted to zero from a strategy template; sides mapped from an unvalidated external enum; reconstruction from serialized events with corrupt/zero quantity.
Related errors
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9516af09cbe26cf0.
Report an issue: GitHub.