pandas-market-calendars 4.1.4__py3-none-any.whl → 4.2.0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- {pandas_market_calendars-4.1.4.dist-info → pandas_market_calendars-4.2.0.dist-info}/METADATA +200 -187
- pandas_market_calendars-4.2.0.dist-info/NOTICE +206 -0
- pandas_market_calendars-4.2.0.dist-info/RECORD +6 -0
- {pandas_market_calendars-4.1.4.dist-info → pandas_market_calendars-4.2.0.dist-info}/WHEEL +1 -1
- pandas_market_calendars/__init__.py +0 -37
- pandas_market_calendars/calendar_registry.py +0 -47
- pandas_market_calendars/calendar_utils.py +0 -225
- pandas_market_calendars/class_registry.py +0 -111
- pandas_market_calendars/exchange_calendar_asx.py +0 -63
- pandas_market_calendars/exchange_calendar_bmf.py +0 -227
- pandas_market_calendars/exchange_calendar_bse.py +0 -409
- pandas_market_calendars/exchange_calendar_cboe.py +0 -115
- pandas_market_calendars/exchange_calendar_cme.py +0 -240
- pandas_market_calendars/exchange_calendar_cme_globex_agriculture.py +0 -109
- pandas_market_calendars/exchange_calendar_cme_globex_base.py +0 -106
- pandas_market_calendars/exchange_calendar_cme_globex_energy_and_metals.py +0 -146
- pandas_market_calendars/exchange_calendar_cme_globex_equities.py +0 -104
- pandas_market_calendars/exchange_calendar_cme_globex_fixed_income.py +0 -114
- pandas_market_calendars/exchange_calendar_cme_globex_fx.py +0 -78
- pandas_market_calendars/exchange_calendar_eurex.py +0 -119
- pandas_market_calendars/exchange_calendar_hkex.py +0 -408
- pandas_market_calendars/exchange_calendar_ice.py +0 -65
- pandas_market_calendars/exchange_calendar_iex.py +0 -98
- pandas_market_calendars/exchange_calendar_jpx.py +0 -98
- pandas_market_calendars/exchange_calendar_lse.py +0 -91
- pandas_market_calendars/exchange_calendar_nyse.py +0 -1127
- pandas_market_calendars/exchange_calendar_ose.py +0 -150
- pandas_market_calendars/exchange_calendar_sifma.py +0 -300
- pandas_market_calendars/exchange_calendar_six.py +0 -114
- pandas_market_calendars/exchange_calendar_sse.py +0 -290
- pandas_market_calendars/exchange_calendar_tase.py +0 -195
- pandas_market_calendars/exchange_calendar_tsx.py +0 -159
- pandas_market_calendars/exchange_calendars_mirror.py +0 -114
- pandas_market_calendars/holidays_cme.py +0 -341
- pandas_market_calendars/holidays_cme_globex.py +0 -169
- pandas_market_calendars/holidays_cn.py +0 -1436
- pandas_market_calendars/holidays_jp.py +0 -362
- pandas_market_calendars/holidays_nyse.py +0 -1474
- pandas_market_calendars/holidays_oz.py +0 -65
- pandas_market_calendars/holidays_sifma.py +0 -321
- pandas_market_calendars/holidays_uk.py +0 -177
- pandas_market_calendars/holidays_us.py +0 -364
- pandas_market_calendars/jpx_equinox.py +0 -147
- pandas_market_calendars/market_calendar.py +0 -770
- pandas_market_calendars-4.1.4.dist-info/RECORD +0 -45
- {pandas_market_calendars-4.1.4.dist-info → pandas_market_calendars-4.2.0.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.1.4.dist-info → pandas_market_calendars-4.2.0.dist-info}/top_level.txt +0 -0
@@ -1,114 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Imported calendars from the exchange_calendars project
|
3
|
-
|
4
|
-
GitHub: https://github.com/gerrymanoim/exchange_calendars
|
5
|
-
"""
|
6
|
-
|
7
|
-
from .market_calendar import MarketCalendar
|
8
|
-
import exchange_calendars
|
9
|
-
|
10
|
-
|
11
|
-
class TradingCalendar(MarketCalendar):
|
12
|
-
"""
|
13
|
-
This class provides access to all the information on opens, breaks and closes that are available
|
14
|
-
in the exchange_calendars package, it will receive the correctly formatted regular_market_times
|
15
|
-
dictionary in the for-loop below.
|
16
|
-
|
17
|
-
The initialization of calendars from exchange_calendars, is bypassed until the `.ec` property is used,
|
18
|
-
which returns the initialized exchange_calendar calendar, which is only initialized the first time.
|
19
|
-
"""
|
20
|
-
# flag indicating that offset still needs to be checked.
|
21
|
-
# A class attribute so we only do this once per class and not per instance
|
22
|
-
_FINALIZE_TRADING_CALENDAR = True
|
23
|
-
|
24
|
-
def __new__(cls, *args, **kwargs):
|
25
|
-
self = super().__new__(cls)
|
26
|
-
self._ec = super().__new__(cls._ec_class)
|
27
|
-
# flag indicating that mirrored class is not initialized yet, which we only want to do
|
28
|
-
# once per instance, if and only if the public `.ec` property is used.
|
29
|
-
self._EC_NOT_INITIALIZED = True
|
30
|
-
|
31
|
-
# offsets of exchange_calendar_mirrors are only available through the instance
|
32
|
-
if cls._FINALIZE_TRADING_CALENDAR:
|
33
|
-
if self._ec.open_offset:
|
34
|
-
cls.regular_market_times._set("market_open", tuple(
|
35
|
-
(t[0], t[1], self._ec.open_offset) for t in cls.regular_market_times["market_open"]))
|
36
|
-
|
37
|
-
if self._ec.close_offset:
|
38
|
-
cls.regular_market_times._set("market_close", tuple(
|
39
|
-
(t[0], t[1], self._ec.close_offset) for t in cls.regular_market_times["market_close"]))
|
40
|
-
cls._FINALIZE_TRADING_CALENDAR = False
|
41
|
-
|
42
|
-
self.__init__(*args, **kwargs)
|
43
|
-
return self
|
44
|
-
|
45
|
-
def __init__(self, open_time=None, close_time=None):
|
46
|
-
super().__init__(open_time, close_time)
|
47
|
-
|
48
|
-
@property
|
49
|
-
def ec(self):
|
50
|
-
if self._EC_NOT_INITIALIZED:
|
51
|
-
self._ec.__init__()
|
52
|
-
self._EC_NOT_INITIALIZED = False
|
53
|
-
|
54
|
-
return self._ec
|
55
|
-
|
56
|
-
@property
|
57
|
-
def name(self):
|
58
|
-
return self._ec.name
|
59
|
-
|
60
|
-
@property
|
61
|
-
def tz(self):
|
62
|
-
return self._ec.tz
|
63
|
-
|
64
|
-
@property
|
65
|
-
def regular_holidays(self):
|
66
|
-
return self._ec.regular_holidays
|
67
|
-
|
68
|
-
@property
|
69
|
-
def adhoc_holidays(self):
|
70
|
-
return self._ec.adhoc_holidays
|
71
|
-
|
72
|
-
@property
|
73
|
-
def special_opens(self):
|
74
|
-
return self._ec.special_opens
|
75
|
-
|
76
|
-
@property
|
77
|
-
def special_opens_adhoc(self):
|
78
|
-
return self._ec.special_opens_adhoc
|
79
|
-
|
80
|
-
@property
|
81
|
-
def special_closes(self):
|
82
|
-
return self._ec.special_closes
|
83
|
-
|
84
|
-
@property
|
85
|
-
def special_closes_adhoc(self):
|
86
|
-
return self._ec.special_closes_adhoc
|
87
|
-
|
88
|
-
|
89
|
-
calendars = exchange_calendars.calendar_utils._default_calendar_factories # noqa
|
90
|
-
|
91
|
-
time_props = dict(open_times= "market_open",
|
92
|
-
close_times= "market_close",
|
93
|
-
break_start_times= "break_start",
|
94
|
-
break_end_times= "break_end")
|
95
|
-
|
96
|
-
for exchange in calendars:
|
97
|
-
cal = calendars[exchange]
|
98
|
-
|
99
|
-
# this loop will set up the newly required regular_market_times dictionary
|
100
|
-
regular_market_times = {}
|
101
|
-
for prop, new in time_props.items():
|
102
|
-
times = getattr(cal, prop)
|
103
|
-
if times is None or isinstance(times, property): continue
|
104
|
-
regular_market_times[new] = times
|
105
|
-
|
106
|
-
cal = type(exchange, (TradingCalendar,), {'_ec_class': calendars[exchange],
|
107
|
-
'alias': [exchange],
|
108
|
-
'regular_market_times': regular_market_times})
|
109
|
-
locals()[exchange + 'ExchangeCalendar'] = cal
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
@@ -1,341 +0,0 @@
|
|
1
|
-
import datetime
|
2
|
-
|
3
|
-
from dateutil.relativedelta import (MO, FR)
|
4
|
-
from dateutil.relativedelta import (TH)
|
5
|
-
from pandas import (DateOffset, Timestamp)
|
6
|
-
from pandas.tseries.holiday import (Holiday, Easter)
|
7
|
-
from pandas.tseries.holiday import (nearest_workday)
|
8
|
-
from pandas.tseries.offsets import (Day)
|
9
|
-
|
10
|
-
|
11
|
-
#########
|
12
|
-
# Martin Luther King
|
13
|
-
#########
|
14
|
-
USMartinLutherKingJrAfter1998Before2022 = Holiday(
|
15
|
-
'Dr. Martin Luther King Jr. Day',
|
16
|
-
month=1,
|
17
|
-
day=1,
|
18
|
-
# The US markets didn't observe MLK day as a holiday until 1998.
|
19
|
-
start_date=Timestamp('1998-01-01'),
|
20
|
-
end_date=Timestamp('2021-12-31'),
|
21
|
-
offset=DateOffset(weekday=MO(3)),
|
22
|
-
)
|
23
|
-
|
24
|
-
USMartinLutherKingJrAfter1998Before2015 = Holiday(
|
25
|
-
'Dr. Martin Luther King Jr. Day',
|
26
|
-
month=1,
|
27
|
-
day=1,
|
28
|
-
# The US markets didn't observe MLK day as a holiday until 1998.
|
29
|
-
start_date=Timestamp('1998-01-01'),
|
30
|
-
end_date=Timestamp('2014-12-31'),
|
31
|
-
offset=DateOffset(weekday=MO(3)),)
|
32
|
-
|
33
|
-
USMartinLutherKingJrAfter2015 = Holiday(
|
34
|
-
'Dr. Martin Luther King Jr. Day',
|
35
|
-
month=1,
|
36
|
-
day=1,
|
37
|
-
# The US markets didn't observe MLK day as a holiday until 1998.
|
38
|
-
start_date=Timestamp('2015-01-01'),
|
39
|
-
offset=DateOffset(weekday=MO(3)),)
|
40
|
-
|
41
|
-
USMartinLutherKingJrAfter1998Before2016FridayBefore = Holiday(
|
42
|
-
"Dr. Martin Luther King Jr. Day",
|
43
|
-
month= 1,
|
44
|
-
day= 1,
|
45
|
-
start_date= Timestamp("1998-01-01"),
|
46
|
-
end_date= Timestamp("2015-12-31"),
|
47
|
-
offset= [DateOffset(weekday= MO(3)), DateOffset(weekday= FR(-1))]
|
48
|
-
)
|
49
|
-
|
50
|
-
#########
|
51
|
-
# President's Day
|
52
|
-
#########
|
53
|
-
USPresidentsDayBefore2022 = Holiday(
|
54
|
-
'President''s Day',
|
55
|
-
start_date=Timestamp('1971-01-01'),
|
56
|
-
end_date=Timestamp('2021-12-31'),
|
57
|
-
month=2, 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, day=1,
|
65
|
-
offset=DateOffset(weekday=MO(3)),)
|
66
|
-
|
67
|
-
USPresidentsDayAfter2015 = Holiday(
|
68
|
-
'President''s Day',
|
69
|
-
start_date=Timestamp('2015-01-01'),
|
70
|
-
month=2, day=1,
|
71
|
-
offset=DateOffset(weekday=MO(3)),)
|
72
|
-
|
73
|
-
USPresidentsDayBefore2016FridayBefore = Holiday(
|
74
|
-
'President''s Day',
|
75
|
-
start_date=Timestamp('1971-01-01'),
|
76
|
-
end_date=Timestamp('2015-12-31'),
|
77
|
-
month=2, day=1,
|
78
|
-
offset=[DateOffset(weekday=MO(3)), DateOffset(weekday= FR(-1))]
|
79
|
-
)
|
80
|
-
|
81
|
-
#########
|
82
|
-
# Good Friday
|
83
|
-
#########
|
84
|
-
|
85
|
-
|
86
|
-
GoodFridayBefore2021 = Holiday(
|
87
|
-
"Good Friday",
|
88
|
-
month=1, day=1,
|
89
|
-
offset=[Easter(), Day(-2)],
|
90
|
-
end_date=Timestamp('2020-12-31'),
|
91
|
-
)
|
92
|
-
|
93
|
-
# On some years (i.e. 2010,2012,2015) there is a special close for equities at 08:15
|
94
|
-
# so here it is made sure that those are not full holidays
|
95
|
-
easter = Easter()
|
96
|
-
daymin2 = Day(-2)
|
97
|
-
def not_0815_close(dt):
|
98
|
-
if dt.year in (2010, 2012, 2015):
|
99
|
-
return None
|
100
|
-
else:
|
101
|
-
return dt + easter + daymin2
|
102
|
-
|
103
|
-
GoodFridayBefore2021NotEarlyClose = Holiday(
|
104
|
-
"Good Friday",
|
105
|
-
month=1, day=1,
|
106
|
-
observance=not_0815_close,
|
107
|
-
end_date=Timestamp('2020-12-31'),
|
108
|
-
)
|
109
|
-
|
110
|
-
## CME Interest Rate Products have this odd close
|
111
|
-
GoodFriday2009 = Holiday(
|
112
|
-
"Good Friday",
|
113
|
-
month= 1, day= 1,
|
114
|
-
offset= [Easter(), Day(-3)],
|
115
|
-
start_date= Timestamp("2009-01-01"),
|
116
|
-
end_date= Timestamp("2009-12-31"),
|
117
|
-
)
|
118
|
-
|
119
|
-
GoodFriday2021 = Holiday(
|
120
|
-
"Good Friday",
|
121
|
-
month=1, day=1,
|
122
|
-
offset=[Easter(), Day(-2)],
|
123
|
-
start_date=Timestamp('2021-01-01'),
|
124
|
-
end_date=Timestamp('2021-12-31'),
|
125
|
-
)
|
126
|
-
GoodFridayAfter2021 = Holiday(
|
127
|
-
"Good Friday",
|
128
|
-
month=1, day=1,
|
129
|
-
offset=[Easter(), Day(-2)],
|
130
|
-
start_date=Timestamp('2022-01-01'),
|
131
|
-
)
|
132
|
-
# Dates when equities closed at 08:15
|
133
|
-
GoodFriday2010 = Holiday(
|
134
|
-
"Good Friday",
|
135
|
-
month=1, day=1,
|
136
|
-
offset=[Easter(), Day(-2)],
|
137
|
-
start_date=Timestamp('2010-01-01'),
|
138
|
-
end_date=Timestamp('2010-12-31'),
|
139
|
-
)
|
140
|
-
GoodFriday2012 = Holiday(
|
141
|
-
"Good Friday",
|
142
|
-
month=1, day=1,
|
143
|
-
offset=[Easter(), Day(-2)],
|
144
|
-
start_date=Timestamp('2012-01-01'),
|
145
|
-
end_date=Timestamp('2012-12-31'),)
|
146
|
-
|
147
|
-
GoodFriday2015 = Holiday(
|
148
|
-
"Good Friday",
|
149
|
-
month=1, day=1,
|
150
|
-
offset=[Easter(), Day(-2)],
|
151
|
-
start_date=Timestamp('2015-01-01'),
|
152
|
-
end_date=Timestamp('2015-12-31'),
|
153
|
-
)
|
154
|
-
|
155
|
-
#########
|
156
|
-
# Memorial Day
|
157
|
-
#########
|
158
|
-
|
159
|
-
USMemorialDay2021AndPrior = Holiday(
|
160
|
-
'Memorial Day',
|
161
|
-
month=5,
|
162
|
-
day=25,
|
163
|
-
start_date=Timestamp('1971-01-01'),
|
164
|
-
end_date=Timestamp('2021-12-31'),
|
165
|
-
offset=DateOffset(weekday=MO(1)),
|
166
|
-
)#### Equity Products
|
167
|
-
USMemorialDay2013AndPrior = Holiday(
|
168
|
-
'Memorial Day',
|
169
|
-
month=5,
|
170
|
-
day=25,
|
171
|
-
start_date=Timestamp('1971-01-01'),
|
172
|
-
end_date=Timestamp('2013-12-31'),
|
173
|
-
offset=DateOffset(weekday=MO(1)),
|
174
|
-
)
|
175
|
-
USMemorialDayAfter2013 = Holiday(
|
176
|
-
'Memorial Day',
|
177
|
-
month=5,
|
178
|
-
day=25,
|
179
|
-
start_date=Timestamp('2014-01-01'),
|
180
|
-
offset=DateOffset(weekday=MO(1)),
|
181
|
-
)
|
182
|
-
USMemorialDay2015AndPriorFridayBefore = Holiday(
|
183
|
-
'Memorial Day',
|
184
|
-
month=5,
|
185
|
-
day=25,
|
186
|
-
start_date=Timestamp('1971-01-01'),
|
187
|
-
end_date=Timestamp('2015-12-31'),
|
188
|
-
offset=[DateOffset(weekday=MO(1)), DateOffset(weekday= FR(-1))],
|
189
|
-
)
|
190
|
-
|
191
|
-
#######
|
192
|
-
# Independence Day
|
193
|
-
#######
|
194
|
-
|
195
|
-
USIndependenceDayBefore2022 = Holiday(
|
196
|
-
'July 4th',
|
197
|
-
month=7,
|
198
|
-
day=4,
|
199
|
-
start_date=Timestamp('1954-01-01'),
|
200
|
-
end_date=Timestamp('2021-12-31'),
|
201
|
-
observance=nearest_workday,)
|
202
|
-
USIndependenceDayBefore2014 = Holiday(
|
203
|
-
'July 4th',
|
204
|
-
month=7,
|
205
|
-
day=4,
|
206
|
-
start_date=Timestamp('1954-01-01'),
|
207
|
-
end_date=Timestamp('2013-12-31'),
|
208
|
-
observance=nearest_workday,)
|
209
|
-
USIndependenceDayAfter2014 = Holiday(
|
210
|
-
'July 4th',
|
211
|
-
month=7,
|
212
|
-
day=4,
|
213
|
-
start_date=Timestamp('2014-01-01'),
|
214
|
-
observance=nearest_workday,)
|
215
|
-
|
216
|
-
# Necessary for equities
|
217
|
-
def previous_workday_if_july_4th_is_tue_to_fri(dt):
|
218
|
-
july4th = datetime.datetime(dt.year, 7, 4)
|
219
|
-
if july4th.weekday() in (1, 2, 3, 4):
|
220
|
-
return july4th - datetime.timedelta(days= 1)
|
221
|
-
# else None
|
222
|
-
|
223
|
-
USIndependenceDayBefore2022PreviousDay = Holiday(
|
224
|
-
'July 4th',
|
225
|
-
month=7,
|
226
|
-
day=4,
|
227
|
-
start_date=Timestamp('1954-01-01'),
|
228
|
-
observance= previous_workday_if_july_4th_is_tue_to_fri
|
229
|
-
)
|
230
|
-
|
231
|
-
#########
|
232
|
-
# Labor Day
|
233
|
-
#########
|
234
|
-
|
235
|
-
USLaborDayStarting1887Before2022 = Holiday(
|
236
|
-
"Labor Day",
|
237
|
-
month=9,
|
238
|
-
day=1,
|
239
|
-
start_date=Timestamp("1887-01-01"),
|
240
|
-
end_date=Timestamp('2021-12-31'),
|
241
|
-
offset=DateOffset(weekday=MO(1))
|
242
|
-
)
|
243
|
-
USLaborDayStarting1887Before2014 = Holiday(
|
244
|
-
"Labor Day",
|
245
|
-
month=9,
|
246
|
-
day=1,
|
247
|
-
start_date=Timestamp("1887-01-01"),
|
248
|
-
end_date=Timestamp('2013-12-31'),
|
249
|
-
offset=DateOffset(weekday=MO(1))
|
250
|
-
)
|
251
|
-
USLaborDayStarting1887Before2015FridayBefore = Holiday(
|
252
|
-
"Labor Day",
|
253
|
-
month=9,
|
254
|
-
day=1,
|
255
|
-
start_date=Timestamp("1887-01-01"),
|
256
|
-
end_date=Timestamp('2014-12-31'),
|
257
|
-
offset=[DateOffset(weekday=MO(1)), DateOffset(weekday=FR(-1))]
|
258
|
-
|
259
|
-
)
|
260
|
-
USLaborDayStarting1887After2014 = Holiday(
|
261
|
-
"Labor Day",
|
262
|
-
month=9,
|
263
|
-
day=1,
|
264
|
-
start_date=Timestamp("2014-01-01"),
|
265
|
-
offset=DateOffset(weekday=MO(1))
|
266
|
-
)
|
267
|
-
|
268
|
-
|
269
|
-
#########
|
270
|
-
# Thanksgiving
|
271
|
-
#########
|
272
|
-
|
273
|
-
USThanksgivingBefore2022 = Holiday(
|
274
|
-
'ThanksgivingFriday',
|
275
|
-
start_date=Timestamp('1942-01-01'),
|
276
|
-
end_date=Timestamp('2021-12-31'),
|
277
|
-
month=11, day=1,
|
278
|
-
offset=DateOffset(weekday=TH(4)),
|
279
|
-
)
|
280
|
-
USThanksgivingBefore2014 = Holiday(
|
281
|
-
'ThanksgivingFriday',
|
282
|
-
start_date=Timestamp('1942-01-01'),
|
283
|
-
end_date=Timestamp('2013-12-31'),
|
284
|
-
month=11, day=1,
|
285
|
-
offset=DateOffset(weekday=TH(4)),
|
286
|
-
)
|
287
|
-
USThanksgivingAfter2014 = Holiday(
|
288
|
-
'ThanksgivingFriday',
|
289
|
-
start_date=Timestamp('2014-01-01'),
|
290
|
-
month=11, day=1,
|
291
|
-
offset=DateOffset(weekday=TH(4)),
|
292
|
-
)
|
293
|
-
|
294
|
-
######## The following Holidays shouldn't be set with the FR offset
|
295
|
-
## In 2013, Nov 1st is a friday, so the 4th Friday is before the 4th Thursday...
|
296
|
-
# the observance rule defined herafter fixes this
|
297
|
-
|
298
|
-
# USThanksgivingFridayBefore2022 = Holiday(
|
299
|
-
# 'ThanksgivingFriday',
|
300
|
-
# start_date=Timestamp('1942-01-01'),
|
301
|
-
# end_date=Timestamp('2021-12-31'),
|
302
|
-
# month=11, day=1,
|
303
|
-
# offset=DateOffset(weekday=FR(4)),
|
304
|
-
# )
|
305
|
-
#
|
306
|
-
# USThanksgivingFriday2022AndAfter = Holiday(
|
307
|
-
# 'ThanksgivingFriday',
|
308
|
-
# start_date=Timestamp('2022-01-01'),
|
309
|
-
# month=11, day=1,
|
310
|
-
# offset=DateOffset(weekday=FR(4)),
|
311
|
-
# )
|
312
|
-
# USThanksgivingFriday = Holiday(
|
313
|
-
# 'ThanksgivingFriday',
|
314
|
-
# month=11, day=1,
|
315
|
-
# offset=DateOffset(weekday=FR(4)),
|
316
|
-
# )
|
317
|
-
|
318
|
-
def fri_after_4th_thu(dt):
|
319
|
-
# dt will just be Nov 1st
|
320
|
-
diff_to_thu = 3 - dt.weekday()
|
321
|
-
if diff_to_thu < 0: diff_to_thu += 7
|
322
|
-
return dt + datetime.timedelta(days=diff_to_thu + 22)
|
323
|
-
|
324
|
-
USThanksgivingFriday = Holiday(
|
325
|
-
'ThanksgivingFriday',
|
326
|
-
start_date=Timestamp('1942-01-01'),
|
327
|
-
month=11, day=1,
|
328
|
-
observance= fri_after_4th_thu,
|
329
|
-
)
|
330
|
-
|
331
|
-
USThanksgivingFriday2022AndAfter = Holiday(
|
332
|
-
'ThanksgivingFriday',
|
333
|
-
start_date=Timestamp('2022-01-01'),
|
334
|
-
month=11, day=1,
|
335
|
-
observance= fri_after_4th_thu,
|
336
|
-
)
|
337
|
-
# USThanksgivingFriday = Holiday(
|
338
|
-
# 'ThanksgivingFriday',
|
339
|
-
# month=11, day=1,
|
340
|
-
# observance= fri_after_4th_thu,
|
341
|
-
# )
|
@@ -1,169 +0,0 @@
|
|
1
|
-
from dateutil.relativedelta import (MO, TU, WE, TH, FR, SA, SU)
|
2
|
-
from pandas import (DateOffset, Timestamp, date_range)
|
3
|
-
from datetime import timedelta
|
4
|
-
from pandas.tseries.holiday import (Holiday, nearest_workday, sunday_to_monday, Easter)
|
5
|
-
from pandas.tseries.offsets import Day, CustomBusinessDay
|
6
|
-
|
7
|
-
from pandas_market_calendars.market_calendar import ( MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
####################################################
|
12
|
-
# US New Years Day Jan 1
|
13
|
-
#####################################################
|
14
|
-
USNewYearsDay = Holiday(
|
15
|
-
'New Years Day',
|
16
|
-
month=1,
|
17
|
-
day=1,
|
18
|
-
start_date = Timestamp('1952-09-29'),
|
19
|
-
#observance=sunday_to_monday,
|
20
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,)
|
21
|
-
)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#########################################################################
|
26
|
-
# Martin Luther King Jr.
|
27
|
-
# Starting 1998
|
28
|
-
##########################################################################
|
29
|
-
USMartinLutherKingJrFrom2022 = Holiday( # Early Close 1:30pm
|
30
|
-
'Dr. Martin Luther King Jr. Day',
|
31
|
-
month=1,
|
32
|
-
day=1,
|
33
|
-
start_date=Timestamp('2022-01-01'),
|
34
|
-
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,),
|
35
|
-
offset=DateOffset(weekday=MO(3)),
|
36
|
-
)
|
37
|
-
|
38
|
-
USMartinLutherKingJrPre2022 = Holiday( # Early Close 12:00pm
|
39
|
-
'Dr. Martin Luther King Jr. Day',
|
40
|
-
month=1,
|
41
|
-
day=1,
|
42
|
-
start_date=Timestamp('1998-01-01'),
|
43
|
-
end_date=Timestamp("2021-12-31"),
|
44
|
-
offset=DateOffset(weekday=MO(3)),
|
45
|
-
)
|
46
|
-
|
47
|
-
|
48
|
-
#########################################################################
|
49
|
-
# US Presidents Day Feb
|
50
|
-
##########################################################################
|
51
|
-
USPresidentsDayFrom2022 = Holiday('President''s Day', # 1:30pm Early Close
|
52
|
-
start_date=Timestamp('2022-01-01'),
|
53
|
-
month=2, day=1,
|
54
|
-
offset=DateOffset(weekday=MO(3)))
|
55
|
-
|
56
|
-
USPresidentsDayPre2022 = Holiday('President''s Day', # 12:00pm Early Close
|
57
|
-
end_date=Timestamp('2021-12-31'),
|
58
|
-
month=2, day=1,
|
59
|
-
offset=DateOffset(weekday=MO(3)))
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
############################################################
|
64
|
-
# Good Friday
|
65
|
-
############################################################
|
66
|
-
GoodFriday = Holiday(
|
67
|
-
"Good Friday 1908+",
|
68
|
-
start_date=Timestamp('1908-01-01'),
|
69
|
-
month=1,
|
70
|
-
day=1,
|
71
|
-
offset=[Easter(), Day(-2)]
|
72
|
-
)
|
73
|
-
|
74
|
-
##################################################
|
75
|
-
# US Memorial Day (Decoration Day) May 30
|
76
|
-
##################################################
|
77
|
-
USMemorialDayFrom2022 = Holiday( # 1:30pm early close
|
78
|
-
'Memorial Day',
|
79
|
-
month=5,
|
80
|
-
day=25,
|
81
|
-
start_date=Timestamp('2022-01-01'),
|
82
|
-
offset=DateOffset(weekday=MO(1)),
|
83
|
-
)
|
84
|
-
|
85
|
-
USMemorialDayPre2022 = Holiday( # 12:00pm early close
|
86
|
-
'Memorial Day',
|
87
|
-
month=5,
|
88
|
-
day=25,
|
89
|
-
end_date=Timestamp('2021-12-31'),
|
90
|
-
offset=DateOffset(weekday=MO(1)),
|
91
|
-
)
|
92
|
-
|
93
|
-
#######################################
|
94
|
-
# US Juneteenth (June 19th)
|
95
|
-
#######################################
|
96
|
-
USJuneteenthFrom2022 = Holiday(
|
97
|
-
'Juneteenth Starting at 2022',
|
98
|
-
start_date=Timestamp('2022-06-19'),
|
99
|
-
month=6, day=19,
|
100
|
-
observance=nearest_workday,
|
101
|
-
)
|
102
|
-
|
103
|
-
#######################################
|
104
|
-
# US Independence Day July 4
|
105
|
-
#######################################
|
106
|
-
USIndependenceDayFrom2022 = Holiday(
|
107
|
-
'July 4th',
|
108
|
-
month=7,
|
109
|
-
day=4,
|
110
|
-
start_date=Timestamp('2022-01-01'),
|
111
|
-
observance=nearest_workday,
|
112
|
-
)
|
113
|
-
USIndependenceDayPre2022 = Holiday(
|
114
|
-
'July 4th',
|
115
|
-
month=7,
|
116
|
-
day=4,
|
117
|
-
end_date=Timestamp('2021-12-31'),
|
118
|
-
observance=nearest_workday,
|
119
|
-
)
|
120
|
-
|
121
|
-
|
122
|
-
#################################################
|
123
|
-
# US Labor Day Starting 1887
|
124
|
-
#################################################
|
125
|
-
USLaborDay = Holiday(
|
126
|
-
"Labor Day",
|
127
|
-
month=9,
|
128
|
-
day=1,
|
129
|
-
start_date=Timestamp("1887-01-01"),
|
130
|
-
offset=DateOffset(weekday=MO(1))
|
131
|
-
)
|
132
|
-
|
133
|
-
|
134
|
-
################################################
|
135
|
-
# US Thanksgiving Nov 30
|
136
|
-
################################################
|
137
|
-
USThanksgivingDayFrom2022 = Holiday(
|
138
|
-
'Thanksgiving',
|
139
|
-
start_date=Timestamp('2022-01-01'),
|
140
|
-
month=11, day=1,
|
141
|
-
offset=DateOffset(weekday=TH(4))
|
142
|
-
)
|
143
|
-
|
144
|
-
USThanksgivingDayPre2022 = Holiday(
|
145
|
-
'Thanksgiving',
|
146
|
-
end_date=Timestamp('2021-12-31'),
|
147
|
-
month=11, day=1,
|
148
|
-
offset=DateOffset(weekday=TH(4))
|
149
|
-
)
|
150
|
-
|
151
|
-
FridayAfterThanksgiving = Holiday(
|
152
|
-
'Friday after Thanksgiving',
|
153
|
-
month=11,
|
154
|
-
day=1,
|
155
|
-
offset=[DateOffset(weekday=TH(4)), Day(1)],
|
156
|
-
)
|
157
|
-
|
158
|
-
|
159
|
-
################################
|
160
|
-
# Christmas Dec 25
|
161
|
-
################################
|
162
|
-
ChristmasCME = Holiday(
|
163
|
-
'Christmas',
|
164
|
-
month=12,
|
165
|
-
day=25,
|
166
|
-
start_date=Timestamp('1999-01-01'),
|
167
|
-
observance=nearest_workday,
|
168
|
-
)
|
169
|
-
|