nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported order type for Binance Spot: {order_type:?}

Error message

Unsupported order type for Binance Spot: {order_type:?}

What it means

order_type_to_binance_spot maps Nautilus OrderType values onto the limited set Binance Spot supports: Market, Limit (post-only becomes LIMIT_MAKER), StopMarket->STOP_LOSS, StopLimit->STOP_LOSS_LIMIT, MarketIfTouched->TAKE_PROFIT and LimitIfTouched->TAKE_PROFIT_LIMIT. Every other variant has no Binance Spot equivalent and the conversion bails.

Source

Thrown at crates/adapters/binance/src/spot/enums.rs:115

/// Converts a Nautilus order type to Binance Spot order type.
///
/// # Errors
///
/// Returns an error if the order type is not supported on Binance Spot.
pub fn order_type_to_binance_spot(
    order_type: OrderType,
    post_only: bool,
) -> anyhow::Result<BinanceSpotOrderType> {
    match (order_type, post_only) {
        (OrderType::Market, _) => Ok(BinanceSpotOrderType::Market),
        (OrderType::Limit, true) => Ok(BinanceSpotOrderType::LimitMaker),
        (OrderType::Limit, false) => Ok(BinanceSpotOrderType::Limit),
        (OrderType::StopMarket, _) => Ok(BinanceSpotOrderType::StopLoss),
        (OrderType::StopLimit, _) => Ok(BinanceSpotOrderType::StopLossLimit),
        (OrderType::MarketIfTouched, _) => Ok(BinanceSpotOrderType::TakeProfit),
        (OrderType::LimitIfTouched, _) => Ok(BinanceSpotOrderType::TakeProfitLimit),
        _ => anyhow::bail!("Unsupported order type for Binance Spot: {order_type:?}"),
    }
}

/// Converts a Nautilus time in force to Binance Spot time in force.
///
/// Binance Spot only supports GTC, IOC, and FOK. When native GTD is disabled,
/// GTD maps to GTC so a Nautilus strategy can manage expiry locally.
///
/// # Errors
///
/// Returns an error if the time in force is not supported on Binance Spot.
pub fn time_in_force_to_binance_spot(
    tif: TimeInForce,
    use_gtd: bool,
) -> anyhow::Result<BinanceTimeInForce> {
    match tif {
        TimeInForce::Gtc => Ok(BinanceTimeInForce::Gtc),
        TimeInForce::Ioc => Ok(BinanceTimeInForce::Ioc),

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Replace trailing stops with StopMarket/StopLimit and manage the trailing logic in the strategy
  2. Use Market or Limit (with post_only where maker behavior is required)
  3. Pre-validate the order type against the supported set before creating the order

Example fix

# before: unsupported on Binance Spot
order = self.order_factory.trailing_stop_market(
    instrument_id, order_side=OrderSide.BUY, quantity=qty, trailing_offset=..., trailing_offset_type=...,
)

# after: emulate with a strategy-managed stop
order = self.order_factory.stop_market(
    instrument_id, order_side=OrderSide.BUY, quantity=qty, trigger_price=stop_price,
)
# strategy updates the trigger price as the market moves
Defensive patterns

Strategy: type-guard

Validate before calling

fn ensure_supported_spot_order_type(order_type: OrderType) -> anyhow::Result<()> {
    anyhow::ensure!(
        matches!(
            order_type,
            OrderType::Market
                | OrderType::Limit
                | OrderType::StopMarket
                | OrderType::StopLimit
                | OrderType::MarketIfTouched
                | OrderType::LimitIfTouched
        ),
        "order type {order_type:?} is not available on Binance Spot"
    );
    Ok(())
}

Type guard

fn is_supported_binance_spot_order_type(order_type: OrderType) -> bool {
    matches!(
        order_type,
        OrderType::Market
            | OrderType::Limit
            | OrderType::StopMarket
            | OrderType::StopLimit
            | OrderType::MarketIfTouched
            | OrderType::LimitIfTouched
    )
}

Try / catch

match submit_order(cmd) {
    Ok(_) => {}
    Err(e) if e.to_string().contains("Unsupported order type for Binance Spot") => {
        // deny locally: no venue call was possible
        self.emitter.emit_order_denied(&order, &e.to_string());
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Submitting, modifying, or listing an order whose OrderType is MarketToLimit, TrailingStopMarket, TrailingStopLimit, or any other unmapped variant — build_spot_order_params and the WS/HTTP param builders all route through this function.

Common situations: Strategies written for futures or equities venues that use trailing stops on spot; ported signal libraries that emit MarketToLimit; shared order factories reused across adapters without venue filtering.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/233f49f7c50a0bf2. Report an issue: GitHub.