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.
- pandas_market_calendars/__init__.py +39 -39
- pandas_market_calendars/calendar_registry.py +57 -57
- pandas_market_calendars/calendar_utils.py +1151 -1151
- pandas_market_calendars/calendars/asx.py +77 -70
- pandas_market_calendars/calendars/bmf.py +226 -219
- pandas_market_calendars/calendars/bse.py +432 -425
- pandas_market_calendars/calendars/cboe.py +156 -149
- pandas_market_calendars/calendars/cme.py +412 -405
- pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -172
- pandas_market_calendars/calendars/cme_globex_base.py +126 -119
- pandas_market_calendars/calendars/cme_globex_crypto.py +165 -158
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +223 -216
- pandas_market_calendars/calendars/cme_globex_equities.py +130 -123
- pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -136
- pandas_market_calendars/calendars/cme_globex_fx.py +101 -101
- pandas_market_calendars/calendars/eurex.py +138 -131
- pandas_market_calendars/calendars/eurex_fixed_income.py +105 -98
- pandas_market_calendars/calendars/hkex.py +438 -431
- pandas_market_calendars/calendars/ice.py +88 -81
- pandas_market_calendars/calendars/iex.py +162 -155
- pandas_market_calendars/calendars/jpx.py +124 -117
- pandas_market_calendars/calendars/lse.py +125 -118
- pandas_market_calendars/calendars/mirror.py +144 -144
- pandas_market_calendars/calendars/nyse.py +1472 -1466
- pandas_market_calendars/calendars/ose.py +125 -118
- pandas_market_calendars/calendars/sifma.py +390 -383
- pandas_market_calendars/calendars/six.py +143 -136
- pandas_market_calendars/calendars/sse.py +322 -315
- pandas_market_calendars/calendars/tase.py +231 -224
- pandas_market_calendars/calendars/tsx.py +192 -185
- pandas_market_calendars/class_registry.py +115 -115
- pandas_market_calendars/holidays/cme.py +385 -385
- pandas_market_calendars/holidays/cme_globex.py +214 -214
- pandas_market_calendars/holidays/cn.py +1476 -1476
- pandas_market_calendars/holidays/jp.py +401 -401
- pandas_market_calendars/holidays/jpx_equinox.py +506 -506
- pandas_market_calendars/holidays/nyse.py +1536 -1536
- pandas_market_calendars/holidays/oz.py +63 -63
- pandas_market_calendars/holidays/sifma.py +350 -350
- pandas_market_calendars/holidays/us.py +376 -376
- pandas_market_calendars/market_calendar.py +1008 -1008
- {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/METADATA +3 -1
- pandas_market_calendars-5.1.1.dist-info/RECORD +50 -0
- {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/WHEEL +1 -1
- pandas_market_calendars-5.1.0.dist-info/RECORD +0 -50
- {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/licenses/LICENSE +0 -0
- {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/licenses/NOTICE +0 -0
- {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/top_level.txt +0 -0
@@ -1,350 +1,350 @@
|
|
1
|
-
from dateutil.relativedelta import MO, TH
|
2
|
-
from pandas import DateOffset, Timestamp
|
3
|
-
from pandas.tseries.holiday import (
|
4
|
-
Holiday,
|
5
|
-
nearest_workday,
|
6
|
-
next_monday,
|
7
|
-
sunday_to_monday,
|
8
|
-
previous_workday,
|
9
|
-
Easter,
|
10
|
-
)
|
11
|
-
from pandas.tseries.offsets import Day
|
12
|
-
|
13
|
-
from pandas_market_calendars.market_calendar import (
|
14
|
-
MONDAY,
|
15
|
-
TUESDAY,
|
16
|
-
WEDNESDAY,
|
17
|
-
THURSDAY,
|
18
|
-
FRIDAY,
|
19
|
-
)
|
20
|
-
|
21
|
-
####################################################
|
22
|
-
# US New Years Day Jan 1
|
23
|
-
# When Jan 1 is a Sunday, US markets observe the subsequent Monday.
|
24
|
-
# When Jan 1 is a Saturday (as in 2005 and 2011), no holiday is observed.
|
25
|
-
#####################################################
|
26
|
-
USNewYearsDay = Holiday(
|
27
|
-
"New Years Day US",
|
28
|
-
month=1,
|
29
|
-
day=1,
|
30
|
-
days_of_week=(
|
31
|
-
MONDAY,
|
32
|
-
TUESDAY,
|
33
|
-
WEDNESDAY,
|
34
|
-
THURSDAY,
|
35
|
-
FRIDAY,
|
36
|
-
),
|
37
|
-
observance=sunday_to_monday,
|
38
|
-
)
|
39
|
-
|
40
|
-
USNewYearsEve2pmEarlyClose = Holiday(
|
41
|
-
"New Years Eve US",
|
42
|
-
month=1,
|
43
|
-
day=1,
|
44
|
-
days_of_week=(
|
45
|
-
MONDAY,
|
46
|
-
TUESDAY,
|
47
|
-
WEDNESDAY,
|
48
|
-
THURSDAY,
|
49
|
-
FRIDAY,
|
50
|
-
),
|
51
|
-
observance=previous_workday,
|
52
|
-
)
|
53
|
-
|
54
|
-
#########################################################################
|
55
|
-
# Martin Luther King Jr
|
56
|
-
##########################################################################
|
57
|
-
MartinLutherKingJr = Holiday(
|
58
|
-
"Dr. Martin Luther King Jr. Day",
|
59
|
-
month=1,
|
60
|
-
day=1,
|
61
|
-
days_of_week=(
|
62
|
-
MONDAY,
|
63
|
-
TUESDAY,
|
64
|
-
WEDNESDAY,
|
65
|
-
THURSDAY,
|
66
|
-
FRIDAY,
|
67
|
-
),
|
68
|
-
offset=DateOffset(weekday=MO(3)),
|
69
|
-
)
|
70
|
-
|
71
|
-
#########################################################################
|
72
|
-
# US Presidents Day Feb
|
73
|
-
##########################################################################
|
74
|
-
USPresidentsDay = Holiday(
|
75
|
-
"President" "s Day",
|
76
|
-
start_date=Timestamp("1971-01-01"),
|
77
|
-
month=2,
|
78
|
-
day=1,
|
79
|
-
days_of_week=(
|
80
|
-
MONDAY,
|
81
|
-
TUESDAY,
|
82
|
-
WEDNESDAY,
|
83
|
-
THURSDAY,
|
84
|
-
FRIDAY,
|
85
|
-
),
|
86
|
-
offset=DateOffset(weekday=MO(3)),
|
87
|
-
)
|
88
|
-
|
89
|
-
############################################################
|
90
|
-
# Good Friday
|
91
|
-
############################################################
|
92
|
-
|
93
|
-
|
94
|
-
def is_first_friday(dt):
|
95
|
-
"""Check if date is the first Friday of the month"""
|
96
|
-
# The first Friday of any month must occur on or before the 7th.
|
97
|
-
# This check is sufficient regardless of whether Good Friday is in March or April.
|
98
|
-
return dt.weekday() == FRIDAY and dt.day <= 7
|
99
|
-
|
100
|
-
|
101
|
-
GoodFridayThru2020 = Holiday(
|
102
|
-
"Good Friday Thru 2020",
|
103
|
-
end_date=Timestamp("2020-12-31"),
|
104
|
-
month=1,
|
105
|
-
day=1,
|
106
|
-
offset=[Easter(), Day(-2)],
|
107
|
-
)
|
108
|
-
|
109
|
-
# Generate potential Good Friday dates post 2020 (will be filtered in calendar class)
|
110
|
-
GoodFridayPotentialPost2020 = Holiday(
|
111
|
-
"Good Friday Potential Post 2020",
|
112
|
-
start_date=Timestamp("2021-01-01"),
|
113
|
-
month=1,
|
114
|
-
day=1,
|
115
|
-
offset=[Easter(), Day(-2)],
|
116
|
-
)
|
117
|
-
|
118
|
-
DayBeforeGoodFriday2pmEarlyCloseThru2020 = Holiday(
|
119
|
-
"Day Before Good Friday Thru 2020",
|
120
|
-
end_date=Timestamp("2020-12-31"),
|
121
|
-
month=1,
|
122
|
-
day=1,
|
123
|
-
offset=[Easter(), Day(-3)],
|
124
|
-
)
|
125
|
-
|
126
|
-
# Generate potential Thursday before Good Friday dates post 2020 (will be filtered in calendar class)
|
127
|
-
DayBeforeGoodFridayPotentialPost2020 = Holiday(
|
128
|
-
"Day Before Good Friday Potential Post 2020",
|
129
|
-
start_date=Timestamp("2021-01-01"),
|
130
|
-
month=1,
|
131
|
-
day=1,
|
132
|
-
offset=[Easter(), Day(-3)],
|
133
|
-
)
|
134
|
-
|
135
|
-
##################################################
|
136
|
-
# US Memorial Day (Decoration Day) May 30
|
137
|
-
# Closed every year since 1873
|
138
|
-
# Observed on Monday since 1971
|
139
|
-
##################################################
|
140
|
-
USMemorialDay = Holiday(
|
141
|
-
"Memorial Day",
|
142
|
-
month=5,
|
143
|
-
day=25,
|
144
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
145
|
-
offset=DateOffset(weekday=MO(1)),
|
146
|
-
)
|
147
|
-
|
148
|
-
DayBeforeUSMemorialDay2pmEarlyClose = Holiday(
|
149
|
-
"Day Before Memorial Day",
|
150
|
-
month=5,
|
151
|
-
day=25,
|
152
|
-
offset=[DateOffset(weekday=MO(1)), Day(-3)],
|
153
|
-
)
|
154
|
-
|
155
|
-
#######################################
|
156
|
-
# US Juneteenth (June 19th)
|
157
|
-
#######################################
|
158
|
-
USJuneteenthAfter2022 = Holiday(
|
159
|
-
"Juneteenth Starting at 2022",
|
160
|
-
start_date=Timestamp("2022-06-19"),
|
161
|
-
month=6,
|
162
|
-
day=19,
|
163
|
-
observance=nearest_workday,
|
164
|
-
)
|
165
|
-
|
166
|
-
#######################################
|
167
|
-
# US Independence Day July 4
|
168
|
-
#######################################
|
169
|
-
USIndependenceDay = Holiday(
|
170
|
-
"July 4th",
|
171
|
-
month=7,
|
172
|
-
day=4,
|
173
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
174
|
-
observance=nearest_workday,
|
175
|
-
)
|
176
|
-
|
177
|
-
# Day before Independence Day
|
178
|
-
DayBeforeUSIndependenceDay2pmEarlyClose = Holiday(
|
179
|
-
"Day Before Independence Day",
|
180
|
-
month=7,
|
181
|
-
day=4,
|
182
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
183
|
-
observance=previous_workday,
|
184
|
-
)
|
185
|
-
|
186
|
-
# When July 4th is a Saturday, the previous Friday is a holiday
|
187
|
-
# and the previous Thursday is an early close
|
188
|
-
ThursdayBeforeUSIndependenceDay2pmEarlyClose = Holiday(
|
189
|
-
"Thursday Before Independence Day",
|
190
|
-
month=7,
|
191
|
-
day=2,
|
192
|
-
days_of_week=(THURSDAY,),
|
193
|
-
)
|
194
|
-
|
195
|
-
#################################################
|
196
|
-
# US Labor Day
|
197
|
-
#################################################
|
198
|
-
USLaborDay = Holiday("Labor Day", month=9, day=1, offset=DateOffset(weekday=MO(1)))
|
199
|
-
|
200
|
-
#################################################
|
201
|
-
# Columbus Day
|
202
|
-
#################################################
|
203
|
-
USColumbusDay = Holiday(
|
204
|
-
"Columbus Day",
|
205
|
-
month=10,
|
206
|
-
day=1,
|
207
|
-
offset=DateOffset(weekday=MO(2)),
|
208
|
-
)
|
209
|
-
|
210
|
-
##########################################################
|
211
|
-
# Armistice/Veterans day
|
212
|
-
# When falls on Saturday, no holiday is observed.
|
213
|
-
# When falls on Sunday, the Monday following is a holiday.
|
214
|
-
##########################################################
|
215
|
-
USVeteransDay = Holiday(
|
216
|
-
"Veterans Day",
|
217
|
-
month=11,
|
218
|
-
day=11,
|
219
|
-
# SIFMA guidance for observing only Mon-Fri or Sunday->Monday
|
220
|
-
# appears consistent for many years. This rule doesn't specify
|
221
|
-
# a start_date, letting it apply further back if needed by other logic,
|
222
|
-
# while effectively covering 2023+ due to the days_of_week filter.
|
223
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
224
|
-
observance=sunday_to_monday,
|
225
|
-
)
|
226
|
-
|
227
|
-
################################################
|
228
|
-
# US Thanksgiving Nov 30
|
229
|
-
################################################
|
230
|
-
USThanksgivingDay = Holiday("Thanksgiving", month=11, day=1, offset=DateOffset(weekday=TH(4)))
|
231
|
-
|
232
|
-
DayAfterThanksgiving2pmEarlyClose = Holiday(
|
233
|
-
"Black Friday",
|
234
|
-
month=11,
|
235
|
-
day=1,
|
236
|
-
offset=[DateOffset(weekday=TH(4)), Day(1)],
|
237
|
-
)
|
238
|
-
|
239
|
-
################################
|
240
|
-
# Christmas Dec 25
|
241
|
-
################################
|
242
|
-
Christmas = Holiday(
|
243
|
-
"Christmas",
|
244
|
-
month=12,
|
245
|
-
day=25,
|
246
|
-
observance=nearest_workday,
|
247
|
-
)
|
248
|
-
|
249
|
-
ChristmasEve2pmEarlyClose = Holiday(
|
250
|
-
"Christmas Eve",
|
251
|
-
month=12,
|
252
|
-
day=25,
|
253
|
-
observance=previous_workday,
|
254
|
-
)
|
255
|
-
|
256
|
-
# When Christmas is on a Saturday it is observed on Friday the 24th
|
257
|
-
# Early close on Thursday 23rd
|
258
|
-
ChristmasEveThursday2pmEarlyClose = Holiday(
|
259
|
-
"Christmas Eve on Thursday",
|
260
|
-
month=12,
|
261
|
-
day=23,
|
262
|
-
days_of_week=(THURSDAY,),
|
263
|
-
)
|
264
|
-
|
265
|
-
############################################################################
|
266
|
-
# UK Specific Holidays
|
267
|
-
############################################################################
|
268
|
-
|
269
|
-
# Remarkably, in 2022 SIFMA recommended NO new year's day observance in the US (Saturday)
|
270
|
-
# but in the UK it was observed on Monday requiring a different rule
|
271
|
-
UKNewYearsDay = Holiday(
|
272
|
-
"New Years Day",
|
273
|
-
month=1,
|
274
|
-
day=1,
|
275
|
-
observance=next_monday,
|
276
|
-
)
|
277
|
-
|
278
|
-
UKGoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(), Day(-2)])
|
279
|
-
|
280
|
-
UKEasterMonday = Holiday("Easter Monday", month=1, day=1, offset=[Easter(), Day(+1)])
|
281
|
-
|
282
|
-
# Observed first Monday in May
|
283
|
-
UKMayDay = Holiday(
|
284
|
-
"May Day",
|
285
|
-
month=5,
|
286
|
-
day=1,
|
287
|
-
offset=DateOffset(weekday=MO(1)),
|
288
|
-
)
|
289
|
-
|
290
|
-
# Almost always follows US Memorial Day except for
|
291
|
-
UKSpringBankAdHoc = [
|
292
|
-
Timestamp("2022-06-02", tz="UTC"),
|
293
|
-
]
|
294
|
-
|
295
|
-
UKPlatinumJubilee2022 = [
|
296
|
-
Timestamp("2022-06-03", tz="UTC"),
|
297
|
-
]
|
298
|
-
|
299
|
-
# Observed last Monday in August in England, Wales, and Northern Ireland
|
300
|
-
# Observed first Monday in August in Scotland
|
301
|
-
# Coded as last Monday
|
302
|
-
# https://www.timeanddate.com/holidays/uk/summer-bank-holiday
|
303
|
-
UKSummerBank = Holiday(
|
304
|
-
"Summer Bank Holiday",
|
305
|
-
month=8,
|
306
|
-
day=30,
|
307
|
-
offset=DateOffset(weekday=MO(-1)),
|
308
|
-
)
|
309
|
-
|
310
|
-
# UK observes Christmas on Tuesday when Boxing Day is on Monday
|
311
|
-
# UK observes Christmas on Monday when Christmas is on Saturday
|
312
|
-
UKChristmaEve = Holiday(
|
313
|
-
"Christmas",
|
314
|
-
month=12,
|
315
|
-
day=24,
|
316
|
-
days_of_week=(FRIDAY,),
|
317
|
-
)
|
318
|
-
|
319
|
-
UKChristmas = Holiday(
|
320
|
-
"Christmas",
|
321
|
-
month=12,
|
322
|
-
day=25,
|
323
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
324
|
-
)
|
325
|
-
|
326
|
-
# If christmas day is Saturday Monday 27th is a holiday
|
327
|
-
# If christmas day is sunday the Tuesday 27th is a holiday
|
328
|
-
UKWeekendChristmas = Holiday(
|
329
|
-
"Weekend Christmas",
|
330
|
-
month=12,
|
331
|
-
day=27,
|
332
|
-
days_of_week=(MONDAY, TUESDAY),
|
333
|
-
)
|
334
|
-
|
335
|
-
# Boxing day
|
336
|
-
UKBoxingDay = Holiday(
|
337
|
-
"Boxing Day",
|
338
|
-
month=12,
|
339
|
-
day=26,
|
340
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
341
|
-
)
|
342
|
-
|
343
|
-
# If boxing day is saturday then Monday 28th is a holiday
|
344
|
-
# If boxing day is sunday then Tuesday 28th is a holiday
|
345
|
-
UKWeekendBoxingDay = Holiday(
|
346
|
-
"Weekend Boxing Day",
|
347
|
-
month=12,
|
348
|
-
day=28,
|
349
|
-
days_of_week=(MONDAY, TUESDAY),
|
350
|
-
)
|
1
|
+
from dateutil.relativedelta import MO, TH
|
2
|
+
from pandas import DateOffset, Timestamp
|
3
|
+
from pandas.tseries.holiday import (
|
4
|
+
Holiday,
|
5
|
+
nearest_workday,
|
6
|
+
next_monday,
|
7
|
+
sunday_to_monday,
|
8
|
+
previous_workday,
|
9
|
+
Easter,
|
10
|
+
)
|
11
|
+
from pandas.tseries.offsets import Day
|
12
|
+
|
13
|
+
from pandas_market_calendars.market_calendar import (
|
14
|
+
MONDAY,
|
15
|
+
TUESDAY,
|
16
|
+
WEDNESDAY,
|
17
|
+
THURSDAY,
|
18
|
+
FRIDAY,
|
19
|
+
)
|
20
|
+
|
21
|
+
####################################################
|
22
|
+
# US New Years Day Jan 1
|
23
|
+
# When Jan 1 is a Sunday, US markets observe the subsequent Monday.
|
24
|
+
# When Jan 1 is a Saturday (as in 2005 and 2011), no holiday is observed.
|
25
|
+
#####################################################
|
26
|
+
USNewYearsDay = Holiday(
|
27
|
+
"New Years Day US",
|
28
|
+
month=1,
|
29
|
+
day=1,
|
30
|
+
days_of_week=(
|
31
|
+
MONDAY,
|
32
|
+
TUESDAY,
|
33
|
+
WEDNESDAY,
|
34
|
+
THURSDAY,
|
35
|
+
FRIDAY,
|
36
|
+
),
|
37
|
+
observance=sunday_to_monday,
|
38
|
+
)
|
39
|
+
|
40
|
+
USNewYearsEve2pmEarlyClose = Holiday(
|
41
|
+
"New Years Eve US",
|
42
|
+
month=1,
|
43
|
+
day=1,
|
44
|
+
days_of_week=(
|
45
|
+
MONDAY,
|
46
|
+
TUESDAY,
|
47
|
+
WEDNESDAY,
|
48
|
+
THURSDAY,
|
49
|
+
FRIDAY,
|
50
|
+
),
|
51
|
+
observance=previous_workday,
|
52
|
+
)
|
53
|
+
|
54
|
+
#########################################################################
|
55
|
+
# Martin Luther King Jr
|
56
|
+
##########################################################################
|
57
|
+
MartinLutherKingJr = Holiday(
|
58
|
+
"Dr. Martin Luther King Jr. Day",
|
59
|
+
month=1,
|
60
|
+
day=1,
|
61
|
+
days_of_week=(
|
62
|
+
MONDAY,
|
63
|
+
TUESDAY,
|
64
|
+
WEDNESDAY,
|
65
|
+
THURSDAY,
|
66
|
+
FRIDAY,
|
67
|
+
),
|
68
|
+
offset=DateOffset(weekday=MO(3)),
|
69
|
+
)
|
70
|
+
|
71
|
+
#########################################################################
|
72
|
+
# US Presidents Day Feb
|
73
|
+
##########################################################################
|
74
|
+
USPresidentsDay = Holiday(
|
75
|
+
"President" "s Day",
|
76
|
+
start_date=Timestamp("1971-01-01"),
|
77
|
+
month=2,
|
78
|
+
day=1,
|
79
|
+
days_of_week=(
|
80
|
+
MONDAY,
|
81
|
+
TUESDAY,
|
82
|
+
WEDNESDAY,
|
83
|
+
THURSDAY,
|
84
|
+
FRIDAY,
|
85
|
+
),
|
86
|
+
offset=DateOffset(weekday=MO(3)),
|
87
|
+
)
|
88
|
+
|
89
|
+
############################################################
|
90
|
+
# Good Friday
|
91
|
+
############################################################
|
92
|
+
|
93
|
+
|
94
|
+
def is_first_friday(dt):
|
95
|
+
"""Check if date is the first Friday of the month"""
|
96
|
+
# The first Friday of any month must occur on or before the 7th.
|
97
|
+
# This check is sufficient regardless of whether Good Friday is in March or April.
|
98
|
+
return dt.weekday() == FRIDAY and dt.day <= 7
|
99
|
+
|
100
|
+
|
101
|
+
GoodFridayThru2020 = Holiday(
|
102
|
+
"Good Friday Thru 2020",
|
103
|
+
end_date=Timestamp("2020-12-31"),
|
104
|
+
month=1,
|
105
|
+
day=1,
|
106
|
+
offset=[Easter(), Day(-2)],
|
107
|
+
)
|
108
|
+
|
109
|
+
# Generate potential Good Friday dates post 2020 (will be filtered in calendar class)
|
110
|
+
GoodFridayPotentialPost2020 = Holiday(
|
111
|
+
"Good Friday Potential Post 2020",
|
112
|
+
start_date=Timestamp("2021-01-01"),
|
113
|
+
month=1,
|
114
|
+
day=1,
|
115
|
+
offset=[Easter(), Day(-2)],
|
116
|
+
)
|
117
|
+
|
118
|
+
DayBeforeGoodFriday2pmEarlyCloseThru2020 = Holiday(
|
119
|
+
"Day Before Good Friday Thru 2020",
|
120
|
+
end_date=Timestamp("2020-12-31"),
|
121
|
+
month=1,
|
122
|
+
day=1,
|
123
|
+
offset=[Easter(), Day(-3)],
|
124
|
+
)
|
125
|
+
|
126
|
+
# Generate potential Thursday before Good Friday dates post 2020 (will be filtered in calendar class)
|
127
|
+
DayBeforeGoodFridayPotentialPost2020 = Holiday(
|
128
|
+
"Day Before Good Friday Potential Post 2020",
|
129
|
+
start_date=Timestamp("2021-01-01"),
|
130
|
+
month=1,
|
131
|
+
day=1,
|
132
|
+
offset=[Easter(), Day(-3)],
|
133
|
+
)
|
134
|
+
|
135
|
+
##################################################
|
136
|
+
# US Memorial Day (Decoration Day) May 30
|
137
|
+
# Closed every year since 1873
|
138
|
+
# Observed on Monday since 1971
|
139
|
+
##################################################
|
140
|
+
USMemorialDay = Holiday(
|
141
|
+
"Memorial Day",
|
142
|
+
month=5,
|
143
|
+
day=25,
|
144
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
145
|
+
offset=DateOffset(weekday=MO(1)),
|
146
|
+
)
|
147
|
+
|
148
|
+
DayBeforeUSMemorialDay2pmEarlyClose = Holiday(
|
149
|
+
"Day Before Memorial Day",
|
150
|
+
month=5,
|
151
|
+
day=25,
|
152
|
+
offset=[DateOffset(weekday=MO(1)), Day(-3)],
|
153
|
+
)
|
154
|
+
|
155
|
+
#######################################
|
156
|
+
# US Juneteenth (June 19th)
|
157
|
+
#######################################
|
158
|
+
USJuneteenthAfter2022 = Holiday(
|
159
|
+
"Juneteenth Starting at 2022",
|
160
|
+
start_date=Timestamp("2022-06-19"),
|
161
|
+
month=6,
|
162
|
+
day=19,
|
163
|
+
observance=nearest_workday,
|
164
|
+
)
|
165
|
+
|
166
|
+
#######################################
|
167
|
+
# US Independence Day July 4
|
168
|
+
#######################################
|
169
|
+
USIndependenceDay = Holiday(
|
170
|
+
"July 4th",
|
171
|
+
month=7,
|
172
|
+
day=4,
|
173
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
174
|
+
observance=nearest_workday,
|
175
|
+
)
|
176
|
+
|
177
|
+
# Day before Independence Day
|
178
|
+
DayBeforeUSIndependenceDay2pmEarlyClose = Holiday(
|
179
|
+
"Day Before Independence Day",
|
180
|
+
month=7,
|
181
|
+
day=4,
|
182
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
183
|
+
observance=previous_workday,
|
184
|
+
)
|
185
|
+
|
186
|
+
# When July 4th is a Saturday, the previous Friday is a holiday
|
187
|
+
# and the previous Thursday is an early close
|
188
|
+
ThursdayBeforeUSIndependenceDay2pmEarlyClose = Holiday(
|
189
|
+
"Thursday Before Independence Day",
|
190
|
+
month=7,
|
191
|
+
day=2,
|
192
|
+
days_of_week=(THURSDAY,),
|
193
|
+
)
|
194
|
+
|
195
|
+
#################################################
|
196
|
+
# US Labor Day
|
197
|
+
#################################################
|
198
|
+
USLaborDay = Holiday("Labor Day", month=9, day=1, offset=DateOffset(weekday=MO(1)))
|
199
|
+
|
200
|
+
#################################################
|
201
|
+
# Columbus Day
|
202
|
+
#################################################
|
203
|
+
USColumbusDay = Holiday(
|
204
|
+
"Columbus Day",
|
205
|
+
month=10,
|
206
|
+
day=1,
|
207
|
+
offset=DateOffset(weekday=MO(2)),
|
208
|
+
)
|
209
|
+
|
210
|
+
##########################################################
|
211
|
+
# Armistice/Veterans day
|
212
|
+
# When falls on Saturday, no holiday is observed.
|
213
|
+
# When falls on Sunday, the Monday following is a holiday.
|
214
|
+
##########################################################
|
215
|
+
USVeteransDay = Holiday(
|
216
|
+
"Veterans Day",
|
217
|
+
month=11,
|
218
|
+
day=11,
|
219
|
+
# SIFMA guidance for observing only Mon-Fri or Sunday->Monday
|
220
|
+
# appears consistent for many years. This rule doesn't specify
|
221
|
+
# a start_date, letting it apply further back if needed by other logic,
|
222
|
+
# while effectively covering 2023+ due to the days_of_week filter.
|
223
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
224
|
+
observance=sunday_to_monday,
|
225
|
+
)
|
226
|
+
|
227
|
+
################################################
|
228
|
+
# US Thanksgiving Nov 30
|
229
|
+
################################################
|
230
|
+
USThanksgivingDay = Holiday("Thanksgiving", month=11, day=1, offset=DateOffset(weekday=TH(4)))
|
231
|
+
|
232
|
+
DayAfterThanksgiving2pmEarlyClose = Holiday(
|
233
|
+
"Black Friday",
|
234
|
+
month=11,
|
235
|
+
day=1,
|
236
|
+
offset=[DateOffset(weekday=TH(4)), Day(1)],
|
237
|
+
)
|
238
|
+
|
239
|
+
################################
|
240
|
+
# Christmas Dec 25
|
241
|
+
################################
|
242
|
+
Christmas = Holiday(
|
243
|
+
"Christmas",
|
244
|
+
month=12,
|
245
|
+
day=25,
|
246
|
+
observance=nearest_workday,
|
247
|
+
)
|
248
|
+
|
249
|
+
ChristmasEve2pmEarlyClose = Holiday(
|
250
|
+
"Christmas Eve",
|
251
|
+
month=12,
|
252
|
+
day=25,
|
253
|
+
observance=previous_workday,
|
254
|
+
)
|
255
|
+
|
256
|
+
# When Christmas is on a Saturday it is observed on Friday the 24th
|
257
|
+
# Early close on Thursday 23rd
|
258
|
+
ChristmasEveThursday2pmEarlyClose = Holiday(
|
259
|
+
"Christmas Eve on Thursday",
|
260
|
+
month=12,
|
261
|
+
day=23,
|
262
|
+
days_of_week=(THURSDAY,),
|
263
|
+
)
|
264
|
+
|
265
|
+
############################################################################
|
266
|
+
# UK Specific Holidays
|
267
|
+
############################################################################
|
268
|
+
|
269
|
+
# Remarkably, in 2022 SIFMA recommended NO new year's day observance in the US (Saturday)
|
270
|
+
# but in the UK it was observed on Monday requiring a different rule
|
271
|
+
UKNewYearsDay = Holiday(
|
272
|
+
"New Years Day",
|
273
|
+
month=1,
|
274
|
+
day=1,
|
275
|
+
observance=next_monday,
|
276
|
+
)
|
277
|
+
|
278
|
+
UKGoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(), Day(-2)])
|
279
|
+
|
280
|
+
UKEasterMonday = Holiday("Easter Monday", month=1, day=1, offset=[Easter(), Day(+1)])
|
281
|
+
|
282
|
+
# Observed first Monday in May
|
283
|
+
UKMayDay = Holiday(
|
284
|
+
"May Day",
|
285
|
+
month=5,
|
286
|
+
day=1,
|
287
|
+
offset=DateOffset(weekday=MO(1)),
|
288
|
+
)
|
289
|
+
|
290
|
+
# Almost always follows US Memorial Day except for
|
291
|
+
UKSpringBankAdHoc = [
|
292
|
+
Timestamp("2022-06-02", tz="UTC"),
|
293
|
+
]
|
294
|
+
|
295
|
+
UKPlatinumJubilee2022 = [
|
296
|
+
Timestamp("2022-06-03", tz="UTC"),
|
297
|
+
]
|
298
|
+
|
299
|
+
# Observed last Monday in August in England, Wales, and Northern Ireland
|
300
|
+
# Observed first Monday in August in Scotland
|
301
|
+
# Coded as last Monday
|
302
|
+
# https://www.timeanddate.com/holidays/uk/summer-bank-holiday
|
303
|
+
UKSummerBank = Holiday(
|
304
|
+
"Summer Bank Holiday",
|
305
|
+
month=8,
|
306
|
+
day=30,
|
307
|
+
offset=DateOffset(weekday=MO(-1)),
|
308
|
+
)
|
309
|
+
|
310
|
+
# UK observes Christmas on Tuesday when Boxing Day is on Monday
|
311
|
+
# UK observes Christmas on Monday when Christmas is on Saturday
|
312
|
+
UKChristmaEve = Holiday(
|
313
|
+
"Christmas",
|
314
|
+
month=12,
|
315
|
+
day=24,
|
316
|
+
days_of_week=(FRIDAY,),
|
317
|
+
)
|
318
|
+
|
319
|
+
UKChristmas = Holiday(
|
320
|
+
"Christmas",
|
321
|
+
month=12,
|
322
|
+
day=25,
|
323
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
324
|
+
)
|
325
|
+
|
326
|
+
# If christmas day is Saturday Monday 27th is a holiday
|
327
|
+
# If christmas day is sunday the Tuesday 27th is a holiday
|
328
|
+
UKWeekendChristmas = Holiday(
|
329
|
+
"Weekend Christmas",
|
330
|
+
month=12,
|
331
|
+
day=27,
|
332
|
+
days_of_week=(MONDAY, TUESDAY),
|
333
|
+
)
|
334
|
+
|
335
|
+
# Boxing day
|
336
|
+
UKBoxingDay = Holiday(
|
337
|
+
"Boxing Day",
|
338
|
+
month=12,
|
339
|
+
day=26,
|
340
|
+
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
|
341
|
+
)
|
342
|
+
|
343
|
+
# If boxing day is saturday then Monday 28th is a holiday
|
344
|
+
# If boxing day is sunday then Tuesday 28th is a holiday
|
345
|
+
UKWeekendBoxingDay = Holiday(
|
346
|
+
"Weekend Boxing Day",
|
347
|
+
month=12,
|
348
|
+
day=28,
|
349
|
+
days_of_week=(MONDAY, TUESDAY),
|
350
|
+
)
|