Skip to content

Commit 20cbe68

Browse files
authored
Merge branch 'dev' into nse-calendar-overhaul
2 parents 9af1144 + 2b2dcb9 commit 20cbe68

17 files changed

Lines changed: 437 additions & 15 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Issue 477 CME Equity Market Pause Plan
2+
3+
## Current Step
4+
5+
4. Run focused plus full validation. Completed.
6+
7+
## Plan
8+
9+
1. Reproduce the obsolete post-cutover pause and confirm the historical boundary. Completed.
10+
2. Add focused schedule, open-state, and intraday-grid regression tests around the cutover. Completed.
11+
3. Add a date-effective CME equity-hours transition that preserves the pre-2021 pause. Completed.
12+
4. Run focused plus full validation. Completed.
13+
14+
## Assumptions
15+
16+
- CME's June 2021 Globex notice is authoritative for the June 28, 2021 trade-date cutover.
17+
- Historical sessions before the cutover must retain the 15:15-15:30 CT pause.
18+
- A zero-length break at the former 15:15 CT pause boundary preserves the established schedule schema without
19+
removing any tradable time.
20+
21+
## Validation
22+
23+
- The two new regression tests failed before the implementation and passed afterward.
24+
- Focused CME equity and source tests: 25 passed.
25+
- Fast suite: 1492 passed and 1 failed; the only failure was the existing timezone-sensitive
26+
`test_valid_days_tz_aware` NYSE baseline already documented on `dev`.
27+
- Ruff lint and format checks passed for all changed Python files.
28+
- `git diff --check` passed with CRLF treated as a valid line ending.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Issue 484 TASE Monday-Friday Trading Week Plan
2+
3+
## Current Step
4+
5+
5. Run the TASE tests, the full fast suite, and the formatter checks. Completed.
6+
7+
## Plan
8+
9+
1. Confirm the trading week change (Sunday-Thursday to Monday-Friday effective 2026-01-05, last Sunday session 2026-01-04) and the 2026 closure dates against the exchange schedule, and cross-check both against the upstream `exchange_calendars` XTAE calendar. Completed.
10+
2. Change the weekmask to Monday-Friday and handle the crossover in `valid_days`, following the NYSE pre/post-1952 Saturday pattern so pre-2026 schedules are unchanged. Completed.
11+
3. Add the 2026 and 2027 closures to `TASEClosedDay` (the list ended at 2025-10-14). Completed.
12+
4. Add the Friday 13:34 early close through `special_closes` with the weekday form. Completed.
13+
5. Add native TASE tests (`tests/test_tase_calendar.py`), run the full fast suite, and run ruff format and check. Completed.
14+
15+
## Assumptions
16+
17+
- The exchange's published schedule is authoritative: Monday-Friday trading from 2026-01-05, Friday sessions 9:59-13:34, and a Friday before a Sunday holiday or holiday eve is closed.
18+
- The 2027 closures follow the same rules; election days or other one-off closures are added when announced.
19+
- The regular Monday-Thursday close time (15:59) is left as is; it predates this change and is noted in the issue.
20+
21+
## Validation
22+
23+
- `tests/test_tase_calendar.py`: 6 passed.
24+
- Full fast suite on the `dev` base: 1497 passed.
25+
- 2026-2027 session sets identical to the upstream `exchange_calendars` XTAE calendar (492 sessions each, no differences).
26+
- 2019-2025 schedule output hash-identical to the unmodified branch.
27+
- Ruff format and check passed for the changed Python files.

‎pandas_market_calendars/calendars/bse.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@
378378
Timestamp("2023-11-14", tz="UTC"), # Tue, Diwali
379379
Timestamp("2023-11-27", tz="UTC"), # Mon, Guru Nanak's Birthday
380380
Timestamp("2023-12-25", tz="UTC"), # Mon, Christmas
381+
Timestamp("2024-01-22", tz="UTC"), # Mon, Ram Mandir Pran Pratishtha ceremony
381382
Timestamp("2024-01-26", tz="UTC"), # Fri, Republic Day
382383
Timestamp("2024-03-08", tz="UTC"), # Fri, Mahashivratri
383384
Timestamp("2024-03-25", tz="UTC"), # Mon, Holi
@@ -392,6 +393,7 @@
392393
Timestamp("2024-10-02", tz="UTC"), # Wed, Mahatma Gandhi Jayanti
393394
Timestamp("2024-11-01", tz="UTC"), # Fri, Diwali
394395
Timestamp("2024-11-15", tz="UTC"), # Fri, Guru Nanak's Birthday
396+
Timestamp("2024-11-20", tz="UTC"), # Wed, Maharashtra Assembly Elections
395397
Timestamp("2024-12-25", tz="UTC"), # Wed, Christmas
396398
Timestamp("2025-02-26", tz="UTC"), # Wed, Mahashivratri
397399
Timestamp("2025-03-14", tz="UTC"), # Fri, Holi
@@ -407,6 +409,7 @@
407409
Timestamp("2025-10-22", tz="UTC"), # Wed, Balipratipada
408410
Timestamp("2025-11-05", tz="UTC"), # Wed, Prakash Gurpurb Sri Guru Nanak Dev
409411
Timestamp("2025-12-25", tz="UTC"), # Thu, Christmas
412+
Timestamp("2026-01-15", tz="UTC"), # Thu, Maharashtra Municipal Elections
410413
Timestamp("2026-01-26", tz="UTC"), # Mon, Republic Day
411414
Timestamp("2026-03-03", tz="UTC"), # Tue, Holi
412415
Timestamp("2026-03-26", tz="UTC"), # Thu, Shri Ram Navami

‎pandas_market_calendars/calendars/cme.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
CME_EQUITY_LEGACY_HOURS_START = "2005-09-12"
6262
CME_EQUITY_MODERN_HOURS_START = "2012-11-19"
63+
CME_EQUITY_MARKET_PAUSE_END = "2021-06-28"
6364

6465

6566
class CMETradeDateCalendar(MarketCalendar):
@@ -117,7 +118,8 @@ class CMEEquityExchangeCalendar(MarketCalendar):
117118
118119
Open Time: 5:00 PM, America/Chicago
119120
Close Time: 4:00 PM, America/Chicago
120-
Break: 3:15 - 3:30pm America/Chicago
121+
Market pause through June 25, 2021: 3:15 - 3:30pm America/Chicago
122+
No intraday pause from trade date June 28, 2021
121123
"""
122124

123125
aliases = ["CME_Equity", "CBOT_Equity"]
@@ -141,6 +143,8 @@ class CMEEquityExchangeCalendar(MarketCalendar):
141143
(None, time(15, 30)),
142144
(CME_EQUITY_LEGACY_HOURS_START, time(15, 15)),
143145
(CME_EQUITY_MODERN_HOURS_START, time(15, 30)),
146+
# Preserve the schedule columns while representing continuous trading.
147+
(CME_EQUITY_MARKET_PAUSE_END, time(15, 15)),
144148
),
145149
}
146150

‎pandas_market_calendars/calendars/hkex.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ def process_queen_birthday(dt: Any) -> Any:
354354
Timestamp("2023-07-17", tz="UTC"), # Typhoon closure
355355
Timestamp("2023-09-01", tz="UTC"), # Typhoon closure
356356
Timestamp("2023-09-08", tz="UTC"), # Typhoon closure
357+
# 2026: Ching Ming substitute (Apr 6) coincides with Easter Monday,
358+
# so Apr 7 is an additional general holiday (same pattern as 2015-04-07)
359+
Timestamp("2026-04-07", tz="UTC"),
357360
]
358361

359362

‎pandas_market_calendars/calendars/mirror.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,16 @@ def weekmask(self) -> str:
148148
regular_market_times[new] = times
149149

150150
cal = type(
151-
exchange,
151+
f"{exchange}ExchangeCalendar",
152152
(TradingCalendar,),
153153
{
154+
"__module__": __name__,
154155
"_ec_class": calendars[exchange],
155-
"alias": [exchange],
156+
"aliases": [exchange],
156157
"regular_market_times": regular_market_times,
157158
},
158159
)
159-
locals()[f"{exchange}ExchangeCalendar"] = cal
160+
locals()[cal.__name__] = cal
160161

161162

162163
class XTAEExchangeCalendar(TradingCalendar):

‎pandas_market_calendars/calendars/six.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
EasterMonday,
99
GoodFriday,
1010
Holiday,
11-
previous_friday,
1211
)
1312
from zoneinfo import ZoneInfo
1413

@@ -27,7 +26,7 @@
2726
"New Year's Eve",
2827
month=12,
2928
day=31,
30-
observance=previous_friday,
29+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
3130
)
3231
# New Year's Day
3332
NewYearsDay = Holiday(

‎pandas_market_calendars/calendars/tase.py‎

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from datetime import time
22
from typing import Any, List, Literal, Union
33

4-
from pandas import DatetimeIndex, Timedelta, Timestamp
4+
from pandas import DatetimeIndex, Timedelta, Timestamp, date_range
5+
from pandas.tseries.offsets import CustomBusinessDay
56
from zoneinfo import ZoneInfo
67

78
from pandas_market_calendars.calendar_utils import Day_Anchor, Month_Anchor
8-
from pandas_market_calendars.market_calendar import MarketCalendar
9+
from pandas_market_calendars.market_calendar import FRIDAY, MarketCalendar
910

1011

1112
TASEClosedDay = [
@@ -137,14 +138,51 @@
137138
Timestamp("2025-10-07", tz="Asia/Jerusalem"),
138139
Timestamp("2025-10-13", tz="Asia/Jerusalem"),
139140
Timestamp("2025-10-14", tz="Asia/Jerusalem"),
141+
# 2026 (Monday-Friday trading week from 2026-01-05)
142+
Timestamp("2026-03-03", tz="Asia/Jerusalem"),
143+
Timestamp("2026-04-01", tz="Asia/Jerusalem"),
144+
Timestamp("2026-04-02", tz="Asia/Jerusalem"),
145+
Timestamp("2026-04-07", tz="Asia/Jerusalem"),
146+
Timestamp("2026-04-08", tz="Asia/Jerusalem"),
147+
Timestamp("2026-04-21", tz="Asia/Jerusalem"),
148+
Timestamp("2026-04-22", tz="Asia/Jerusalem"),
149+
Timestamp("2026-05-21", tz="Asia/Jerusalem"),
150+
Timestamp("2026-05-22", tz="Asia/Jerusalem"),
151+
Timestamp("2026-07-23", tz="Asia/Jerusalem"),
152+
Timestamp("2026-09-11", tz="Asia/Jerusalem"),
153+
Timestamp("2026-09-18", tz="Asia/Jerusalem"),
154+
Timestamp("2026-09-21", tz="Asia/Jerusalem"),
155+
Timestamp("2026-09-25", tz="Asia/Jerusalem"),
156+
Timestamp("2026-10-02", tz="Asia/Jerusalem"),
157+
# 2027
158+
Timestamp("2027-03-23", tz="Asia/Jerusalem"),
159+
Timestamp("2027-04-21", tz="Asia/Jerusalem"),
160+
Timestamp("2027-04-22", tz="Asia/Jerusalem"),
161+
Timestamp("2027-04-27", tz="Asia/Jerusalem"),
162+
Timestamp("2027-04-28", tz="Asia/Jerusalem"),
163+
Timestamp("2027-05-11", tz="Asia/Jerusalem"),
164+
Timestamp("2027-05-12", tz="Asia/Jerusalem"),
165+
Timestamp("2027-06-10", tz="Asia/Jerusalem"),
166+
Timestamp("2027-06-11", tz="Asia/Jerusalem"),
167+
Timestamp("2027-08-12", tz="Asia/Jerusalem"),
168+
Timestamp("2027-10-01", tz="Asia/Jerusalem"),
169+
Timestamp("2027-10-08", tz="Asia/Jerusalem"),
170+
Timestamp("2027-10-11", tz="Asia/Jerusalem"),
171+
Timestamp("2027-10-15", tz="Asia/Jerusalem"),
172+
Timestamp("2027-10-22", tz="Asia/Jerusalem"),
140173
]
141174

142175

143176
class TASEExchangeCalendar(MarketCalendar):
144177
"""
145178
Exchange calendar for TASE Stock Exchange
146179
147-
Note these dates are only checked against 2020 and 2021
180+
TASE moved from a Sunday-Thursday to a Monday-Friday trading week effective
181+
2026-01-05; the last Sunday session was 2026-01-04. Friday sessions close
182+
early, ahead of Shabbat.
183+
https://www.tase.co.il/en/content/knowledge_center/trading_vacation_schedule/
184+
185+
Note the dates before 2026 are only checked against 2020 and 2021
148186
https://info.tase.co.il/Eng/about_tase/corporate/Pages/vacation_schedule.aspx
149187
150188
Opening times for the regular trading of equities (not including closing auction call)
@@ -183,6 +221,10 @@ class TASEExchangeCalendar(MarketCalendar):
183221
"market_close": ((None, time(15, 59)),),
184222
}
185223

224+
# Last session of the Sunday-Thursday trading week; Monday-Friday trading
225+
# started 2026-01-05
226+
_sunday_end = Timestamp("2026-01-04", tz="UTC")
227+
186228
@property
187229
def name(self) -> str:
188230
return "TASE"
@@ -201,8 +243,82 @@ def adhoc_holidays(self) -> List[Any]:
201243

202244
@property
203245
def weekmask(self) -> str:
246+
return "Mon Tue Wed Thu Fri"
247+
248+
@property
249+
def weekmask_pre_2026(self) -> str:
204250
return "Sun Mon Tue Wed Thu"
205251

252+
def holidays_pre_2026(self) -> CustomBusinessDay:
253+
"""
254+
TASE traded Sunday-Thursday before the move to a Monday-Friday trading
255+
week effective 2026-01-05 (the last Sunday session was 2026-01-04).
256+
CustomBusinessDay object that can be used in place of holidays() for
257+
dates prior to the crossover.
258+
259+
:return: CustomBusinessDay object of holidays
260+
"""
261+
if hasattr(self, "_holidays_pre_2026"):
262+
return self._holidays_pre_2026
263+
264+
self._holidays_pre_2026 = CustomBusinessDay(
265+
holidays=self.adhoc_holidays,
266+
weekmask=self.weekmask_pre_2026,
267+
)
268+
return self._holidays_pre_2026
269+
270+
@property
271+
def special_closes(self) -> List[Any]:
272+
# Friday sessions (from 2026-01-05) end at 13:34, before Shabbat
273+
return [(time(13, 34), FRIDAY)]
274+
275+
def valid_days(self, start_date: Any, end_date: Any, tz: Any = "UTC") -> DatetimeIndex:
276+
"""
277+
Get a DatetimeIndex of valid open business days.
278+
279+
Handles the trading week change from Sunday-Thursday to Monday-Friday
280+
effective 2026-01-05.
281+
282+
:param start_date: start date
283+
:param end_date: end date
284+
:param tz: time zone in either string or pytz.timezone
285+
:return: DatetimeIndex of valid business days
286+
"""
287+
start_date = Timestamp(start_date)
288+
end_date = Timestamp(end_date)
289+
start_date = start_date.tz_convert(tz) if start_date.tz else start_date.tz_localize(tz)
290+
end_date = end_date.tz_convert(tz) if end_date.tz else end_date.tz_localize(tz)
291+
292+
if tz is None:
293+
sunday_end = self._sunday_end.tz_localize(None)
294+
else:
295+
sunday_end = self._sunday_end
296+
297+
# Entirely within the Monday-Friday trading week. Call super.
298+
if start_date > sunday_end:
299+
return super().valid_days(start_date, end_date, tz=tz)
300+
301+
# Entirely within the Sunday-Thursday trading week. Augment the super call.
302+
if end_date <= sunday_end:
303+
return date_range(
304+
start_date,
305+
end_date,
306+
freq=self.holidays_pre_2026(),
307+
normalize=True,
308+
tz=tz,
309+
)
310+
311+
# Range is split across the crossover. Concatenate two date_range calls.
312+
days_pre = date_range(
313+
start_date,
314+
sunday_end,
315+
freq=self.holidays_pre_2026(),
316+
normalize=True,
317+
tz=tz,
318+
)
319+
days_post = date_range(sunday_end, end_date, freq=self.holidays(), normalize=True, tz=tz)
320+
return days_pre.union(days_post)
321+
206322
def date_range_htf(
207323
self,
208324
frequency: Union[str, Timedelta, int, float],

‎pandas_market_calendars/holidays/uk.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# Spring bank holiday has two exceptions based on the Golden & Diamond Jubilee
5959
# 2002-05-27 Spring bank holiday removed for Golden Jubilee
6060
# 2012-05-28 Spring bank holiday removed for Diamond Jubilee
61-
# 2022-05-31 Spring bank holiday removed for Platinum Jubilee
61+
# 2022-05-30 Spring bank holiday removed for Platinum Jubilee (moved to 2022-06-02)
6262

6363
# Spring bank holiday
6464
SpringBank_pre_2002 = Holiday(
@@ -92,7 +92,9 @@
9292
month=5,
9393
day=31,
9494
offset=DateOffset(weekday=MO(-1)),
95-
start_date=Timestamp("2022-01-01"),
95+
# 2022's holiday was moved to Jun 2 for the Platinum Jubilee (see the
96+
# UniqueCloses entries), so this rule skips 2022 like 2002/2012 above
97+
start_date=Timestamp("2023-01-01"),
9698
)
9799

98100
# Summer bank holiday

‎pandas_market_calendars/sources.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ class Source(NamedTuple):
163163
last_verified="2025-01-24",
164164
covers="trading hours",
165165
),
166+
Source(
167+
name="CME Globex Equity Market Pause Elimination Notice",
168+
url="https://www.cmegroup.com/notices/electronic-trading/2021/06/20210621.html",
169+
last_verified="2026-08-12",
170+
covers="historical trading hours",
171+
),
166172
),
167173
"CME_Agriculture": (
168174
Source(

0 commit comments

Comments
 (0)