nautechsystems/nautilus_trader · error · anyhow::Error

invalid `entry_order_type`, was {other}

Error message

invalid `entry_order_type`, was {other}

What it means

Inside the bracket-order factory (`try_bracket`), the entry order is built by matching on the requested `entry_order_type`; only entry order types that produce a valid bracket entry (stop-limit, limit, market, stop-market style entries) are handled. Any other OrderAny/OrderType variant falls into the catch-all arm and bails with this error, meaning the requested order type cannot be used as the entry leg of a bracket order.

Source

Thrown at crates/common/src/factories/order.rs:1459

                expire_time,
                entry_post_only,
                false, // reduce_only
                quote_quantity,
                None, // display_qty
                emulation_trigger,
                trigger_instrument_id,
                entry_contingency_type,
                entry_order_list_id,
                entry_linked_order_ids,
                entry_parent_order_id,
                entry_exec_algorithm_id,
                entry_exec_algorithm_params,
                entry_exec_spawn_id,
                entry_tags,
                UUID4::new(),
                ts_init,
            )?),
            other => anyhow::bail!("invalid `entry_order_type`, was {other}"),
        };

        let sl_tp_side = match order_side {
            OrderSide::Buy => OrderSide::Sell,
            OrderSide::Sell => OrderSide::Buy,
        };

        let tp_contingency_type = Some(contingency_type);
        let tp_order_list_id = Some(order_list_id);
        let tp_linked_order_ids = Some(vec![sl_client_order_id]);
        let tp_parent_order_id = Some(entry_client_order_id);

        let tp_order = match tp_order_type {
            OrderType::Limit => OrderAny::Limit(LimitOrder::new_checked(
                self.trader_id,
                self.strategy_id,
                instrument_id,
                tp_client_order_id,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use a supported entry order type (market, limit, stop-market, stop-limit) for the bracket's entry leg.
  2. Validate entry_order_type against the supported set before calling bracket().
  3. Place trailing-stop orders directly instead of via bracket(); pair them with manual TP/SL if needed.
  4. If a previously valid type now fails, check the changelog for OrderType changes and update the caller.

Example fix

// before
let order_list = factory.bracket(entry_order_type, OrderSide::Buy, ...)?;

// after
assert!(matches!(
    entry_order_type,
    OrderType::Market | OrderType::Limit | OrderType::StopMarket | OrderType::StopLimit
), "unsupported bracket entry type");
let order_list = factory.bracket(entry_order_type, OrderSide::Buy, ...)?;
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_ENTRY: &[OrderType] = &[
    OrderType::Market, OrderType::Limit,
    OrderType::StopMarket, OrderType::StopLimit,
];
if !SUPPORTED_ENTRY.contains(&entry_order_type) {
    return Err(anyhow::anyhow!(
        "unsupported bracket entry_order_type: {entry_order_type:?}"
    ));
}

Type guard

fn is_valid_bracket_entry(t: OrderType) -> bool {
    matches!(
        t,
        OrderType::Market
            | OrderType::Limit
            | OrderType::StopMarket
            | OrderType::StopLimit
    )
}

Try / catch

match factory.bracket(entry_order_type, side, price, ...) {
    Ok(orders) => orders,
    Err(e) if e.to_string().contains("invalid `entry_order_type`") => {
        bail!("bracket entry type {entry_order_type:?} unsupported; use Market/Limit/StopMarket/StopLimit")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `factory.bracket(...)` (which calls try_bracket) with an `entry_order_type` value that is not one of the supported entry types — e.g. passing TRAILING_STOP_MARKET, TRAILING_STOP_LIMIT, or another exotic order type as the entry leg.

Common situations: Configuring a strategy from YAML/TOML where the entry order type string maps to an unsupported variant; generic strategy code forwarding a user-selected order type straight into bracket() without whitelisting; enum variant renamed/added in a version upgrade so a previously accepted value now hits the catch-all.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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