nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported time in force for Binance Spot

Error message

Unsupported time in force for Binance Spot: {tif:?}

What it means

Binance Spot only accepts GTC (and GTT-like semantic via GTC) time in force; this error is thrown by `time_in_force_to_binance_spot` when the Nautilus `TimeInForce` cannot be mapped to a Binance Spot TIF enum. GTD is rejected earlier with a dedicated message; any other variant (e.g. Fok, Ioc if unmapped by the caller upstream, AtTheOpen, etc.) hits this catch-all bail.

Solutions

  1. Set the order's time_in_force to TimeInForce::Gtc before submitting to Binance Spot
  2. Check which TIF the adapter maps (Gtc) and pre-validate order TIF in the strategy's submit path
  3. If GTD semantics are needed, use the supported GTD path: set use_gtd=false and enable manage_gtd_expiry on the strategy
  4. If IOC/FOK is required, use the Binance Futures adapter, which supports those TIFs

Example fix

// before
let order = order_factory.limit(
    instrument_id, Side::Buy, qty, price,
    TimeInForce::Ioc, None, None,
);
// after
let order = order_factory.limit(
    instrument_id, Side::Buy, qty, price,
    TimeInForce::Gtc, None, None,
);
Defensive patterns

Strategy: validation

Validate before calling

fn is_spot_tif_supported(tif: TimeInForce) -> bool {
    matches!(tif, TimeInForce::Gtc | TimeInForce::Gtd)
}

Try / catch

match time_in_force_to_binance_spot(order.time_in_force()) {
    Ok(tif) => { /* proceed */ }
    Err(e) => log::error!("TIF unsupported for Binance Spot: {e}"),
}

Prevention

When it happens

Trigger: Calling `time_in_force_to_binance_spot` with any `TimeInForce` other than Gtc or Gtd — e.g. `TimeInForce::Fok`, `TimeInForce::Ioc`, `TimeInForce::AtTheOpen`, `TimeInForce::AtTheClose` — directly or via `submit_order` / `build_new_order_params` / `build_cancel_replace_params` with an order whose TIF is not GTC.

Common situations: Strategies configured with IOC/FOK execution semantics assuming Binance Spot supports them; copying Futures (UMB/UMF) order configs, which do support IOC/FOK, to the Spot adapter; a strategy factory defaulting TIF to something other than GTC.

Related errors


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

Appendix: source

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

/// 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),
        TimeInForce::Fok => Ok(BinanceTimeInForce::Fok),
        TimeInForce::Gtd if !use_gtd => {
            log::warn!(
                "Binance Spot does not support GTD; submitting as GTC because use_gtd=false. Enable manage_gtd_expiry on the submitting strategy"
            );
            Ok(BinanceTimeInForce::Gtc)
        }
        TimeInForce::Gtd => anyhow::bail!(
            "Binance Spot does not support native GTD; set use_gtd=false and enable manage_gtd_expiry on the submitting strategy"
        ),
        _ => anyhow::bail!("Unsupported time in force for Binance Spot: {tif:?}"),
    }
}

#[cfg(test)]
mod tests {
    use rstest::rstest;

    use super::*;

    #[rstest]
    #[case(OrderType::Market, false, BinanceSpotOrderType::Market)]
    #[case(OrderType::Limit, false, BinanceSpotOrderType::Limit)]
    #[case(OrderType::Limit, true, BinanceSpotOrderType::LimitMaker)]
    #[case(OrderType::StopMarket, false, BinanceSpotOrderType::StopLoss)]
    #[case(OrderType::StopLimit, false, BinanceSpotOrderType::StopLossLimit)]
    #[case(OrderType::MarketIfTouched, false, BinanceSpotOrderType::TakeProfit)]
    #[case(
        OrderType::LimitIfTouched,

View on GitHub (pinned to 18893faf8b)