{"record":{"id":"c6b6833cc8f3aeda","repo":"nautechsystems/nautilus_trader","slug":"unsupported-time-in-force-for-binance-spot-tif","errorCode":null,"errorMessage":"Unsupported time in force for Binance Spot: {tif:?}","messagePattern":"Unsupported time in force for Binance Spot: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/enums.rs","lineNumber":144,"sourceCode":"/// Returns an error if the time in force is not supported on Binance Spot.\npub fn time_in_force_to_binance_spot(\n    tif: TimeInForce,\n    use_gtd: bool,\n) -> anyhow::Result<BinanceTimeInForce> {\n    match tif {\n        TimeInForce::Gtc => Ok(BinanceTimeInForce::Gtc),\n        TimeInForce::Ioc => Ok(BinanceTimeInForce::Ioc),\n        TimeInForce::Fok => Ok(BinanceTimeInForce::Fok),\n        TimeInForce::Gtd if !use_gtd => {\n            log::warn!(\n                \"Binance Spot does not support GTD; submitting as GTC because use_gtd=false. Enable manage_gtd_expiry on the submitting strategy\"\n            );\n            Ok(BinanceTimeInForce::Gtc)\n        }\n        TimeInForce::Gtd => anyhow::bail!(\n            \"Binance Spot does not support native GTD; set use_gtd=false and enable manage_gtd_expiry on the submitting strategy\"\n        ),\n        _ => anyhow::bail!(\"Unsupported time in force for Binance Spot: {tif:?}\"),\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;\n\n    use super::*;\n\n    #[rstest]\n    #[case(OrderType::Market, false, BinanceSpotOrderType::Market)]\n    #[case(OrderType::Limit, false, BinanceSpotOrderType::Limit)]\n    #[case(OrderType::Limit, true, BinanceSpotOrderType::LimitMaker)]\n    #[case(OrderType::StopMarket, false, BinanceSpotOrderType::StopLoss)]\n    #[case(OrderType::StopLimit, false, BinanceSpotOrderType::StopLossLimit)]\n    #[case(OrderType::MarketIfTouched, false, BinanceSpotOrderType::TakeProfit)]\n    #[case(\n        OrderType::LimitIfTouched,","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/enums.rs#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the order's time_in_force to TimeInForce::Gtc before submitting to Binance Spot","Check which TIF the adapter maps (Gtc) and pre-validate order TIF in the strategy's submit path","If GTD semantics are needed, use the supported GTD path: set use_gtd=false and enable manage_gtd_expiry on the strategy","If IOC/FOK is required, use the Binance Futures adapter, which supports those TIFs"],"exampleFix":"// before\nlet order = order_factory.limit(\n    instrument_id, Side::Buy, qty, price,\n    TimeInForce::Ioc, None, None,\n);\n// after\nlet order = order_factory.limit(\n    instrument_id, Side::Buy, qty, price,\n    TimeInForce::Gtc, None, None,\n);","handlingStrategy":"validation","validationCode":"fn is_spot_tif_supported(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Gtd)\n}","typeGuard":null,"tryCatchPattern":"match time_in_force_to_binance_spot(order.time_in_force()) {\n    Ok(tif) => { /* proceed */ }\n    Err(e) => log::error!(\"TIF unsupported for Binance Spot: {e}\"),\n}","preventionTips":["Default order factories to TimeInForce::Gtc for Binance Spot","Map strategy execution semantics (IOC/FOK) to supported venues, not Spot","Use manage_gtd_expiry for GTD needs instead of native GTD"],"tags":["binance","spot","time-in-force","unsupported-enum-value","adapter"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}