nautechsystems/nautilus_trader · error

Unsupported `TimeInForce` for Binance

Error message

Unsupported `TimeInForce` for Binance: {value:?}

What it means

This is the TryFrom<TimeInForce> conversion into Binance's native TimeInForce enum. Binance supports Gtc, Ioc, Fok, and Gtd; any other Nautilus TimeInForce variant (e.g. AtTheClose, Day) has no Binance equivalent, so the conversion bails with the unsupported value's debug representation.

Solutions

  1. Use only Gtc, Ioc, Fok, or Gtd when placing Binance orders.
  2. Clamp or map unsupported TIF values before submission (e.g. AtTheClose -> Gtc, or reject the order at strategy level).
  3. Add venue filtering so orders with non-Binance TIF values are not routed to Binance.
  4. Match order type to TIF: e.g. use Gtd with an explicit expire time instead of venue-specific closing-auction TIFs.

Example fix

// before
let tif = BinanceTimeInForce::try_from(order.time_in_force)?; // bails on AtTheClose
// after
let tif = match order.time_in_force {
    TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok | TimeInForce::Gtd =>
        BinanceTimeInForce::try_from(order.time_in_force)?,
    other => anyhow::bail!("Binance does not support {:?}; adjust strategy", other),
};
Defensive patterns

Strategy: validation

Validate before calling

const BINANCE_TIF: [TimeInForce; 4] =
    [TimeInForce::Gtc, TimeInForce::Ioc, TimeInForce::Fok, TimeInForce::Gtd];
assert!(BINANCE_TIF.contains(&order.time_in_force), "unsupported TIF for Binance");

Type guard

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

Try / catch

match BinanceTimeInForce::try_from(order.time_in_force) {
    Ok(tif) => submit_with(tif),
    Err(e) if e.to_string().contains("Unsupported `TimeInForce`") =>
        reject_order(&order, "venue does not support this time in force"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Submitting or translating an order whose TimeInForce is not Gtc/Ioc/Fok/Gtd — e.g. an order with TimeInForce::AtTheClose or an all-or-none persistence variant reaching the Binance order-encoding path.

Common situations: Routing multi-venue strategies to Binance where orders were constructed for another venue's semantics (e.g. Betfair AtTheClose); copying order templates with venue-specific TIF values; strategy code setting TIF without checking venue support.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/common/enums.rs:401

    /// Good till date.
    Gtd,
    /// Request-for-quote interactive (USD-M Futures).
    Rpi,
    /// Unknown or undocumented value.
    #[serde(other)]
    Unknown,
}

impl TryFrom<TimeInForce> for BinanceTimeInForce {
    type Error = anyhow::Error;

    fn try_from(value: TimeInForce) -> Result<Self, Self::Error> {
        match value {
            TimeInForce::Gtc => Ok(Self::Gtc),
            TimeInForce::Ioc => Ok(Self::Ioc),
            TimeInForce::Fok => Ok(Self::Fok),
            TimeInForce::Gtd => Ok(Self::Gtd),
            _ => anyhow::bail!("Unsupported `TimeInForce` for Binance: {value:?}"),
        }
    }
}

/// Income type for account income history.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum BinanceIncomeType {
    /// Internal transfers.
    Transfer,
    /// Welcome bonus.
    WelcomeBonus,
    /// Realized profit and loss.
    RealizedPnl,
    /// Funding fee payments/receipts.
    FundingFee,
    /// Trading commission.
    Commission,

View on GitHub (pinned to 18893faf8b)