{"record":{"id":"7a95bf9302ccac16","repo":"nautechsystems/nautilus_trader","slug":"start-was-end","errorCode":null,"errorMessage":"start was > end","messagePattern":"start was > end","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/backtest/src/engine.rs","lineNumber":763,"sourceCode":"                let missing_book_data = !self.has_book_data.contains(instrument_id)\n                    && !self.has_book_processed.contains(instrument_id);\n\n                if has_data && missing_book_data {\n                    anyhow::bail!(\n                        \"No order book data found for instrument '{instrument_id}' when `book_type` \\\n                         is '{:?}'. Set the venue `book_type` to 'L1_MBP' (for top-of-book data \\\n                         like quotes, trades, and bars) or provide order book data for this \\\n                         instrument.\",\n                        exchange.book_type()\n                    );\n                }\n            }\n        }\n\n        // Determine time boundaries\n        let start_ns = start.unwrap_or_else(|| self.ts_first.unwrap_or_default());\n        let end_ns = end.unwrap_or_else(|| self.ts_last_data.unwrap_or(start_ns));\n        anyhow::ensure!(start_ns <= end_ns, \"start was > end\");\n        self.end_ns = end_ns;\n        self.last_ns = start_ns;\n        self.last_module_ns = None;\n\n        // Set all component clocks to start\n        let clocks = self.collect_all_clocks();\n        Self::set_all_clocks_time(&clocks, start_ns);\n\n        // First-iteration initialization\n        if self.iteration == 0 {\n            self.set_instrument_expiration_timers()?;\n\n            self.run_config_id = run_config_id;\n            self.run_id = Some(UUID4::new());\n            self.run_started = Some(UnixNanos::from(nanos_since_unix_epoch()));\n            self.backtest_start = Some(start_ns);\n\n            for exchange in self.venues.values() {","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/engine.rs#L745-L781","documentation":"run_impl derives the simulation window: start_ns defaults to the first event timestamp and end_ns to the last data timestamp (or start). If the resolved start is greater than end — typically because explicit start/end arguments are inverted or fall outside the data range — the engine refuses to run with this bare message.","triggerScenarios":"engine.run(start=Some(later_ns), end=Some(earlier_ns)) with an inverted range, or start beyond ts_last_data while ts_first/ts_last defaults resolve end before start.","commonSituations":"Swapped start/end parameters (ms vs ns confusion aside, simply reversed); a run window entirely after the loaded data's last timestamp; computing bounds from config with the wrong variable order.","solutions":["Swap the start/end arguments so start <= end.","Verify your configured window actually overlaps the timestamps of the data added to the engine.","Check unit conversion (seconds vs milliseconds vs nanoseconds) when computing start/end UnixNanos values."],"exampleFix":"// before\nengine.run(Some(UnixNanos::from(end_ms)), Some(UnixNanos::from(start_ms)), None, false);\n// after\nengine.run(Some(UnixNanos::from(start_ms)), Some(UnixNanos::from(end_ms)), None, false);","handlingStrategy":"validation","validationCode":"if let (Some(s), Some(e)) = (start, end) {\n    assert!(s <= e, \"run window invalid: start {s} > end {e}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the configured run window (start <= end) in your config loader.","Confirm the window overlaps the data's first/last timestamps.","Beware unit confusion (ms vs ns) when building UnixNanos bounds."],"tags":["rust","backtest","time-range","validation"],"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-14T05:17:10.506Z"}