{"record":{"id":"0c3a8ee1b319f899","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-aggregate-trade-history-is-limited","errorCode":null,"errorMessage":"Binance Futures aggregate trade history is limited to the past 24 hours","messagePattern":"Binance Futures aggregate trade history is limited to the past 24 hours","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/http/client.rs","lineNumber":2993,"sourceCode":"\n        Ok(result)\n    }\n\n    /// Requests bounded aggregate public trades for an instrument.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if a supplied time bound is invalid or parsing fails.\n    pub async fn request_agg_trades(\n        &self,\n        instrument_id: InstrumentId,\n        start: Option<Timestamp>,\n        end: Option<Timestamp>,\n        limit: Option<u32>,\n    ) -> anyhow::Result<Vec<TradeTick>> {\n        let cutoff =\n            self.clock.get_time_ns().to_datetime_utc() - jiff::SignedDuration::from_hours(24);\n        anyhow::ensure!(\n            start.as_ref().is_none_or(|value| value >= &cutoff)\n                && end.as_ref().is_none_or(|value| value >= &cutoff),\n            \"Binance Futures aggregate trade history is limited to the past 24 hours\"\n        );\n        let (symbol, price_precision, size_precision) =\n            self.cached_precisions_by_id(instrument_id)?;\n        let params = BinanceAggTradesParams {\n            symbol,\n            from_id: None,\n            start_time: start.map(|value| value.as_millisecond()),\n            end_time: end.map(|value| value.as_millisecond()),\n            limit,\n        };\n        let trades = self.inner.agg_trades(&params).await?;\n        trades\n            .iter()\n            .map(|trade| {\n                let ts_init = parse_millis(trade.time, \"Futures aggregate trade time\")?;","sourceCodeStart":2975,"sourceCodeEnd":3011,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/http/client.rs#L2975-L3011","documentation":"Binance Futures only serves aggTrades (aggregate trade) data for roughly the last 24 hours. The adapter checks the requested start/end timestamps against a 24-hour cutoff from the current clock time and rejects any request reaching further back.","triggerScenarios":"Requesting aggregate trade history (request_trades / aggTrades) with a start or end Timestamp older than 24 hours relative to now; omitting start but passing an old end also triggers it.","commonSituations":"Backfill jobs or backtests requesting historical trades from Binance Futures; assuming unlimited trade history like spot or data-vendor APIs; clock/timezone mistakes making timestamps appear older than 24h.","solutions":["Request only data within the last 24 hours (set start >= now - 24h)","Use a dedicated historical data vendor (e.g. Binance data dumps, Tardis, Nautilus data catalog) for older trades","Double-check the timestamps passed are in UTC and not stale cached values"],"exampleFix":"// before\nlet start = Timestamp::from(\"2024-01-01T00:00:00Z\"); // far in the past\n// after\nlet start = (now_utc() - Duration::hours(23)).into(); // within 24h window","handlingStrategy":"validation","validationCode":"let cutoff = now_utc() - chrono::Duration::hours(24);\nif let Some(start) = &start {\n    assert!(start.as_datetime() >= cutoff, \"start must be within last 24h\");\n}\nif let Some(end) = &end {\n    assert!(end.as_datetime() >= cutoff, \"end must be within last 24h\");\n}","typeGuard":null,"tryCatchPattern":"match client.request_trades(instrument_id, start, end, limit).await {\n    Ok(trades) => trades,\n    Err(e) if e.to_string().contains(\"limited to the past 24 hours\") => {\n        // switch to an archival data source\n        archival_provider.request_trades(instrument_id, start, end, limit).await\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Clamp start/end timestamps to now - 24h before requesting Binance Futures trades","Use an archival vendor or local data catalog for older history","Store Binance Futures trade data in real time if you need long history"],"tags":["binance","rate-limitation","time-range","futures"],"backgroundTag":"value-out-of-range","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"}