{"record":{"id":"f6a04049ab584595","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-goodtilldate-must-be-smaller-than","errorCode":null,"errorMessage":"Binance Futures goodTillDate must be smaller than {BINANCE_GTD_MAX_MILLIS}","messagePattern":"Binance Futures goodTillDate must be smaller than (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/execution.rs","lineNumber":1203,"sourceCode":"\n    let expire_time = expire_time.context(\"Binance Futures GTD requires an expire_time\")?;\n    let expire_ns = expire_time.as_u64();\n    anyhow::ensure!(\n        expire_ns.is_multiple_of(NANOSECONDS_IN_SECOND),\n        \"Binance Futures goodTillDate requires whole-second precision\"\n    );\n\n    let minimum_ns = ts_now\n        .as_u64()\n        .checked_add(BINANCE_GTD_MIN_LEAD_SECS * NANOSECONDS_IN_SECOND)\n        .context(\"Binance Futures GTD minimum timestamp overflow\")?;\n    anyhow::ensure!(\n        expire_ns > minimum_ns,\n        \"Binance Futures goodTillDate must be strictly greater than current time plus {BINANCE_GTD_MIN_LEAD_SECS} seconds\"\n    );\n\n    let good_till_date = expire_ns / NANOSECONDS_IN_MILLISECOND;\n    anyhow::ensure!(\n        good_till_date < BINANCE_GTD_MAX_MILLIS,\n        \"Binance Futures goodTillDate must be smaller than {BINANCE_GTD_MAX_MILLIS}\"\n    );\n\n    Ok(FuturesOrderLifetime {\n        time_in_force,\n        good_till_date: Some(i64::try_from(good_till_date)?),\n    })\n}\n\nfn is_grouped_order(order: &OrderAny) -> bool {\n    matches!(\n        order.contingency_type(),\n        Some(contingency_type) if contingency_type != ContingencyType::NoContingency\n    ) || order\n        .linked_order_ids()\n        .is_some_and(|linked_order_ids| !linked_order_ids.is_empty())\n}","sourceCodeStart":1185,"sourceCodeEnd":1221,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/execution.rs#L1185-L1221","documentation":"Binance caps goodTillDate below the maximum representable exchange timestamp: the millisecond value must stay under BINANCE_GTD_MAX_MILLIS = 253_402_300_799_000 (execution.rs:141), i.e. before 9999-12-31T23:59:59Z. The client converts the whole-second expiry to milliseconds and rejects anything at or beyond the cap before sending, avoiding a venue-side parse failure.","triggerScenarios":"Submitting a GTD order whose expire_time corresponds to a year >= 10000 — e.g. an expiry accidentally built in microseconds/milliseconds instead of nanoseconds (making it astronomically large), or a sentinel 'far future' value like u64::MAX/i64::MAX passed as the expiry.","commonSituations":"Unit confusion when constructing UnixNanos from ms/us values; 'never expire' sentinels expressed as max integers instead of GTC; date libraries defaulting to far-future dates on parse errors.","solutions":["Use a realistic expiry date (same day/session horizon) instead of a far-future sentinel","For 'no expiry', submit GTC rather than a maximal goodTillDate","Verify the expire_time is in nanoseconds and within ordinary date ranges before submission"],"exampleFix":"// before\nlet expire = UnixNanos::from(4_102_444_800_000 * 1_000_000_000); // ms value treated as seconds -> year ~130000\n\n// after\nlet expire = UnixNanos::from(1_767_225_600 * 1_000_000_000); // 2026-01-01T00:00:00Z in ns","handlingStrategy":"validation","validationCode":"const MAX_GTD_MS: u64 = 253_402_300_799_000; // 9999-12-31T23:59:59Z\nlet gtd_ms = expire.as_u64() / 1_000_000;\nanyhow::ensure!(gtd_ms < MAX_GTD_MS, \"goodTillDate beyond exchange maximum\");","typeGuard":"fn within_gtd_max(expire_ns: u64) -> bool {\n    expire_ns / 1_000_000 < 253_402_300_799_000\n}","tryCatchPattern":null,"preventionTips":["Never use max-int sentinels for expiry; use GTC for no-expiry orders","Double-check unit (ns vs ms/us) whenever constructing UnixNanos from foreign timestamps","Bound expiry to a sane horizon (same day/week) in config validation"],"tags":["binance-futures","gtd","expire-time","max-timestamp","rust"],"backgroundTag":"good-till-date-validation","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}