{"record":{"id":"6bb6107bdf84908d","repo":"nautechsystems/nautilus_trader","slug":"invalid-time-range-start-s-end-e","errorCode":null,"errorMessage":"Invalid time range: start={s:?} end={e:?}","messagePattern":"Invalid time range: start=(.+?) end=(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/http/client.rs","lineNumber":1266,"sourceCode":"        end: Option<Timestamp>,\n        limit: Option<u32>,\n    ) -> anyhow::Result<Vec<TradeTick>> {\n        // Get instrument from cache to determine precisions\n        let (price_precision, size_precision) =\n            if let Some(instrument) = self.get_instrument(&instrument_id.symbol.inner()) {\n                (instrument.price_precision(), instrument.size_precision())\n            } else {\n                log::warn!(\"Instrument {instrument_id} not in cache, skipping trades request\");\n                return Err(InstrumentLookupError::not_found(instrument_id).into());\n            };\n\n        // Convert timestamps to milliseconds\n        let now = Timestamp::now();\n        let end_dt = end.unwrap_or(now);\n        let start_dt = start.unwrap_or(end_dt - jiff::SignedDuration::from_hours(1));\n\n        if let (Some(s), Some(e)) = (start, end) {\n            anyhow::ensure!(s < e, \"Invalid time range: start={s:?} end={e:?}\");\n        }\n\n        let start_ms = start_dt.as_millisecond();\n        let end_ms = end_dt.as_millisecond();\n        let ts_init = self.generate_ts_init();\n        let mut all_trades = Vec::new();\n        let mut paginator = TradePaginator::new(start_ms, end_ms);\n\n        loop {\n            let params = GetLastTradesByInstrumentAndTimeParams::new(\n                instrument_id.symbol.to_string(),\n                paginator.cursor,\n                end_ms,\n                Some(DERIBIT_HISTORICAL_TRADES_MAX_COUNT),\n                Some(\"asc\".to_string()),\n            );\n\n            let full_response = self","sourceCodeStart":1248,"sourceCodeEnd":1284,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/http/client.rs#L1248-L1284","documentation":"request_trades validates that, when both start and end timestamps are supplied, start is strictly earlier than end. anyhow::ensure! raises this error otherwise. It is a caller-argument precondition, not a network problem.","triggerScenarios":"Calling request_trades with both start and end provided where start >= end — e.g. swapped arguments, passing the same timestamp for both, or computing end from start incorrectly.","commonSituations":"Reversed parameter order in a paging loop; using an inclusive 'latest trade time' from a previous request as end while it is already <= the new start; unit confusion producing identical epoch values.","solutions":["Reorder the arguments so start < end.","Default one bound to None and let the client fill it (end defaults to now, start defaults to end - 1 hour).","Add a caller-side check `s < e` before calling request_trades."],"exampleFix":"// before\nclient.request_trades(bar_type, end, start, None).await?;\n// after\nassert!(start < end, \"start must precede end\");\nclient.request_trades(bar_type, Some(start), Some(end), None).await?;","handlingStrategy":"validation","validationCode":"if let (Some(s), Some(e)) = (start, end) {\n    assert!(s < e, \"request_trades: start must be < end ({s:?} >= {e:?})\");\n}","typeGuard":null,"tryCatchPattern":"let (start, end) = (start.min(end), start.max(end));\nlet trades = client.request_trades(instrument_id, Some(start), Some(end), None).await?;","preventionTips":["Always construct the window as (t - lookback, t) so ordering is implicit","Never pass both bounds from independent sources without checking s < e","Let the client default unbounded sides instead of computing them manually"],"tags":["deribit","validation","time-range","arguments"],"backgroundTag":"invalid-argument-value","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"}