nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported order type: {order_type:?}

Error message

Unsupported order type: {order_type:?}

What it means

nautilus_order_type_to_hyperliquid maps Nautilus OrderType values to Hyperliquid order kinds. Only Limit, Market, and the trigger-based stop/take-profit variants are translated; any other OrderType hits the catch-all arm and bails.

Source

Thrown at crates/adapters/hyperliquid/src/common/converters.rs:199

                is_market: true,
                trigger_px,
                tpsl: HyperliquidTpSl::Sl,
            }
        }

        // Trailing stop limit (requires special handling)
        OrderType::TrailingStopLimit => {
            let trigger_px = trigger_price
                .context("Trigger price required for TrailingStopLimit order")?
                .to_string();
            HyperliquidOrderType::Trigger {
                is_market: false,
                trigger_px,
                tpsl: HyperliquidTpSl::Sl,
            }
        }

        _ => anyhow::bail!("Unsupported order type: {order_type:?}"),
    };

    Ok(result)
}

/// Converts a Hyperliquid order type to a Nautilus `OrderType`.
pub fn hyperliquid_order_type_to_nautilus(hl_order_type: &HyperliquidOrderType) -> OrderType {
    match hl_order_type {
        HyperliquidOrderType::Limit { .. } => OrderType::Limit,
        HyperliquidOrderType::Trigger {
            is_market, tpsl, ..
        } => match (is_market, tpsl) {
            (true, HyperliquidTpSl::Sl) => OrderType::StopMarket,
            (false, HyperliquidTpSl::Sl) => OrderType::StopLimit,
            (true, HyperliquidTpSl::Tp) => OrderType::MarketIfTouched,
            (false, HyperliquidTpSl::Tp) => OrderType::LimitIfTouched,
        },
    }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use only OrderType::Limit, Market, StopMarket, StopLimit, LimitIfTouched, or MarketIfTouched for Hyperliquid.
  2. Check the order type before routing and reject/redirect unsupported types at the strategy layer.
  3. If a genuinely new Nautilus variant must be supported, add an arm to the converter mapping it to a Hyperliquid order kind.

Example fix

// before
let hl = nautilus_order_type_to_hyperliquid(&OrderType::TrailingStopMarket)?;
// after
if matches!(order_type, OrderType::TrailingStopMarket | OrderType::MarketToLimit) {
    anyhow::bail!("route this order to a venue that supports it");
}
let hl = nautilus_order_type_to_hyperliquid(&order_type)?;
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED: &[OrderType] = &[
    OrderType::Limit, OrderType::Market, OrderType::StopMarket, OrderType::StopLimit,
    OrderType::LimitIfTouched, OrderType::MarketIfTouched,
];
fn hyperliquid_supports(t: &OrderType) -> bool { SUPPORTED.contains(t) }

Try / catch

match nautilus_order_type_to_hyperliquid(&order_type) {
    Ok(hl) => send(hl),
    Err(e) => anyhow::bail!("venue routing failed: {e}"), // redirect or drop order
}

Prevention

When it happens

Trigger: Passing an OrderType not handled by the match (e.g. MarketToLimit, TrailingStopMarket, TrailingStopLimit) into nautilus_order_type_to_hyperliquid when converting an order for the Hyperliquid adapter.

Common situations: Generic strategy code that builds orders without filtering by venue capabilities; new Nautilus order types added after the adapter was written; routing an order to Hyperliquid that was designed for another exchange.

Related errors


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