{"record":{"id":"24fa46e8b9936128","repo":"nautechsystems/nautilus_trader","slug":"timer-name-stop-time-must-be-after-start-ti","errorCode":null,"errorMessage":"Timer '{name}' stop time {} must be after start time {}","messagePattern":"Timer '(.+?)' stop time (.+?) must be after start time (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/clock.rs","lineNumber":870,"sourceCode":"\n    let next_event_time = if fire_immediately {\n        start_time_ns\n    } else {\n        start_time_ns.checked_add(interval_ns).ok_or_else(|| {\n            anyhow::anyhow!(\"Timer '{name}' first event time exceeds UnixNanos range\")\n        })?\n    };\n\n    if !allow_past && next_event_time < ts_now {\n        anyhow::bail!(\n            \"Timer '{name}' next event time {} would be in the past (current time is {ts_now})\",\n            next_event_time.to_rfc3339(),\n        );\n    }\n\n    if let Some(stop_time) = stop_time_ns {\n        if stop_time <= start_time_ns {\n            anyhow::bail!(\n                \"Timer '{name}' stop time {} must be after start time {}\",\n                stop_time.to_rfc3339(),\n                start_time_ns.to_rfc3339(),\n            );\n        }\n\n        if !allow_past && stop_time <= ts_now {\n            anyhow::bail!(\n                \"Timer '{name}' stop time {} is in the past (current time is {ts_now})\",\n                stop_time.to_rfc3339(),\n            );\n        }\n    }\n\n    Ok((\n        name,\n        start_time_ns,\n        stop_time_ns,","sourceCodeStart":852,"sourceCodeEnd":888,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/clock.rs#L852-L888","documentation":"set_timer_ns supports an optional stop_time_ns that terminates the timer. Validation requires the stop time to be strictly after the start time; if stop_time <= start_time_ns the timer would stop before or exactly when it begins, which is contradictory, so the call fails.","triggerScenarios":"Calling set_timer_ns with Some(stop_time_ns) that is less than or equal to start_time_ns.","commonSituations":"Off-by-one or unit mix-ups (seconds vs nanoseconds when computing stop = start + duration); copying a stop time from a different schedule; config where stop time was authored for a different start time.","solutions":["Ensure stop_time_ns > start_time_ns, e.g. stop = start + planned_duration_ns, before calling set_timer_ns.","Check unit conversion: Nautilus times are Unix nanoseconds; multiply seconds by 1_000_000_000.","Guard the computation: bail or warn in your code if stop_time_ns <= start_time_ns and drop the stop_time (pass None) for an unbounded timer.","Correct the strategy/session config so the stop deadline postdates the start."],"exampleFix":"// before\nlet stop = start_time_ns; // wrong: equals start\nclock.set_timer_ns(\"t\", interval_ns, start_time_ns, Some(stop), None, false, false);\n// after\nlet stop = start_time_ns + duration_ns; // must be > start\nclock.set_timer_ns(\"t\", interval_ns, start_time_ns, Some(stop), None, false, false);","handlingStrategy":"validation","validationCode":"fn ensure_stop_after_start(start_time_ns: u64, stop_time_ns: Option<u64>) -> anyhow::Result<()> {\n    if let Some(stop) = stop_time_ns {\n        anyhow::ensure!(stop > start_time_ns, \"stop {stop} must be after start {start_time_ns}\");\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match clock.set_timer_ns(name, interval_ns, start, stop, None, false, false) {\n    Err(e) if e.to_string().contains(\"must be after start time\") => {\n        log::error!(\"bad timer config: {e}\");\n        // fix config or pass None for unbounded timer\n    }\n    other => other?,\n}","preventionTips":["Compute stop = start + duration_ns in nanoseconds; double-check unit conversions","Unit-test timer schedules with their start/stop relationships","Validate strategy config stop deadlines exceed start times before registration"],"tags":["timer","clock","validation","argument-order"],"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"}