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