{"record":{"id":"65bce500e78524e1","repo":"nautechsystems/nautilus_trader","slug":"unsupported-timeinforce-for-binance-value","errorCode":null,"errorMessage":"Unsupported `TimeInForce` for Binance: {value:?}","messagePattern":"Unsupported `TimeInForce` for Binance: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/enums.rs","lineNumber":402,"sourceCode":"    /// Good till date.\n    Gtd,\n    /// Request-for-quote interactive (USD-M Futures).\n    Rpi,\n    /// Unknown or undocumented value.\n    #[serde(other)]\n    Unknown,\n}\n\nimpl TryFrom<TimeInForce> for BinanceTimeInForce {\n    type Error = anyhow::Error;\n\n    fn try_from(value: TimeInForce) -> Result<Self, Self::Error> {\n        match value {\n            TimeInForce::Gtc => Ok(Self::Gtc),\n            TimeInForce::Ioc => Ok(Self::Ioc),\n            TimeInForce::Fok => Ok(Self::Fok),\n            TimeInForce::Gtd => Ok(Self::Gtd),\n            _ => anyhow::bail!(\"Unsupported `TimeInForce` for Binance: {value:?}\"),\n        }\n    }\n}\n\n/// Income type for account income history.\n#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]\n#[serde(rename_all = \"SCREAMING_SNAKE_CASE\")]\npub enum BinanceIncomeType {\n    /// Internal transfers.\n    Transfer,\n    /// Welcome bonus.\n    WelcomeBonus,\n    /// Realized profit and loss.\n    RealizedPnl,\n    /// Funding fee payments/receipts.\n    FundingFee,\n    /// Trading commission.\n    Commission,","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/common/enums.rs#L384-L420","documentation":"Converting a NautilusTrader TimeInForce to BinanceTimeInForce supports only Gtc, Ioc, Fok and Gtd - the four time-in-force modes the Binance API accepts. Any other TIF variant (e.g. AtTheClose or Day) makes the TryFrom conversion fail during order encoding.","triggerScenarios":"Submitting to a Binance execution client an order with TimeInForce other than GTC/IOC/FOK/GTD - most commonly AtTheClose (used by venues like Betfair) or Day carried over from multi-venue strategy code.","commonSituations":"Strategies parameterized per-venue without per-venue TIF mapping; porting configs from equities/betting exchanges; default TIF changed in shared strategy code.","solutions":["Map the order's time_in_force to Gtc, Ioc, Fok or Gtd for Binance venues before submission","For GTD confirm the expiry time is also provided as Binance requires","Add a per-venue TIF translation in your strategy factory so unsupported values never reach the encoder"],"exampleFix":"# before (shared config)\ntime_in_force = \"AT_THE_CLOSE\"\n\n# after (binance venue config)\ntime_in_force = \"GTC\"  # or IOC / FOK / GTD","handlingStrategy":"type-guard","validationCode":"fn is_binance_supported_tif(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok | TimeInForce::Gtd)\n}","typeGuard":"fn is_binance_supported_tif(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok | TimeInForce::Gtd)\n}","tryCatchPattern":"match BinanceTimeInForce::try_from(order.time_in_force()) {\n    Ok(tif) => encode_order(order, tif),\n    Err(_) => log::error!(\"TIF {:?} not supported on Binance - remap to GTC or route elsewhere\", order.time_in_force()),\n}","preventionTips":["Add venue-specific TIF mapping in strategy config instead of one global TIF","Test submissions against Binance testnet when porting strategies between venue types","Remember GTD on Binance also requires an expiry time - validate both together"],"tags":["binance","time-in-force","enum-conversion","validation","order-submission"],"backgroundTag":"unsupported-enum-value","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}