{"record":{"id":"7d987574194f15d7","repo":"nautechsystems/nautilus_trader","slug":"timestamp-overflow-for","errorCode":null,"errorMessage":"Timestamp overflow for {}","messagePattern":"Timestamp overflow for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/http/client.rs","lineNumber":1374,"sourceCode":"        let ticker = extract_raw_symbol(instrument_id.symbol.as_str());\n        let ts_init = self.generate_ts_init();\n\n        let response = self\n            .inner\n            .get_historical_funding(ticker, limit, None, end)\n            .await?;\n\n        let mut rates = Vec::with_capacity(response.historical_funding.len());\n\n        for entry in &response.historical_funding {\n            // Filter by start time if specified\n            if start.is_some_and(|s| entry.effective_at < s) {\n                continue;\n            }\n\n            let ts_event =\n                UnixNanos::from(u64::try_from(entry.effective_at.as_nanosecond()).map_err(\n                    |_| anyhow::anyhow!(\"Timestamp overflow for {}\", entry.effective_at),\n                )?);\n\n            rates.push(FundingRateUpdate::new(\n                instrument_id,\n                entry.rate,\n                Some(60),\n                None,\n                ts_event,\n                ts_init,\n            ));\n        }\n\n        // dYdX returns newest first; reverse to chronological order\n        rates.reverse();\n\n        log::debug!(\"Fetched {} funding rates for {instrument_id}\", rates.len(),);\n\n        Ok(rates)","sourceCodeStart":1356,"sourceCodeEnd":1392,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/http/client.rs#L1356-L1392","documentation":"request_funding_rates converts each funding entry's effective_at timestamp to UnixNanos (u64 nanoseconds). The error fires when u64::try_from on the nanosecond count fails — i.e. the timestamp is negative (pre-epoch) or exceeds u64 nanosecond range — so the funding rate update cannot be built.","triggerScenarios":"A funding entry whose effective_at is before the Unix epoch or absurdly far in the future, returned by the dYdX funding rates endpoint, during request_funding_rates.","commonSituations":"Upstream API change or malformed field returning zero/negative datetimes; timezone misparse producing pre-1970 timestamps; a bad DateTime parsed from the API with wrong precision assumptions.","solutions":["Inspect the raw funding response to see what effective_at values the API actually returns","Filter out entries with implausible effective_at values before conversion","Pin/upgrade the adapter version matching the current dYdV API datetime format","If it is a systematic format change, fix the deserialization of effective_at rather than the conversion"],"exampleFix":"// before\nlet ts_event = UnixNanos::from(u64::try_from(entry.effective_at.as_nanosecond())\n    .map_err(|_| anyhow::anyhow!(\"Timestamp overflow for {}\", entry.effective_at))?);\n// after\nif entry.effective_at < DateTime::default() { continue; } // skip invalid timestamps\nlet ts_event = UnixNanos::from(u64::try_from(entry.effective_at.as_nanosecond())\n    .map_err(|_| anyhow::anyhow!(\"Timestamp overflow for {}\", entry.effective_at))?);","handlingStrategy":"try-catch","validationCode":"if entry.effective_at < DateTime::UNIX_EPOCH {\n    log::warn!(\"skipping funding entry with pre-epoch timestamp\");\n    continue;\n}","typeGuard":"fn has_valid_timestamp(dt: &DateTime<Utc>) -> bool {\n    *dt >= DateTime::UNIX_EPOCH && u64::try_from(dt.as_nanosecond()).is_ok()\n}","tryCatchPattern":"let rates = match client.request_funding_rates(instrument_id, start, end).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"Timestamp overflow\") => {\n        log::warn!(\"bad funding timestamp from API, skipping batch: {e}\");\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["Validate API datetime fields at deserialization boundaries","Filter implausible timestamps before conversion to UnixNanos","Watch for dYdX API schema changes in funding payloads"],"tags":["dydx","timestamp","overflow","funding-rates"],"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-14T00:17:10.932Z"}