nautechsystems/nautilus_trader · error · anyhow::Error

Market-if-touched orders require a trigger price

Error message

Market-if-touched orders require a trigger price

What it means

Hyperliquid requires that Market-if-Touched (MIT) orders carry a trigger price, because on the exchange an MIT order is represented as a trigger order with is_market=true. The adapter converts Nautilus OrderType::MarketIfTouched into a Hyperliquid trigger request, and if the order's trigger_price() is None it cannot build a valid request, so it aborts with this anyhow::bail! instead of sending a malformed order.

Source

Thrown at crates/adapters/hyperliquid/src/common/parse.rs:614

            }
        }
        OrderType::MarketIfTouched => {
            if let Some(trigger_price) = order.trigger_price() {
                let raw = trigger_price.as_decimal();
                let trigger_price_decimal = if should_normalize_prices {
                    normalize_price(raw, price_decimals).normalize()
                } else {
                    raw.normalize()
                };
                HyperliquidExchangeOrderKind::Trigger {
                    trigger: HyperliquidExchangeTriggerParams {
                        is_market: true,
                        trigger_px: trigger_price_decimal,
                        tpsl: HyperliquidExchangeTpSl::Tp,
                    },
                }
            } else {
                anyhow::bail!("Market-if-touched orders require a trigger price")
            }
        }
        OrderType::LimitIfTouched => {
            if let Some(trigger_price) = order.trigger_price() {
                let raw = trigger_price.as_decimal();
                let trigger_price_decimal = if should_normalize_prices {
                    normalize_price(raw, price_decimals).normalize()
                } else {
                    raw.normalize()
                };
                HyperliquidExchangeOrderKind::Trigger {
                    trigger: HyperliquidExchangeTriggerParams {
                        is_market: false,
                        trigger_px: trigger_price_decimal,
                        tpsl: HyperliquidExchangeTpSl::Tp,
                    },
                }
            } else {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set a trigger price when creating the order via OrderFactory::market_if_touched(... trigger_price=...) so order.trigger_price() is Some.
  2. Validate the order in the strategy before submitting: check order.trigger_price().is_some() for MIT order types.
  3. If the intent was an immediate market order, use OrderType::Market instead of MarketIfTouched.

Example fix

// before
let order = self.order_factory.market_if_touched(
    instrument_id, OrderSide::Buy, quantity, None, TimeInForce::Gtc,
);
// after
let order = self.order_factory.market_if_touched(
    instrument_id, OrderSide::Buy, quantity, Some(trigger_price), TimeInForce::Gtc,
);
Defensive patterns

Strategy: validation

Validate before calling

if matches!(order.order_type(), OrderType::MarketIfTouched) && order.trigger_price().is_none() {
    return Err("MIT order submitted to Hyperliquid without trigger price");
}

Type guard

fn has_trigger(order: &OrderAny) -> bool { order.trigger_price().is_some() }

Prevention

When it happens

Trigger: Calling submit_order/modify_order/order_request with an OrderType::MarketIfTouched order whose trigger_price() returns None — e.g. a MarketIfTouchedOrder was constructed without a trigger_price parameter.

Common situations: Building orders programmatically from strategies where the trigger price is optional in the internal order model; migrating code from venues where market orders don't need triggers; copying a Market order factory call and changing the type to MarketIfTouched without adding trigger_price.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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