From ae61e44b54eb06dfa2a57a4a962d405b0d13005f Mon Sep 17 00:00:00 2001 From: Ryan <64923468+IrishNova@users.noreply.github.com> Date: Mon, 23 Jun 2025 16:41:54 -0500 Subject: [PATCH] Fix timezone handling in TradingDayOfWeekRule Apply normalize() to session labels in both TradingDayOfWeekRule and TradingDayOfMonthRule to resolve 'YYYY-mm-dd HH:mm:ss+00:00 is not a trading minute' error when using week_start() and week_end() date_rules. The fix adds .normalize() before .value to strip timezone information from session labels, ensuring they match the expected midnight UTC format. Changes: - Line 484: Add .normalize() to TradingDayOfWeekRule.should_trigger() - Line 530: Add .normalize() to TradingDayOfMonthRule.should_trigger() Fixes #2860 --- zipline/utils/events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zipline/utils/events.py b/zipline/utils/events.py index d09c2b08df..4f8776f3eb 100644 --- a/zipline/utils/events.py +++ b/zipline/utils/events.py @@ -481,7 +481,7 @@ def __init__(self, n, invert): def should_trigger(self, dt): # is this market minute's period in the list of execution periods? - val = self.cal.minute_to_session_label(dt, direction="none").value + val = self.cal.minute_to_session_label(dt, direction="none").normalize().value return val in self.execution_period_values @lazyval @@ -527,7 +527,7 @@ def __init__(self, n, invert): def should_trigger(self, dt): # is this market minute's period in the list of execution periods? - value = self.cal.minute_to_session_label(dt, direction="none").value + value = self.cal.minute_to_session_label(dt, direction="none").normalize().value return value in self.execution_period_values @lazyval