{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/enums.rs","lineNumber":401,"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":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/enums.rs#L383-L419","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use only Gtc, Ioc, Fok, or Gtd when placing Binance orders.","Clamp or map unsupported TIF values before submission (e.g. AtTheClose -> Gtc, or reject the order at strategy level).","Add venue filtering so orders with non-Binance TIF values are not routed to Binance.","Match order type to TIF: e.g. use Gtd with an explicit expire time instead of venue-specific closing-auction TIFs."],"exampleFix":"// before\nlet tif = BinanceTimeInForce::try_from(order.time_in_force)?; // bails on AtTheClose\n// after\nlet tif = match order.time_in_force {\n    TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok | TimeInForce::Gtd =>\n        BinanceTimeInForce::try_from(order.time_in_force)?,\n    other => anyhow::bail!(\"Binance does not support {:?}; adjust strategy\", other),\n};","handlingStrategy":"validation","validationCode":"const BINANCE_TIF: [TimeInForce; 4] =\n    [TimeInForce::Gtc, TimeInForce::Ioc, TimeInForce::Fok, TimeInForce::Gtd];\nassert!(BINANCE_TIF.contains(&order.time_in_force), \"unsupported TIF for Binance\");","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) => submit_with(tif),\n    Err(e) if e.to_string().contains(\"Unsupported `TimeInForce`\") =>\n        reject_order(&order, \"venue does not support this time in force\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Validate TIF against the venue before routing orders in a multi-venue strategy.","Restrict strategy config to venue-supported TIF values for Binance accounts.","Add a routing filter that drops or remaps AtTheClose/Day-style TIFs before they reach the Binance encoder."],"tags":["binance","time-in-force","enum-conversion","order-management","rust"],"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"}