pandas-market-calendars 5.1.0__py3-none-any.whl → 5.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. pandas_market_calendars/__init__.py +39 -39
  2. pandas_market_calendars/calendar_registry.py +58 -57
  3. pandas_market_calendars/calendar_utils.py +1151 -1151
  4. pandas_market_calendars/calendars/asx.py +100 -70
  5. pandas_market_calendars/calendars/bmf.py +225 -219
  6. pandas_market_calendars/calendars/bse.py +433 -425
  7. pandas_market_calendars/calendars/cboe.py +153 -149
  8. pandas_market_calendars/calendars/cme.py +417 -405
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -172
  10. pandas_market_calendars/calendars/cme_globex_base.py +127 -119
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +166 -158
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +224 -216
  13. pandas_market_calendars/calendars/cme_globex_equities.py +131 -123
  14. pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -136
  15. pandas_market_calendars/calendars/cme_globex_fx.py +101 -101
  16. pandas_market_calendars/calendars/eurex.py +139 -131
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +106 -98
  18. pandas_market_calendars/calendars/hkex.py +437 -431
  19. pandas_market_calendars/calendars/ice.py +89 -81
  20. pandas_market_calendars/calendars/iex.py +163 -155
  21. pandas_market_calendars/calendars/jpx.py +125 -117
  22. pandas_market_calendars/calendars/lse.py +126 -118
  23. pandas_market_calendars/calendars/mirror.py +144 -144
  24. pandas_market_calendars/calendars/nyse.py +1462 -1466
  25. pandas_market_calendars/calendars/ose.py +124 -118
  26. pandas_market_calendars/calendars/sifma.py +391 -383
  27. pandas_market_calendars/calendars/six.py +144 -136
  28. pandas_market_calendars/calendars/sse.py +305 -315
  29. pandas_market_calendars/calendars/tase.py +232 -224
  30. pandas_market_calendars/calendars/tsx.py +193 -185
  31. pandas_market_calendars/class_registry.py +115 -115
  32. pandas_market_calendars/holidays/cme.py +385 -385
  33. pandas_market_calendars/holidays/cme_globex.py +214 -214
  34. pandas_market_calendars/holidays/cn.py +1476 -1476
  35. pandas_market_calendars/holidays/jp.py +401 -401
  36. pandas_market_calendars/holidays/jpx_equinox.py +506 -506
  37. pandas_market_calendars/holidays/nyse.py +1536 -1536
  38. pandas_market_calendars/holidays/oz.py +82 -63
  39. pandas_market_calendars/holidays/sifma.py +350 -350
  40. pandas_market_calendars/holidays/uk.py +186 -186
  41. pandas_market_calendars/holidays/us.py +376 -376
  42. pandas_market_calendars/market_calendar.py +1006 -1008
  43. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/METADATA +5 -4
  44. pandas_market_calendars-5.1.3.dist-info/RECORD +50 -0
  45. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/WHEEL +1 -1
  46. pandas_market_calendars-5.1.0.dist-info/RECORD +0 -50
  47. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/licenses/LICENSE +0 -0
  48. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/licenses/NOTICE +0 -0
  49. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/top_level.txt +0 -0
@@ -1,383 +1,391 @@
1
- from datetime import time
2
- import functools
3
-
4
- import pandas as pd
5
- from pandas.tseries.holiday import AbstractHolidayCalendar
6
- from zoneinfo import ZoneInfo
7
- from itertools import chain
8
-
9
- ########################################################################################################################
10
- # SIFMA Financial Markets Calendar for US, UK, JP
11
- #
12
- # https://www.sifma.com/
13
- #
14
- # US: SIFMAUSExchangeCalendar() ['SIFMAUS', 'SIFMA_US', "Capital_Markets_US", "Financial_Markets_US", "Bond_Markets_US"]
15
- # UK: SIFMAUKExchangeCalendar() ['SIFMAUK', 'SIFMA_UK', "Capital_Markets_UK", "Financial_Markets_UK", "Bond_Markets_UK"]
16
- # JP: SIFMAJPExchangeCalendar() ['SIFMAJP', 'SIFMA_JP', "Capital_Markets_JP", "Financial_Markets_JP", "Bond_Markets_JP"]
17
- #
18
- # Trading Hours:
19
- # US: 7:00 to 17:30
20
- # UK: 8:00 to 17:00
21
- # JP: 8:30 to 18:30
22
- ########################################################################################################################
23
-
24
-
25
- from pandas_market_calendars.holidays.sifma import (
26
- # US Holidays
27
- USNewYearsDay, # Not observed if a Saturday
28
- USNewYearsEve2pmEarlyClose,
29
- MartinLutherKingJr,
30
- USPresidentsDay,
31
- # --- Good Friday Rules --- #
32
- is_first_friday,
33
- GoodFridayThru2020,
34
- DayBeforeGoodFriday2pmEarlyCloseThru2020,
35
- GoodFridayPotentialPost2020, # Potential dates, filtered later
36
- DayBeforeGoodFridayPotentialPost2020, # Potential dates, filtered later
37
- # --- End Good Friday Rules --- #
38
- DayBeforeUSMemorialDay2pmEarlyClose,
39
- USMemorialDay,
40
- USJuneteenthAfter2022,
41
- USIndependenceDay,
42
- DayBeforeUSIndependenceDay2pmEarlyClose,
43
- ThursdayBeforeUSIndependenceDay2pmEarlyClose,
44
- USLaborDay,
45
- USColumbusDay,
46
- USVeteransDay,
47
- USThanksgivingDay,
48
- DayAfterThanksgiving2pmEarlyClose,
49
- Christmas,
50
- ChristmasEve2pmEarlyClose,
51
- ChristmasEveThursday2pmEarlyClose,
52
- # UK Specific Holidays
53
- UKNewYearsDay, # Saturdays observed on Monday
54
- UKGoodFriday,
55
- UKEasterMonday,
56
- UKMayDay,
57
- UKSpringBankAdHoc, # Usually follows US Memorial Day but not always
58
- UKSummerBank,
59
- UKChristmas,
60
- UKChristmaEve,
61
- UKWeekendChristmas, # Observed Tuesday when Boxing Day is on Monday
62
- UKBoxingDay,
63
- UKWeekendBoxingDay,
64
- UKPlatinumJubilee2022,
65
- )
66
- from pandas_market_calendars.market_calendar import MarketCalendar
67
-
68
-
69
- ########################################################################################################################
70
- # SIFMA Financial Markets Calendar for US, UK, JP
71
- #
72
- # https://www.sifma.com/
73
- #
74
- # US: SIFMAUSExchangeCalendar() ['SIFMAUS', 'SIFMA_US', "Capital_Markets_US", "Financial_Markets_US", "Bond_Markets_US"]
75
- # UK: SIFMAUKExchangeCalendar() ['SIFMAUK', 'SIFMA_UK', "Capital_Markets_UK", "Financial_Markets_UK", "Bond_Markets_UK"]
76
- # JP: SIFMAJPExchangeCalendar() ['SIFMAJP', 'SIFMA_JP', "Capital_Markets_JP", "Financial_Markets_JP", "Bond_Markets_JP"]
77
- #
78
- # Trading Hours:
79
- # US: 7:00 to 17:30
80
- # UK: 8:00 to 17:00
81
- # JP: 8:30 to 18:30
82
- ########################################################################################################################
83
-
84
- # AbstractHolidayCalendar.start_date = '1998-01-01'
85
-
86
- ############################################################
87
- # US
88
- ############################################################
89
-
90
-
91
- class SIFMAUSExchangeCalendar(MarketCalendar):
92
- """
93
- Exchange calendar for SIFMA United States
94
-
95
- https://www.sifma.org/resources/general/holiday-schedule/#US
96
-
97
- """
98
-
99
- aliases = [
100
- "SIFMAUS",
101
- "SIFMA_US",
102
- "Capital_Markets_US",
103
- "Financial_Markets_US",
104
- "Bond_Markets_US",
105
- ]
106
-
107
- regular_market_times = {
108
- "market_open": ((None, time(7)),),
109
- "market_close": ((None, time(17, 30)),),
110
- }
111
-
112
- @property
113
- def name(self):
114
- return "SIFMA_US"
115
-
116
- @property
117
- def full_name(self):
118
- return "Securities Industry and Financial Markets Association"
119
-
120
- @property
121
- def tz(self):
122
- return ZoneInfo("America/New_York")
123
-
124
- # Helper method to calculate and cache dynamic dates
125
- @functools.lru_cache()
126
- def _get_dynamic_gf_rules(self):
127
- # Calculate rules for a wide fixed range to avoid arbitrary cutoffs
128
- # while preventing infinite generation. 1970-2100 is a reasonable range.
129
- calc_start = pd.Timestamp("1970-01-01")
130
- calc_end = pd.Timestamp("2100-12-31")
131
-
132
- # Filter potential dates based on the start_date of the underlying Holiday rules
133
- gf_rule_start = GoodFridayPotentialPost2020.start_date
134
- thurs_rule_start = DayBeforeGoodFridayPotentialPost2020.start_date
135
-
136
- # Ensure calculation range respects the rule start dates
137
- effective_gf_start = max(calc_start, gf_rule_start) if gf_rule_start else calc_start
138
- effective_thurs_start = max(calc_start, thurs_rule_start) if thurs_rule_start else calc_start
139
-
140
- potential_gf_dates = GoodFridayPotentialPost2020.dates(effective_gf_start, calc_end)
141
- gf_full_holidays = [d for d in potential_gf_dates if not is_first_friday(d)]
142
- gf_12pm_early_closes = [d for d in potential_gf_dates if is_first_friday(d)]
143
-
144
- potential_thurs_dates = DayBeforeGoodFridayPotentialPost2020.dates(effective_thurs_start, calc_end)
145
- thurs_before_gf_2pm_early_closes = [
146
- thurs for thurs in potential_thurs_dates if not is_first_friday(thurs + pd.Timedelta(days=1))
147
- ]
148
- return gf_full_holidays, gf_12pm_early_closes, thurs_before_gf_2pm_early_closes
149
-
150
- @property
151
- def regular_holidays(self):
152
- return AbstractHolidayCalendar(
153
- rules=[
154
- USNewYearsDay,
155
- MartinLutherKingJr,
156
- USPresidentsDay,
157
- GoodFridayThru2020,
158
- USMemorialDay,
159
- USJuneteenthAfter2022,
160
- USIndependenceDay,
161
- USLaborDay,
162
- USColumbusDay,
163
- USVeteransDay,
164
- USThanksgivingDay,
165
- Christmas,
166
- ]
167
- )
168
-
169
- @property
170
- def adhoc_holidays(self):
171
- gf_full_holidays, _, _ = self._get_dynamic_gf_rules()
172
- return gf_full_holidays
173
-
174
- @property
175
- def special_closes(self):
176
- return [
177
- (
178
- time(14),
179
- AbstractHolidayCalendar(
180
- rules=[
181
- DayBeforeGoodFriday2pmEarlyCloseThru2020,
182
- DayBeforeUSMemorialDay2pmEarlyClose,
183
- DayBeforeUSIndependenceDay2pmEarlyClose,
184
- ThursdayBeforeUSIndependenceDay2pmEarlyClose,
185
- DayAfterThanksgiving2pmEarlyClose,
186
- ChristmasEve2pmEarlyClose,
187
- ChristmasEveThursday2pmEarlyClose,
188
- USNewYearsEve2pmEarlyClose,
189
- ]
190
- ),
191
- )
192
- ]
193
-
194
- @property
195
- def special_closes_adhoc(self):
196
- _, gf_12pm_early_closes, thurs_before_gf_2pm_early_closes = self._get_dynamic_gf_rules()
197
- return [
198
- (
199
- time(12), # SIFMA rule specifies 12:00 PM ET
200
- gf_12pm_early_closes,
201
- ),
202
- (
203
- time(14), # SIFMA rule specifies 2:00 PM ET
204
- thurs_before_gf_2pm_early_closes,
205
- ),
206
- ]
207
-
208
-
209
- ############################################################
210
- # UK
211
- ############################################################
212
-
213
-
214
- class SIFMAUKExchangeCalendar(MarketCalendar):
215
- """
216
- Exchange calendar for SIFMA United Kingdom
217
-
218
- https://www.sifma.org/resources/general/holiday-schedule/#UK
219
-
220
- """
221
-
222
- aliases = [
223
- "SIFMAUK",
224
- "SIFMA_UK",
225
- "Capital_Markets_UK",
226
- "Financial_Markets_UK",
227
- "Bond_Markets_UK",
228
- ]
229
-
230
- regular_market_times = {
231
- "market_open": ((None, time(8)),),
232
- "market_close": ((None, time(17)),),
233
- }
234
-
235
- @property
236
- def name(self):
237
- return "SIFMA_UK"
238
-
239
- @property
240
- def tz(self):
241
- return ZoneInfo("Europe/London")
242
-
243
- @property
244
- def regular_holidays(self):
245
- return AbstractHolidayCalendar(
246
- rules=[
247
- UKNewYearsDay,
248
- MartinLutherKingJr,
249
- USPresidentsDay,
250
- UKGoodFriday,
251
- UKEasterMonday,
252
- UKMayDay,
253
- USMemorialDay,
254
- USJuneteenthAfter2022,
255
- USIndependenceDay,
256
- UKSummerBank,
257
- USLaborDay,
258
- USColumbusDay,
259
- USVeteransDay,
260
- USThanksgivingDay,
261
- UKChristmas,
262
- UKChristmaEve,
263
- UKWeekendChristmas,
264
- UKBoxingDay,
265
- UKWeekendBoxingDay,
266
- ]
267
- )
268
-
269
- @property
270
- def adhoc_holidays(self):
271
- return list(
272
- chain(
273
- UKSpringBankAdHoc,
274
- UKPlatinumJubilee2022,
275
- )
276
- )
277
-
278
-
279
- ############################################################
280
- # Japan
281
- ############################################################
282
- from pandas_market_calendars.holidays.jp import (
283
- JapanComingOfAgeDay,
284
- JapanNationalFoundationDay,
285
- JapanEmperorsBirthday,
286
- JapanVernalEquinox,
287
- JapanShowaDay,
288
- JapanConstitutionMemorialDay,
289
- JapanGreeneryDay,
290
- JapanChildrensDay,
291
- JapanMarineDay,
292
- JapanMountainDay,
293
- JapanRespectForTheAgedDay,
294
- JapanAutumnalEquinox,
295
- JapanHealthAndSportsDay2000To2019,
296
- JapanSportsDay2020,
297
- JapanSportsDay,
298
- JapanCultureDay,
299
- JapanLaborThanksgivingDay,
300
- )
301
-
302
-
303
- class SIFMAJPExchangeCalendar(MarketCalendar):
304
- """
305
- Exchange calendar for SIFMA Japan
306
-
307
- https://www.sifma.org/resources/general/holiday-schedule/#JP
308
-
309
- """
310
-
311
- aliases = [
312
- "SIFMAJP",
313
- "SIFMA_JP",
314
- "Capital_Markets_JP",
315
- "Financial_Markets_JP",
316
- "Bond_Markets_JP",
317
- ]
318
-
319
- regular_market_times = {
320
- "market_open": ((None, time(8, 30)),),
321
- "market_close": ((None, time(18, 30)),),
322
- }
323
-
324
- @property
325
- def name(self):
326
- return "SIFMA_JP"
327
-
328
- @property
329
- def tz(self):
330
- return ZoneInfo("Asia/Tokyo")
331
-
332
- @property
333
- def regular_holidays(self):
334
- return AbstractHolidayCalendar(
335
- rules=[
336
- UKNewYearsDay,
337
- JapanComingOfAgeDay,
338
- MartinLutherKingJr,
339
- JapanNationalFoundationDay,
340
- USPresidentsDay,
341
- JapanEmperorsBirthday,
342
- JapanVernalEquinox,
343
- UKGoodFriday,
344
- UKEasterMonday,
345
- JapanShowaDay,
346
- JapanConstitutionMemorialDay,
347
- JapanGreeneryDay,
348
- JapanChildrensDay,
349
- USMemorialDay,
350
- USJuneteenthAfter2022,
351
- USIndependenceDay,
352
- JapanMarineDay,
353
- JapanMountainDay,
354
- UKSummerBank,
355
- USLaborDay,
356
- JapanRespectForTheAgedDay,
357
- JapanAutumnalEquinox,
358
- JapanSportsDay,
359
- JapanSportsDay2020,
360
- JapanHealthAndSportsDay2000To2019,
361
- JapanCultureDay,
362
- USVeteransDay,
363
- JapanLaborThanksgivingDay,
364
- USThanksgivingDay,
365
- UKChristmas,
366
- UKChristmaEve,
367
- UKBoxingDay,
368
- UKWeekendBoxingDay,
369
- ]
370
- )
371
-
372
- @property
373
- def adhoc_holidays(self):
374
- return list(
375
- chain(
376
- UKSpringBankAdHoc,
377
- UKPlatinumJubilee2022,
378
- )
379
- )
380
-
381
- @property
382
- def special_closes(self):
383
- return [(time(15), AbstractHolidayCalendar(rules=[UKMayDay, UKWeekendChristmas]))]
1
+ from datetime import time
2
+ import functools
3
+
4
+ import pandas as pd
5
+ from pandas.tseries.holiday import AbstractHolidayCalendar
6
+ import sys
7
+
8
+ # check python versiOn aNd import accordingly
9
+ if sys.version_info >= (3, 9):
10
+ # For Python 3.9 and later, import directly
11
+ from zoneinfo import ZoneInfo
12
+ else:
13
+ # For Python 3.8 and earlier, import from backports
14
+ from backports.zoneinfo import ZoneInfo
15
+ from itertools import chain
16
+
17
+ ########################################################################################################################
18
+ # SIFMA Financial Markets Calendar for US, UK, JP
19
+ #
20
+ # https://www.sifma.com/
21
+ #
22
+ # US: SIFMAUSExchangeCalendar() ['SIFMAUS', 'SIFMA_US', "Capital_Markets_US", "Financial_Markets_US", "Bond_Markets_US"]
23
+ # UK: SIFMAUKExchangeCalendar() ['SIFMAUK', 'SIFMA_UK', "Capital_Markets_UK", "Financial_Markets_UK", "Bond_Markets_UK"]
24
+ # JP: SIFMAJPExchangeCalendar() ['SIFMAJP', 'SIFMA_JP', "Capital_Markets_JP", "Financial_Markets_JP", "Bond_Markets_JP"]
25
+ #
26
+ # Trading Hours:
27
+ # US: 7:00 to 17:30
28
+ # UK: 8:00 to 17:00
29
+ # JP: 8:30 to 18:30
30
+ ########################################################################################################################
31
+
32
+
33
+ from pandas_market_calendars.holidays.sifma import (
34
+ # US Holidays
35
+ USNewYearsDay, # Not observed if a Saturday
36
+ USNewYearsEve2pmEarlyClose,
37
+ MartinLutherKingJr,
38
+ USPresidentsDay,
39
+ # --- Good Friday Rules --- #
40
+ is_first_friday,
41
+ GoodFridayThru2020,
42
+ DayBeforeGoodFriday2pmEarlyCloseThru2020,
43
+ GoodFridayPotentialPost2020, # Potential dates, filtered later
44
+ DayBeforeGoodFridayPotentialPost2020, # Potential dates, filtered later
45
+ # --- End Good Friday Rules --- #
46
+ DayBeforeUSMemorialDay2pmEarlyClose,
47
+ USMemorialDay,
48
+ USJuneteenthAfter2022,
49
+ USIndependenceDay,
50
+ DayBeforeUSIndependenceDay2pmEarlyClose,
51
+ ThursdayBeforeUSIndependenceDay2pmEarlyClose,
52
+ USLaborDay,
53
+ USColumbusDay,
54
+ USVeteransDay,
55
+ USThanksgivingDay,
56
+ DayAfterThanksgiving2pmEarlyClose,
57
+ Christmas,
58
+ ChristmasEve2pmEarlyClose,
59
+ ChristmasEveThursday2pmEarlyClose,
60
+ # UK Specific Holidays
61
+ UKNewYearsDay, # Saturdays observed on Monday
62
+ UKGoodFriday,
63
+ UKEasterMonday,
64
+ UKMayDay,
65
+ UKSpringBankAdHoc, # Usually follows US Memorial Day but not always
66
+ UKSummerBank,
67
+ UKChristmas,
68
+ UKChristmaEve,
69
+ UKWeekendChristmas, # Observed Tuesday when Boxing Day is on Monday
70
+ UKBoxingDay,
71
+ UKWeekendBoxingDay,
72
+ UKPlatinumJubilee2022,
73
+ )
74
+ from pandas_market_calendars.market_calendar import MarketCalendar
75
+
76
+
77
+ ########################################################################################################################
78
+ # SIFMA Financial Markets Calendar for US, UK, JP
79
+ #
80
+ # https://www.sifma.com/
81
+ #
82
+ # US: SIFMAUSExchangeCalendar() ['SIFMAUS', 'SIFMA_US', "Capital_Markets_US", "Financial_Markets_US", "Bond_Markets_US"]
83
+ # UK: SIFMAUKExchangeCalendar() ['SIFMAUK', 'SIFMA_UK', "Capital_Markets_UK", "Financial_Markets_UK", "Bond_Markets_UK"]
84
+ # JP: SIFMAJPExchangeCalendar() ['SIFMAJP', 'SIFMA_JP', "Capital_Markets_JP", "Financial_Markets_JP", "Bond_Markets_JP"]
85
+ #
86
+ # Trading Hours:
87
+ # US: 7:00 to 17:30
88
+ # UK: 8:00 to 17:00
89
+ # JP: 8:30 to 18:30
90
+ ########################################################################################################################
91
+
92
+ # AbstractHolidayCalendar.start_date = '1998-01-01'
93
+
94
+ ############################################################
95
+ # US
96
+ ############################################################
97
+
98
+
99
+ class SIFMAUSExchangeCalendar(MarketCalendar):
100
+ """
101
+ Exchange calendar for SIFMA United States
102
+
103
+ https://www.sifma.org/resources/general/holiday-schedule/#US
104
+
105
+ """
106
+
107
+ aliases = [
108
+ "SIFMAUS",
109
+ "SIFMA_US",
110
+ "Capital_Markets_US",
111
+ "Financial_Markets_US",
112
+ "Bond_Markets_US",
113
+ ]
114
+
115
+ regular_market_times = {
116
+ "market_open": ((None, time(7)),),
117
+ "market_close": ((None, time(17, 30)),),
118
+ }
119
+
120
+ @property
121
+ def name(self):
122
+ return "SIFMA_US"
123
+
124
+ @property
125
+ def full_name(self):
126
+ return "Securities Industry and Financial Markets Association"
127
+
128
+ @property
129
+ def tz(self):
130
+ return ZoneInfo("America/New_York")
131
+
132
+ # Helper method to calculate and cache dynamic dates
133
+ @functools.lru_cache()
134
+ def _get_dynamic_gf_rules(self):
135
+ # Calculate rules for a wide fixed range to avoid arbitrary cutoffs
136
+ # while preventing infinite generation. 1970-2100 is a reasonable range.
137
+ calc_start = pd.Timestamp("1970-01-01")
138
+ calc_end = pd.Timestamp("2100-12-31")
139
+
140
+ # Filter potential dates based on the start_date of the underlying Holiday rules
141
+ gf_rule_start = GoodFridayPotentialPost2020.start_date
142
+ thurs_rule_start = DayBeforeGoodFridayPotentialPost2020.start_date
143
+
144
+ # Ensure calculation range respects the rule start dates
145
+ effective_gf_start = max(calc_start, gf_rule_start) if gf_rule_start else calc_start
146
+ effective_thurs_start = max(calc_start, thurs_rule_start) if thurs_rule_start else calc_start
147
+
148
+ potential_gf_dates = GoodFridayPotentialPost2020.dates(effective_gf_start, calc_end)
149
+ gf_full_holidays = [d for d in potential_gf_dates if not is_first_friday(d)]
150
+ gf_12pm_early_closes = [d for d in potential_gf_dates if is_first_friday(d)]
151
+
152
+ potential_thurs_dates = DayBeforeGoodFridayPotentialPost2020.dates(effective_thurs_start, calc_end)
153
+ thurs_before_gf_2pm_early_closes = [
154
+ thurs for thurs in potential_thurs_dates if not is_first_friday(thurs + pd.Timedelta(days=1))
155
+ ]
156
+ return gf_full_holidays, gf_12pm_early_closes, thurs_before_gf_2pm_early_closes
157
+
158
+ @property
159
+ def regular_holidays(self):
160
+ return AbstractHolidayCalendar(
161
+ rules=[
162
+ USNewYearsDay,
163
+ MartinLutherKingJr,
164
+ USPresidentsDay,
165
+ GoodFridayThru2020,
166
+ USMemorialDay,
167
+ USJuneteenthAfter2022,
168
+ USIndependenceDay,
169
+ USLaborDay,
170
+ USColumbusDay,
171
+ USVeteransDay,
172
+ USThanksgivingDay,
173
+ Christmas,
174
+ ]
175
+ )
176
+
177
+ @property
178
+ def adhoc_holidays(self):
179
+ gf_full_holidays, _, _ = self._get_dynamic_gf_rules()
180
+ return gf_full_holidays
181
+
182
+ @property
183
+ def special_closes(self):
184
+ return [
185
+ (
186
+ time(14),
187
+ AbstractHolidayCalendar(
188
+ rules=[
189
+ DayBeforeGoodFriday2pmEarlyCloseThru2020,
190
+ DayBeforeUSMemorialDay2pmEarlyClose,
191
+ DayBeforeUSIndependenceDay2pmEarlyClose,
192
+ ThursdayBeforeUSIndependenceDay2pmEarlyClose,
193
+ DayAfterThanksgiving2pmEarlyClose,
194
+ ChristmasEve2pmEarlyClose,
195
+ ChristmasEveThursday2pmEarlyClose,
196
+ USNewYearsEve2pmEarlyClose,
197
+ ]
198
+ ),
199
+ )
200
+ ]
201
+
202
+ @property
203
+ def special_closes_adhoc(self):
204
+ _, gf_12pm_early_closes, thurs_before_gf_2pm_early_closes = self._get_dynamic_gf_rules()
205
+ return [
206
+ (
207
+ time(12), # SIFMA rule specifies 12:00 PM ET
208
+ gf_12pm_early_closes,
209
+ ),
210
+ (
211
+ time(14), # SIFMA rule specifies 2:00 PM ET
212
+ thurs_before_gf_2pm_early_closes,
213
+ ),
214
+ ]
215
+
216
+
217
+ ############################################################
218
+ # UK
219
+ ############################################################
220
+
221
+
222
+ class SIFMAUKExchangeCalendar(MarketCalendar):
223
+ """
224
+ Exchange calendar for SIFMA United Kingdom
225
+
226
+ https://www.sifma.org/resources/general/holiday-schedule/#UK
227
+
228
+ """
229
+
230
+ aliases = [
231
+ "SIFMAUK",
232
+ "SIFMA_UK",
233
+ "Capital_Markets_UK",
234
+ "Financial_Markets_UK",
235
+ "Bond_Markets_UK",
236
+ ]
237
+
238
+ regular_market_times = {
239
+ "market_open": ((None, time(8)),),
240
+ "market_close": ((None, time(17)),),
241
+ }
242
+
243
+ @property
244
+ def name(self):
245
+ return "SIFMA_UK"
246
+
247
+ @property
248
+ def tz(self):
249
+ return ZoneInfo("Europe/London")
250
+
251
+ @property
252
+ def regular_holidays(self):
253
+ return AbstractHolidayCalendar(
254
+ rules=[
255
+ UKNewYearsDay,
256
+ MartinLutherKingJr,
257
+ USPresidentsDay,
258
+ UKGoodFriday,
259
+ UKEasterMonday,
260
+ UKMayDay,
261
+ USMemorialDay,
262
+ USJuneteenthAfter2022,
263
+ USIndependenceDay,
264
+ UKSummerBank,
265
+ USLaborDay,
266
+ USColumbusDay,
267
+ USVeteransDay,
268
+ USThanksgivingDay,
269
+ UKChristmas,
270
+ UKChristmaEve,
271
+ UKWeekendChristmas,
272
+ UKBoxingDay,
273
+ UKWeekendBoxingDay,
274
+ ]
275
+ )
276
+
277
+ @property
278
+ def adhoc_holidays(self):
279
+ return list(
280
+ chain(
281
+ UKSpringBankAdHoc,
282
+ UKPlatinumJubilee2022,
283
+ )
284
+ )
285
+
286
+
287
+ ############################################################
288
+ # Japan
289
+ ############################################################
290
+ from pandas_market_calendars.holidays.jp import (
291
+ JapanComingOfAgeDay,
292
+ JapanNationalFoundationDay,
293
+ JapanEmperorsBirthday,
294
+ JapanVernalEquinox,
295
+ JapanShowaDay,
296
+ JapanConstitutionMemorialDay,
297
+ JapanGreeneryDay,
298
+ JapanChildrensDay,
299
+ JapanMarineDay,
300
+ JapanMountainDay,
301
+ JapanRespectForTheAgedDay,
302
+ JapanAutumnalEquinox,
303
+ JapanHealthAndSportsDay2000To2019,
304
+ JapanSportsDay2020,
305
+ JapanSportsDay,
306
+ JapanCultureDay,
307
+ JapanLaborThanksgivingDay,
308
+ )
309
+
310
+
311
+ class SIFMAJPExchangeCalendar(MarketCalendar):
312
+ """
313
+ Exchange calendar for SIFMA Japan
314
+
315
+ https://www.sifma.org/resources/general/holiday-schedule/#JP
316
+
317
+ """
318
+
319
+ aliases = [
320
+ "SIFMAJP",
321
+ "SIFMA_JP",
322
+ "Capital_Markets_JP",
323
+ "Financial_Markets_JP",
324
+ "Bond_Markets_JP",
325
+ ]
326
+
327
+ regular_market_times = {
328
+ "market_open": ((None, time(8, 30)),),
329
+ "market_close": ((None, time(18, 30)),),
330
+ }
331
+
332
+ @property
333
+ def name(self):
334
+ return "SIFMA_JP"
335
+
336
+ @property
337
+ def tz(self):
338
+ return ZoneInfo("Asia/Tokyo")
339
+
340
+ @property
341
+ def regular_holidays(self):
342
+ return AbstractHolidayCalendar(
343
+ rules=[
344
+ UKNewYearsDay,
345
+ JapanComingOfAgeDay,
346
+ MartinLutherKingJr,
347
+ JapanNationalFoundationDay,
348
+ USPresidentsDay,
349
+ JapanEmperorsBirthday,
350
+ JapanVernalEquinox,
351
+ UKGoodFriday,
352
+ UKEasterMonday,
353
+ JapanShowaDay,
354
+ JapanConstitutionMemorialDay,
355
+ JapanGreeneryDay,
356
+ JapanChildrensDay,
357
+ USMemorialDay,
358
+ USJuneteenthAfter2022,
359
+ USIndependenceDay,
360
+ JapanMarineDay,
361
+ JapanMountainDay,
362
+ UKSummerBank,
363
+ USLaborDay,
364
+ JapanRespectForTheAgedDay,
365
+ JapanAutumnalEquinox,
366
+ JapanSportsDay,
367
+ JapanSportsDay2020,
368
+ JapanHealthAndSportsDay2000To2019,
369
+ JapanCultureDay,
370
+ USVeteransDay,
371
+ JapanLaborThanksgivingDay,
372
+ USThanksgivingDay,
373
+ UKChristmas,
374
+ UKChristmaEve,
375
+ UKBoxingDay,
376
+ UKWeekendBoxingDay,
377
+ ]
378
+ )
379
+
380
+ @property
381
+ def adhoc_holidays(self):
382
+ return list(
383
+ chain(
384
+ UKSpringBankAdHoc,
385
+ UKPlatinumJubilee2022,
386
+ )
387
+ )
388
+
389
+ @property
390
+ def special_closes(self):
391
+ return [(time(15), AbstractHolidayCalendar(rules=[UKMayDay, UKWeekendChristmas]))]