{"record":{"id":"16f87f90e25ab18b","repo":"nautechsystems/nautilus_trader","slug":"execution-timestamp-time-str-is-non-existent-i","errorCode":null,"errorMessage":"Execution timestamp '{time_str}' is non-existent in timezone '{tz_str}'","messagePattern":"Execution timestamp '(.+?)' is non-existent in timezone '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/parse.rs","lineNumber":451,"sourceCode":"fn localize_with_zone(dt: DateTime, tz_str: &str, time_str: &str) -> anyhow::Result<Timestamp> {\n    let tz_name = if tz_str.eq_ignore_ascii_case(\"Z\") {\n        \"UTC\"\n    } else {\n        tz_str\n    };\n\n    let zone = get_timezone(tz_name).map_err(|_| {\n        anyhow::anyhow!(\n            \"Unrecognized execution timezone '{tz_str}' in '{time_str}'. Configure TWS / IB Gateway to emit a standard timezone (e.g. UTC)\"\n        )\n    })?;\n    let ambiguous = zone.to_ambiguous_timestamp(dt);\n    match ambiguous.offset() {\n        AmbiguousOffset::Unambiguous { .. } => Ok(ambiguous.unambiguous()?),\n        // Fall-back fold: take the earliest instant (worst case ~1h skew).\n        AmbiguousOffset::Fold { .. } => Ok(ambiguous.earlier()?),\n        AmbiguousOffset::Gap { .. } => {\n            anyhow::bail!(\"Execution timestamp '{time_str}' is non-existent in timezone '{tz_str}'\")\n        }\n    }\n}\n\nfn datetime_to_unix_nanos(dt: Timestamp, time_str: &str) -> anyhow::Result<UnixNanos> {\n    let nanos: u64 = dt\n        .as_nanosecond()\n        .try_into()\n        .map_err(|_| anyhow::anyhow!(\"Execution timestamp '{time_str}' was before Unix epoch\"))?;\n    Ok(UnixNanos::new(nanos))\n}\n\n#[cfg(test)]\nmod tests {\n    use ibapi::{\n        contracts::Contract,\n        orders::{Action, ExecutionSide, Liquidity, Order, OrderStatusKind},\n    };","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/parse.rs#L433-L469","documentation":"After parsing the naive datetime, the adapter localizes it into the requested timezone. If that local time falls inside a DST gap (a wall-clock time that never existed because clocks jumped forward), the localization is ambiguous in the impossible direction and the adapter raises this error rather than inventing an instant. Ambiguous (repeated) times are handled by taking the earliest instant, but gap times are rejected.","triggerScenarios":"parse_execution_time receives a timestamp whose date/time falls inside a spring-forward DST gap in tz_str — e.g. '20260308 02:30:00 America/New_York', where 02:00–03:00 local does not exist on the DST transition day.","commonSituations":"Backtests or fill reports containing timestamps recorded during the skipped hour of a DST transition; clocks or systems misconfigured so reported times land in the nonexistent hour; data generated in a fixed-offset timezone then reinterpreted in an IANA zone.","solutions":["Correct the source timestamp — it cannot exist in that timezone; check for clock/offset errors in the reporting system.","If the timestamp is known to be in a fixed offset (e.g. exchange local time), parse with that fixed offset instead of an IANA zone with DST.","Adjust the time by one hour (gap durations are typically 1h) if you know the intended instant.","Handle this error at the call site by skipping or re-anchoring the affected fill record."],"exampleFix":"// before: nonexistent local time in DST gap\nparse_execution_time(\"20260308 02:30:00 America/New_York\")?; // Err: non-existent\n// after: use the post-transition equivalent instant\nparse_execution_time(\"20260308 03:30:00 America/New_York\")?;","handlingStrategy":"try-catch","validationCode":"fn is_dst_gap(ts: &str, tz: &str) -> bool {\n    // Heuristic: if shifting the local time forward by 1h changes the UTC offset,\n    // the original time was likely inside a DST gap. Precheck before parsing.\n    // (Verify with a tz database such as chrono-tz / jiff.)\n    false // implement with your tz library of choice\n}","typeGuard":null,"tryCatchPattern":"match parse_execution_time(time_str) {\n    Err(e) if e.to_string().contains(\"is non-existent in timezone\") => {\n        // DST gap: retry with time advanced past the gap or parsed in a fixed offset\n        let corrected = bump_past_gap(time_str);\n        parse_execution_time(&corrected)?\n    }\n    other => other?,\n}","preventionTips":["Do not generate timestamps inside the 02:00–03:00 local window on DST transition days","Prefer fixed-offset parsing for exchange-local times that have no DST","Store and compare instants in UTC; convert to local time only for display","Test timestamp handling around each year's DST transitions for your venue timezones"],"tags":["timezone","dst","timestamp","parsing"],"backgroundTag":"nonexistent-dst-timestamp","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"}