{"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/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/enums.rs#L126-L162","documentation":"time_in_force_to_binance_spot accepts only GTC, IOC and FOK (plus GTD under the use_gtd downgrade rule). Binance Spot has no equivalent for other Nautilus TimeInForce variants such as DAY, AT_THE_OPEN or AT_THE_CLOSE, so the conversion bails for anything else.","triggerScenarios":"Submitting an order with any TimeInForce other than Gtc/Ioc/Fok/Gtd — e.g. TimeInForce::Day — through submit, modify or order-list paths that build venue params.","commonSituations":"Porting equity-style strategies that use DAY orders; sharing an order factory across venues where DAY is valid; typo'd or defaulted TIF fields from config files.","solutions":["Use GTC (open-ended), IOC or FOK on Binance Spot","Map DAY semantics to GTC plus a strategy-side cancellation at session end","Pre-validate time_in_force against the supported set before creating orders"],"exampleFix":"# before\norder = self.order_factory.limit(..., time_in_force=TimeInForce.DAY)\n\n# after\norder = self.order_factory.limit(..., time_in_force=TimeInForce.GTC)\n# strategy cancels remaining quantity at session end","handlingStrategy":"type-guard","validationCode":"fn ensure_supported_spot_tif(tif: TimeInForce) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok),\n        \"time in force {tif:?} is not available on Binance Spot\"\n    );\n    Ok(())\n}","typeGuard":"fn is_supported_binance_spot_tif(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok)\n}","tryCatchPattern":"match submit_order(cmd) {\n    Err(e) if e.to_string().contains(\"Unsupported time in force for Binance Spot\") => {\n        self.emitter.emit_order_denied(&order, &e.to_string());\n    }\n    other => other?,\n}","preventionTips":["Default shared order factories to GTC unless the venue supports the requested TIF","Map DAY to GTC with a session-end cancel at the strategy layer","Unit-test order specs against the venue's supported enum set before deploying"],"tags":["binance","spot","time-in-force","execution","validation"],"backgroundTag":"unsupported-time-in-force","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}