pandas-market-calendars 4.3.2__py3-none-any.whl → 4.3.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pandas_market_calendars/__init__.py +38 -38
- pandas_market_calendars/calendar_registry.py +53 -52
- pandas_market_calendars/calendar_utils.py +261 -261
- pandas_market_calendars/calendars/asx.py +66 -66
- pandas_market_calendars/calendars/bmf.py +206 -206
- pandas_market_calendars/calendars/bse.py +407 -407
- pandas_market_calendars/calendars/cboe.py +145 -145
- pandas_market_calendars/calendars/cme.py +402 -402
- pandas_market_calendars/calendars/cme_globex_agriculture.py +126 -127
- pandas_market_calendars/calendars/cme_globex_base.py +119 -119
- pandas_market_calendars/calendars/cme_globex_crypto.py +160 -147
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -216
- pandas_market_calendars/calendars/cme_globex_equities.py +123 -121
- pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -134
- pandas_market_calendars/calendars/cme_globex_fx.py +101 -92
- pandas_market_calendars/calendars/eurex.py +139 -139
- pandas_market_calendars/calendars/eurex_fixed_income.py +98 -0
- pandas_market_calendars/calendars/hkex.py +426 -426
- pandas_market_calendars/calendars/ice.py +81 -81
- pandas_market_calendars/calendars/iex.py +112 -111
- pandas_market_calendars/calendars/jpx.py +109 -109
- pandas_market_calendars/calendars/lse.py +114 -114
- pandas_market_calendars/calendars/mirror.py +130 -129
- pandas_market_calendars/calendars/nyse.py +1324 -1324
- pandas_market_calendars/calendars/ose.py +116 -116
- pandas_market_calendars/calendars/sifma.py +350 -335
- pandas_market_calendars/calendars/six.py +132 -132
- pandas_market_calendars/calendars/sse.py +311 -311
- pandas_market_calendars/calendars/tase.py +197 -195
- pandas_market_calendars/calendars/tsx.py +181 -181
- pandas_market_calendars/holidays/cme.py +385 -372
- pandas_market_calendars/holidays/cme_globex.py +214 -223
- pandas_market_calendars/holidays/cn.py +1455 -1455
- pandas_market_calendars/holidays/jp.py +398 -394
- pandas_market_calendars/holidays/nyse.py +1531 -1539
- pandas_market_calendars/holidays/oz.py +63 -65
- pandas_market_calendars/holidays/sifma.py +338 -350
- pandas_market_calendars/holidays/us.py +376 -377
- pandas_market_calendars/market_calendar.py +895 -895
- {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/METADATA +3 -3
- pandas_market_calendars-4.3.3.dist-info/RECORD +50 -0
- pandas_market_calendars-4.3.2.dist-info/RECORD +0 -49
- {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/NOTICE +0 -0
- {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/WHEEL +0 -0
- {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/top_level.txt +0 -0
@@ -1,372 +1,385 @@
|
|
1
|
-
import datetime
|
2
|
-
|
3
|
-
from dateutil.relativedelta import MO, TH, FR
|
4
|
-
from pandas import DateOffset, Timestamp
|
5
|
-
from pandas.tseries.holiday import Holiday, Easter
|
6
|
-
from pandas.tseries.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#########
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#########
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
"
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
"
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
#########
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
return
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
"
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
"
|
180
|
-
month=
|
181
|
-
day=
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
)
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
"
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
"
|
216
|
-
month=
|
217
|
-
day=
|
218
|
-
start_date=Timestamp("
|
219
|
-
end_date=Timestamp("
|
220
|
-
|
221
|
-
)
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
"
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
)
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
)
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
"
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
"
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
"
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
)
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
#
|
334
|
-
#
|
335
|
-
#
|
336
|
-
|
337
|
-
#
|
338
|
-
#
|
339
|
-
# '
|
340
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
1
|
+
import datetime
|
2
|
+
|
3
|
+
from dateutil.relativedelta import MO, TH, FR
|
4
|
+
from pandas import DateOffset, Timestamp
|
5
|
+
from pandas.tseries.holiday import Holiday, Easter, nearest_workday
|
6
|
+
from pandas.tseries.offsets import Day
|
7
|
+
|
8
|
+
#########
|
9
|
+
# Martin Luther King
|
10
|
+
#########
|
11
|
+
USMartinLutherKingJrAfter1998Before2022 = Holiday(
|
12
|
+
"Dr. Martin Luther King Jr. Day",
|
13
|
+
month=1,
|
14
|
+
day=1,
|
15
|
+
# The US markets didn't observe MLK day as a holiday until 1998.
|
16
|
+
start_date=Timestamp("1998-01-01"),
|
17
|
+
end_date=Timestamp("2021-12-31"),
|
18
|
+
offset=DateOffset(weekday=MO(3)),
|
19
|
+
)
|
20
|
+
|
21
|
+
USMartinLutherKingJrAfter1998Before2015 = Holiday(
|
22
|
+
"Dr. Martin Luther King Jr. Day",
|
23
|
+
month=1,
|
24
|
+
day=1,
|
25
|
+
# The US markets didn't observe MLK day as a holiday until 1998.
|
26
|
+
start_date=Timestamp("1998-01-01"),
|
27
|
+
end_date=Timestamp("2014-12-31"),
|
28
|
+
offset=DateOffset(weekday=MO(3)),
|
29
|
+
)
|
30
|
+
|
31
|
+
USMartinLutherKingJrAfter2015 = Holiday(
|
32
|
+
"Dr. Martin Luther King Jr. Day",
|
33
|
+
month=1,
|
34
|
+
day=1,
|
35
|
+
# The US markets didn't observe MLK day as a holiday until 1998.
|
36
|
+
start_date=Timestamp("2015-01-01"),
|
37
|
+
offset=DateOffset(weekday=MO(3)),
|
38
|
+
)
|
39
|
+
|
40
|
+
USMartinLutherKingJrAfter1998Before2016FridayBefore = Holiday(
|
41
|
+
"Dr. Martin Luther King Jr. Day",
|
42
|
+
month=1,
|
43
|
+
day=1,
|
44
|
+
start_date=Timestamp("1998-01-01"),
|
45
|
+
end_date=Timestamp("2015-12-31"),
|
46
|
+
offset=[DateOffset(weekday=MO(3)), DateOffset(weekday=FR(-1))],
|
47
|
+
)
|
48
|
+
|
49
|
+
#########
|
50
|
+
# President's Day
|
51
|
+
#########
|
52
|
+
USPresidentsDayBefore2022 = Holiday(
|
53
|
+
"President" "s Day",
|
54
|
+
start_date=Timestamp("1971-01-01"),
|
55
|
+
end_date=Timestamp("2021-12-31"),
|
56
|
+
month=2,
|
57
|
+
day=1,
|
58
|
+
offset=DateOffset(weekday=MO(3)),
|
59
|
+
)
|
60
|
+
USPresidentsDayBefore2015 = Holiday(
|
61
|
+
"President" "s Day",
|
62
|
+
start_date=Timestamp("1971-01-01"),
|
63
|
+
end_date=Timestamp("2014-12-31"),
|
64
|
+
month=2,
|
65
|
+
day=1,
|
66
|
+
offset=DateOffset(weekday=MO(3)),
|
67
|
+
)
|
68
|
+
|
69
|
+
USPresidentsDayAfter2015 = Holiday(
|
70
|
+
"President" "s Day",
|
71
|
+
start_date=Timestamp("2015-01-01"),
|
72
|
+
month=2,
|
73
|
+
day=1,
|
74
|
+
offset=DateOffset(weekday=MO(3)),
|
75
|
+
)
|
76
|
+
|
77
|
+
USPresidentsDayBefore2016FridayBefore = Holiday(
|
78
|
+
"President" "s Day",
|
79
|
+
start_date=Timestamp("1971-01-01"),
|
80
|
+
end_date=Timestamp("2015-12-31"),
|
81
|
+
month=2,
|
82
|
+
day=1,
|
83
|
+
offset=[DateOffset(weekday=MO(3)), DateOffset(weekday=FR(-1))],
|
84
|
+
)
|
85
|
+
|
86
|
+
#########
|
87
|
+
# Good Friday
|
88
|
+
#########
|
89
|
+
|
90
|
+
|
91
|
+
GoodFridayBefore2021 = Holiday(
|
92
|
+
"Good Friday",
|
93
|
+
month=1,
|
94
|
+
day=1,
|
95
|
+
offset=[Easter(), Day(-2)],
|
96
|
+
end_date=Timestamp("2020-12-31"),
|
97
|
+
)
|
98
|
+
|
99
|
+
# On some years (i.e. 2010,2012,2015) there is a special close for equities at 08:15
|
100
|
+
# so here it is made sure that those are not full holidays
|
101
|
+
easter = Easter()
|
102
|
+
daymin2 = Day(-2)
|
103
|
+
|
104
|
+
|
105
|
+
def not_0815_close(dt):
|
106
|
+
if dt.year in (2010, 2012, 2015):
|
107
|
+
return None
|
108
|
+
else:
|
109
|
+
return dt + easter + daymin2
|
110
|
+
|
111
|
+
|
112
|
+
GoodFridayBefore2021NotEarlyClose = Holiday(
|
113
|
+
"Good Friday",
|
114
|
+
month=1,
|
115
|
+
day=1,
|
116
|
+
observance=not_0815_close,
|
117
|
+
end_date=Timestamp("2020-12-31"),
|
118
|
+
)
|
119
|
+
|
120
|
+
# CME Interest Rate Products have this odd close
|
121
|
+
GoodFriday2009 = Holiday(
|
122
|
+
"Good Friday",
|
123
|
+
month=1,
|
124
|
+
day=1,
|
125
|
+
offset=[Easter(), Day(-3)],
|
126
|
+
start_date=Timestamp("2009-01-01"),
|
127
|
+
end_date=Timestamp("2009-12-31"),
|
128
|
+
)
|
129
|
+
|
130
|
+
GoodFriday2021 = Holiday(
|
131
|
+
"Good Friday",
|
132
|
+
month=1,
|
133
|
+
day=1,
|
134
|
+
offset=[Easter(), Day(-2)],
|
135
|
+
start_date=Timestamp("2021-01-01"),
|
136
|
+
end_date=Timestamp("2021-12-31"),
|
137
|
+
)
|
138
|
+
GoodFridayAfter2021 = Holiday(
|
139
|
+
"Good Friday",
|
140
|
+
month=1,
|
141
|
+
day=1,
|
142
|
+
offset=[Easter(), Day(-2)],
|
143
|
+
start_date=Timestamp("2022-01-01"),
|
144
|
+
)
|
145
|
+
GoodFriday2022 = Holiday(
|
146
|
+
"Good Friday",
|
147
|
+
month=1,
|
148
|
+
day=1,
|
149
|
+
offset=[Easter(), Day(-2)],
|
150
|
+
start_date=Timestamp("2022-01-01"),
|
151
|
+
end_date=Timestamp("2022-12-31"),
|
152
|
+
)
|
153
|
+
GoodFridayAfter2022 = Holiday(
|
154
|
+
"Good Friday",
|
155
|
+
month=1,
|
156
|
+
day=1,
|
157
|
+
offset=[Easter(), Day(-2)],
|
158
|
+
start_date=Timestamp("2023-01-01"),
|
159
|
+
)
|
160
|
+
# Dates when equities closed at 08:15
|
161
|
+
GoodFriday2010 = Holiday(
|
162
|
+
"Good Friday",
|
163
|
+
month=1,
|
164
|
+
day=1,
|
165
|
+
offset=[Easter(), Day(-2)],
|
166
|
+
start_date=Timestamp("2010-01-01"),
|
167
|
+
end_date=Timestamp("2010-12-31"),
|
168
|
+
)
|
169
|
+
GoodFriday2012 = Holiday(
|
170
|
+
"Good Friday",
|
171
|
+
month=1,
|
172
|
+
day=1,
|
173
|
+
offset=[Easter(), Day(-2)],
|
174
|
+
start_date=Timestamp("2012-01-01"),
|
175
|
+
end_date=Timestamp("2012-12-31"),
|
176
|
+
)
|
177
|
+
|
178
|
+
GoodFriday2015 = Holiday(
|
179
|
+
"Good Friday",
|
180
|
+
month=1,
|
181
|
+
day=1,
|
182
|
+
offset=[Easter(), Day(-2)],
|
183
|
+
start_date=Timestamp("2015-01-01"),
|
184
|
+
end_date=Timestamp("2015-12-31"),
|
185
|
+
)
|
186
|
+
|
187
|
+
#########
|
188
|
+
# Memorial Day
|
189
|
+
#########
|
190
|
+
|
191
|
+
USMemorialDay2021AndPrior = Holiday(
|
192
|
+
"Memorial Day",
|
193
|
+
month=5,
|
194
|
+
day=25,
|
195
|
+
start_date=Timestamp("1971-01-01"),
|
196
|
+
end_date=Timestamp("2021-12-31"),
|
197
|
+
offset=DateOffset(weekday=MO(1)),
|
198
|
+
) # Equity Products
|
199
|
+
USMemorialDay2013AndPrior = Holiday(
|
200
|
+
"Memorial Day",
|
201
|
+
month=5,
|
202
|
+
day=25,
|
203
|
+
start_date=Timestamp("1971-01-01"),
|
204
|
+
end_date=Timestamp("2013-12-31"),
|
205
|
+
offset=DateOffset(weekday=MO(1)),
|
206
|
+
)
|
207
|
+
USMemorialDayAfter2013 = Holiday(
|
208
|
+
"Memorial Day",
|
209
|
+
month=5,
|
210
|
+
day=25,
|
211
|
+
start_date=Timestamp("2014-01-01"),
|
212
|
+
offset=DateOffset(weekday=MO(1)),
|
213
|
+
)
|
214
|
+
USMemorialDay2015AndPriorFridayBefore = Holiday(
|
215
|
+
"Memorial Day",
|
216
|
+
month=5,
|
217
|
+
day=25,
|
218
|
+
start_date=Timestamp("1971-01-01"),
|
219
|
+
end_date=Timestamp("2015-12-31"),
|
220
|
+
offset=[DateOffset(weekday=MO(1)), DateOffset(weekday=FR(-1))],
|
221
|
+
)
|
222
|
+
|
223
|
+
#######
|
224
|
+
# Independence Day
|
225
|
+
#######
|
226
|
+
|
227
|
+
USIndependenceDayBefore2022 = Holiday(
|
228
|
+
"July 4th",
|
229
|
+
month=7,
|
230
|
+
day=4,
|
231
|
+
start_date=Timestamp("1954-01-01"),
|
232
|
+
end_date=Timestamp("2021-12-31"),
|
233
|
+
observance=nearest_workday,
|
234
|
+
)
|
235
|
+
USIndependenceDayBefore2014 = Holiday(
|
236
|
+
"July 4th",
|
237
|
+
month=7,
|
238
|
+
day=4,
|
239
|
+
start_date=Timestamp("1954-01-01"),
|
240
|
+
end_date=Timestamp("2013-12-31"),
|
241
|
+
observance=nearest_workday,
|
242
|
+
)
|
243
|
+
USIndependenceDayAfter2014 = Holiday(
|
244
|
+
"July 4th",
|
245
|
+
month=7,
|
246
|
+
day=4,
|
247
|
+
start_date=Timestamp("2014-01-01"),
|
248
|
+
observance=nearest_workday,
|
249
|
+
)
|
250
|
+
|
251
|
+
|
252
|
+
# Necessary for equities and crypto
|
253
|
+
def previous_workday_if_july_4th_is_tue_to_fri(dt):
|
254
|
+
july4th = datetime.datetime(dt.year, 7, 4)
|
255
|
+
if july4th.weekday() in (1, 2, 3, 4):
|
256
|
+
return july4th - datetime.timedelta(days=1)
|
257
|
+
# else None
|
258
|
+
|
259
|
+
|
260
|
+
USIndependenceDayBefore2022PreviousDay = Holiday(
|
261
|
+
"July 4th",
|
262
|
+
month=7,
|
263
|
+
day=4,
|
264
|
+
start_date=Timestamp("1954-01-01"),
|
265
|
+
observance=previous_workday_if_july_4th_is_tue_to_fri,
|
266
|
+
)
|
267
|
+
|
268
|
+
#########
|
269
|
+
# Labor Day
|
270
|
+
#########
|
271
|
+
|
272
|
+
USLaborDayStarting1887Before2022 = Holiday(
|
273
|
+
"Labor Day",
|
274
|
+
month=9,
|
275
|
+
day=1,
|
276
|
+
start_date=Timestamp("1887-01-01"),
|
277
|
+
end_date=Timestamp("2021-12-31"),
|
278
|
+
offset=DateOffset(weekday=MO(1)),
|
279
|
+
)
|
280
|
+
USLaborDayStarting1887Before2014 = Holiday(
|
281
|
+
"Labor Day",
|
282
|
+
month=9,
|
283
|
+
day=1,
|
284
|
+
start_date=Timestamp("1887-01-01"),
|
285
|
+
end_date=Timestamp("2013-12-31"),
|
286
|
+
offset=DateOffset(weekday=MO(1)),
|
287
|
+
)
|
288
|
+
USLaborDayStarting1887Before2015FridayBefore = Holiday(
|
289
|
+
"Labor Day",
|
290
|
+
month=9,
|
291
|
+
day=1,
|
292
|
+
start_date=Timestamp("1887-01-01"),
|
293
|
+
end_date=Timestamp("2014-12-31"),
|
294
|
+
offset=[DateOffset(weekday=MO(1)), DateOffset(weekday=FR(-1))],
|
295
|
+
)
|
296
|
+
USLaborDayStarting1887After2014 = Holiday(
|
297
|
+
"Labor Day",
|
298
|
+
month=9,
|
299
|
+
day=1,
|
300
|
+
start_date=Timestamp("2014-01-01"),
|
301
|
+
offset=DateOffset(weekday=MO(1)),
|
302
|
+
)
|
303
|
+
|
304
|
+
#########
|
305
|
+
# Thanksgiving
|
306
|
+
#########
|
307
|
+
|
308
|
+
USThanksgivingBefore2022 = Holiday(
|
309
|
+
"ThanksgivingFriday",
|
310
|
+
start_date=Timestamp("1942-01-01"),
|
311
|
+
end_date=Timestamp("2021-12-31"),
|
312
|
+
month=11,
|
313
|
+
day=1,
|
314
|
+
offset=DateOffset(weekday=TH(4)),
|
315
|
+
)
|
316
|
+
USThanksgivingBefore2014 = Holiday(
|
317
|
+
"ThanksgivingFriday",
|
318
|
+
start_date=Timestamp("1942-01-01"),
|
319
|
+
end_date=Timestamp("2013-12-31"),
|
320
|
+
month=11,
|
321
|
+
day=1,
|
322
|
+
offset=DateOffset(weekday=TH(4)),
|
323
|
+
)
|
324
|
+
USThanksgivingAfter2014 = Holiday(
|
325
|
+
"ThanksgivingFriday",
|
326
|
+
start_date=Timestamp("2014-01-01"),
|
327
|
+
month=11,
|
328
|
+
day=1,
|
329
|
+
offset=DateOffset(weekday=TH(4)),
|
330
|
+
)
|
331
|
+
|
332
|
+
|
333
|
+
# The following Holidays shouldn't be set with the FR offset
|
334
|
+
# In 2013, Nov 1st is a friday, so the 4th Friday is before the 4th Thursday...
|
335
|
+
# the observance rule defined herafter fixes this
|
336
|
+
|
337
|
+
# USThanksgivingFridayBefore2022 = Holiday(
|
338
|
+
# 'ThanksgivingFriday',
|
339
|
+
# start_date=Timestamp('1942-01-01'),
|
340
|
+
# end_date=Timestamp('2021-12-31'),
|
341
|
+
# month=11, day=1,
|
342
|
+
# offset=DateOffset(weekday=FR(4)),
|
343
|
+
# )
|
344
|
+
#
|
345
|
+
# USThanksgivingFriday2022AndAfter = Holiday(
|
346
|
+
# 'ThanksgivingFriday',
|
347
|
+
# start_date=Timestamp('2022-01-01'),
|
348
|
+
# month=11, day=1,
|
349
|
+
# offset=DateOffset(weekday=FR(4)),
|
350
|
+
# )
|
351
|
+
# USThanksgivingFriday = Holiday(
|
352
|
+
# 'ThanksgivingFriday',
|
353
|
+
# month=11, day=1,
|
354
|
+
# offset=DateOffset(weekday=FR(4)),
|
355
|
+
# )
|
356
|
+
|
357
|
+
|
358
|
+
def fri_after_4th_thu(dt):
|
359
|
+
# dt will just be Nov 1st
|
360
|
+
diff_to_thu = 3 - dt.weekday()
|
361
|
+
if diff_to_thu < 0:
|
362
|
+
diff_to_thu += 7
|
363
|
+
return dt + datetime.timedelta(days=diff_to_thu + 22)
|
364
|
+
|
365
|
+
|
366
|
+
USThanksgivingFriday = Holiday(
|
367
|
+
"ThanksgivingFriday",
|
368
|
+
start_date=Timestamp("1942-01-01"),
|
369
|
+
month=11,
|
370
|
+
day=1,
|
371
|
+
observance=fri_after_4th_thu,
|
372
|
+
)
|
373
|
+
|
374
|
+
USThanksgivingFriday2022AndAfter = Holiday(
|
375
|
+
"ThanksgivingFriday",
|
376
|
+
start_date=Timestamp("2022-01-01"),
|
377
|
+
month=11,
|
378
|
+
day=1,
|
379
|
+
observance=fri_after_4th_thu,
|
380
|
+
)
|
381
|
+
# USThanksgivingFriday = Holiday(
|
382
|
+
# 'ThanksgivingFriday',
|
383
|
+
# month=11, day=1,
|
384
|
+
# observance= fri_after_4th_thu,
|
385
|
+
# )
|