pandas-market-calendars 4.3.0__py3-none-any.whl → 4.3.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/calendars/__init__.py +0 -0
- pandas_market_calendars/calendars/asx.py +63 -0
- pandas_market_calendars/calendars/bmf.py +227 -0
- pandas_market_calendars/calendars/bse.py +409 -0
- pandas_market_calendars/calendars/cboe.py +115 -0
- pandas_market_calendars/calendars/cme.py +240 -0
- pandas_market_calendars/calendars/cme_globex_agriculture.py +103 -0
- pandas_market_calendars/calendars/cme_globex_base.py +103 -0
- pandas_market_calendars/calendars/cme_globex_crypto.py +147 -0
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +138 -0
- pandas_market_calendars/calendars/cme_globex_equities.py +104 -0
- pandas_market_calendars/calendars/cme_globex_fixed_income.py +113 -0
- pandas_market_calendars/calendars/cme_globex_fx.py +78 -0
- pandas_market_calendars/calendars/eurex.py +119 -0
- pandas_market_calendars/calendars/hkex.py +408 -0
- pandas_market_calendars/calendars/ice.py +65 -0
- pandas_market_calendars/calendars/iex.py +98 -0
- pandas_market_calendars/calendars/jpx.py +103 -0
- pandas_market_calendars/calendars/lse.py +91 -0
- pandas_market_calendars/calendars/mirror.py +114 -0
- pandas_market_calendars/calendars/nyse.py +1127 -0
- pandas_market_calendars/calendars/ose.py +150 -0
- pandas_market_calendars/calendars/sifma.py +297 -0
- pandas_market_calendars/calendars/six.py +114 -0
- pandas_market_calendars/calendars/sse.py +290 -0
- pandas_market_calendars/calendars/tase.py +195 -0
- pandas_market_calendars/calendars/tsx.py +159 -0
- pandas_market_calendars/holidays/__init__.py +0 -0
- pandas_market_calendars/holidays/cme.py +340 -0
- pandas_market_calendars/holidays/cme_globex.py +198 -0
- pandas_market_calendars/holidays/cn.py +1436 -0
- pandas_market_calendars/holidays/jp.py +396 -0
- pandas_market_calendars/holidays/jpx_equinox.py +147 -0
- pandas_market_calendars/holidays/nyse.py +1472 -0
- pandas_market_calendars/holidays/oz.py +65 -0
- pandas_market_calendars/holidays/sifma.py +321 -0
- pandas_market_calendars/holidays/uk.py +180 -0
- pandas_market_calendars/holidays/us.py +360 -0
- {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/METADATA +1 -1
- pandas_market_calendars-4.3.1.dist-info/RECORD +49 -0
- pandas_market_calendars-4.3.0.dist-info/RECORD +0 -11
- {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/NOTICE +0 -0
- {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/WHEEL +0 -0
- {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,240 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016 Quantopian, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
from datetime import time
|
17
|
+
from itertools import chain
|
18
|
+
|
19
|
+
from pandas import Timestamp
|
20
|
+
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
21
|
+
from pytz import timezone
|
22
|
+
|
23
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
24
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USNationalDaysofMourning,
|
25
|
+
USNewYearsDay)
|
26
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
27
|
+
|
28
|
+
|
29
|
+
# Useful resources for making changes to this file: http://www.cmegroup.com/tools-information/holiday-calendar.html
|
30
|
+
# The CME has different holiday rules depending on the type of instrument.
|
31
|
+
# For example, http://www.cmegroup.com/tools-information/holiday-calendar/files/2016-4th-of-july-holiday-schedule.pdf # noqa
|
32
|
+
# shows that Equity, Interest Rate, FX, Energy, Metals & DME Products close at 1200 CT on July 4, 2016, while Grain,
|
33
|
+
# Oilseed & MGEX Products and Livestock, Dairy & Lumber products are completely closed.
|
34
|
+
|
35
|
+
|
36
|
+
class CMEEquityExchangeCalendar(MarketCalendar):
|
37
|
+
"""
|
38
|
+
Exchange calendar for CME for Equity products
|
39
|
+
|
40
|
+
Open Time: 6:00 PM, America/New_York / 5:00 PM Chicago
|
41
|
+
Close Time: 5:00 PM, America/New_York / 4:00 PM Chicago
|
42
|
+
Break: 4:15 - 4:30pm America/New_York / 3:15 - 3:30 PM Chicago
|
43
|
+
"""
|
44
|
+
aliases = ['CME_Equity', 'CBOT_Equity']
|
45
|
+
regular_market_times = {
|
46
|
+
"market_open": ((None, time(17), -1),), # offset by -1 day
|
47
|
+
"market_close": ((None, time(16)),),
|
48
|
+
"break_start": ((None, time(15,15)),),
|
49
|
+
"break_end": ((None, time(15,30)),)
|
50
|
+
}
|
51
|
+
|
52
|
+
@property
|
53
|
+
def name(self):
|
54
|
+
return "CME_Equity"
|
55
|
+
|
56
|
+
@property
|
57
|
+
def tz(self):
|
58
|
+
return timezone('America/Chicago')
|
59
|
+
|
60
|
+
@property
|
61
|
+
def regular_holidays(self):
|
62
|
+
# Many days that are holidays for the NYSE are an early close day for CME
|
63
|
+
return AbstractHolidayCalendar(rules=[
|
64
|
+
USNewYearsDay,
|
65
|
+
GoodFriday,
|
66
|
+
Christmas,
|
67
|
+
])
|
68
|
+
|
69
|
+
@property
|
70
|
+
def adhoc_holidays(self):
|
71
|
+
return USNationalDaysofMourning
|
72
|
+
|
73
|
+
@property
|
74
|
+
def special_closes(self):
|
75
|
+
return [(
|
76
|
+
time(12),
|
77
|
+
AbstractHolidayCalendar(rules=[
|
78
|
+
USMartinLutherKingJrAfter1998,
|
79
|
+
USPresidentsDay,
|
80
|
+
USMemorialDay,
|
81
|
+
USLaborDay,
|
82
|
+
USIndependenceDay,
|
83
|
+
USThanksgivingDay,
|
84
|
+
USBlackFridayInOrAfter1993,
|
85
|
+
ChristmasEveBefore1993,
|
86
|
+
ChristmasEveInOrAfter1993,
|
87
|
+
])
|
88
|
+
)]
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
class CMEAgricultureExchangeCalendar(MarketCalendar):
|
93
|
+
"""
|
94
|
+
Exchange calendar for CME for Agriculture products
|
95
|
+
|
96
|
+
Open Time: 5:00 PM, America/Chicago
|
97
|
+
Close Time: 5:00 PM, America/Chicago
|
98
|
+
|
99
|
+
Regularly-Observed Holidays:
|
100
|
+
- New Years Day
|
101
|
+
- Good Friday
|
102
|
+
- Christmas
|
103
|
+
"""
|
104
|
+
aliases = ['CME_Agriculture', 'CBOT_Agriculture', 'COMEX_Agriculture', 'NYMEX_Agriculture']
|
105
|
+
regular_market_times = {
|
106
|
+
"market_open": ((None, time(17, 1), -1),), # offset by -1 day
|
107
|
+
"market_close": ((None, time(17)),)
|
108
|
+
}
|
109
|
+
|
110
|
+
@property
|
111
|
+
def name(self):
|
112
|
+
return "CME_Agriculture"
|
113
|
+
|
114
|
+
@property
|
115
|
+
def tz(self):
|
116
|
+
return timezone('America/Chicago')
|
117
|
+
|
118
|
+
@property
|
119
|
+
def regular_holidays(self):
|
120
|
+
# Ignore gap between 13:20 CST and 14:30 CST for regular trading hours
|
121
|
+
#
|
122
|
+
# The CME has different holiday rules depending on the type of
|
123
|
+
# instrument. For example, http://www.cmegroup.com/tools-information/holiday-calendar/files/2016-4th-of-july-holiday-schedule.pdf # noqa
|
124
|
+
# shows that Equity, Interest Rate, FX, Energy, Metals & DME Products
|
125
|
+
# close at 1200 CT on July 4, 2016, while Grain, Oilseed & MGEX
|
126
|
+
# Products and Livestock, Dairy & Lumber products are completely
|
127
|
+
# closed.
|
128
|
+
return AbstractHolidayCalendar(rules=[
|
129
|
+
USNewYearsDay,
|
130
|
+
USMartinLutherKingJrAfter1998,
|
131
|
+
USPresidentsDay,
|
132
|
+
GoodFriday,
|
133
|
+
USMemorialDay,
|
134
|
+
USIndependenceDay,
|
135
|
+
USLaborDay,
|
136
|
+
USThanksgivingDay,
|
137
|
+
Christmas,
|
138
|
+
])
|
139
|
+
|
140
|
+
@property
|
141
|
+
def adhoc_holidays(self):
|
142
|
+
return USNationalDaysofMourning
|
143
|
+
|
144
|
+
@property
|
145
|
+
def special_closes(self):
|
146
|
+
return [(
|
147
|
+
time(12),
|
148
|
+
AbstractHolidayCalendar(rules=[
|
149
|
+
USBlackFridayInOrAfter1993,
|
150
|
+
ChristmasEveBefore1993,
|
151
|
+
ChristmasEveInOrAfter1993,
|
152
|
+
])
|
153
|
+
)]
|
154
|
+
|
155
|
+
|
156
|
+
# For the bond market Good Friday that coincides with the release of NFP on the first friday of the month is an open day
|
157
|
+
goodFridayClosed = ['1970-03-27', '1971-04-09', '1972-03-31', '1973-04-20', '1974-04-12', '1975-03-28', '1976-04-16',
|
158
|
+
'1977-04-08', '1978-03-24', '1979-04-13', '1981-04-17', '1982-04-09', '1984-04-20', '1986-03-28',
|
159
|
+
'1987-04-17', '1989-03-24', '1990-04-13', '1991-03-29', '1992-04-17', '1993-04-09', '1995-04-14',
|
160
|
+
'1997-03-28', '1998-04-10', '2000-04-21', '2001-04-13', '2002-03-29', '2003-04-18', '2004-04-09',
|
161
|
+
'2005-03-25', '2006-04-14', '2008-03-21', '2009-04-10', '2011-04-22', '2013-03-29', '2014-04-18',
|
162
|
+
'2016-03-25', '2017-04-14', '2018-03-30', '2019-04-19', '2020-04-10', '2022-04-15', '2024-03-29',
|
163
|
+
'2025-04-18', '2027-03-26', '2028-04-14', '2029-03-30', '2030-04-19', '2031-04-11', '2032-03-26',
|
164
|
+
'2033-04-15', '2035-03-23', '2036-04-11', '2038-04-23', '2039-04-08', '2040-03-30', '2041-04-19',
|
165
|
+
'2043-03-27', '2044-04-15', '2046-03-23', '2047-04-12', '2049-04-16', '2050-04-08', '2051-03-31',
|
166
|
+
'2052-04-19', '2054-03-27', '2055-04-16', '2056-03-31', '2057-04-20', '2058-04-12', '2059-03-28',
|
167
|
+
'2060-04-16', '2061-04-08', '2062-03-24', '2063-04-13', '2065-03-27', '2066-04-09', '2068-04-20',
|
168
|
+
'2069-04-12', '2070-03-28', '2071-04-17', '2072-04-08', '2073-03-24', '2074-04-13', '2076-04-17',
|
169
|
+
'2077-04-09', '2079-04-21', '2081-03-28', '2082-04-17', '2084-03-24', '2085-04-13', '2086-03-29',
|
170
|
+
'2087-04-18', '2088-04-09', '2090-04-14', '2092-03-28', '2093-04-10', '2095-04-22', '2096-04-13',
|
171
|
+
'2097-03-29', '2098-04-18', '2099-04-10']
|
172
|
+
|
173
|
+
BondsGoodFridayClosed = [Timestamp(x, tz='UTC') for x in goodFridayClosed]
|
174
|
+
|
175
|
+
goodFridayOpen = ['1980-04-04', '1983-04-01', '1985-04-05', '1988-04-01', '1994-04-01', '1996-04-05', '1999-04-02',
|
176
|
+
'2007-04-06', '2010-04-02', '2012-04-06', '2015-04-03', '2021-04-02', '2023-04-07', '2026-04-03',
|
177
|
+
'2034-04-07', '2037-04-03', '2042-04-04', '2045-04-07', '2048-04-03', '2053-04-04', '2064-04-04',
|
178
|
+
'2067-04-01', '2075-04-05', '2078-04-01', '2080-04-05', '2083-04-02', '2089-04-01', '2091-04-06',
|
179
|
+
'2094-04-02']
|
180
|
+
|
181
|
+
BondsGoodFridayOpen = [Timestamp(x, tz='UTC') for x in goodFridayOpen]
|
182
|
+
|
183
|
+
|
184
|
+
class CMEBondExchangeCalendar(MarketCalendar):
|
185
|
+
"""
|
186
|
+
Exchange calendar for CME for Interest Rate and Bond products
|
187
|
+
|
188
|
+
The Holiday calendar is different between the open outcry trading floor hours and GLOBEX electronic trading hours.
|
189
|
+
This calendar attempts to be accurate for the GLOBEX holidays and hours from approx 2010 onward.
|
190
|
+
"""
|
191
|
+
aliases = ['CME_Rate', 'CBOT_Rate', 'CME_InterestRate', 'CBOT_InterestRate', 'CME_Bond', 'CBOT_Bond']
|
192
|
+
regular_market_times = {
|
193
|
+
"market_open": ((None, time(17), -1),), # offset by -1 day
|
194
|
+
"market_close": ((None, time(16)),)
|
195
|
+
}
|
196
|
+
|
197
|
+
@property
|
198
|
+
def name(self):
|
199
|
+
return "CME_Bond"
|
200
|
+
|
201
|
+
@property
|
202
|
+
def tz(self):
|
203
|
+
return timezone('America/Chicago')
|
204
|
+
|
205
|
+
@property
|
206
|
+
def regular_holidays(self):
|
207
|
+
return AbstractHolidayCalendar(rules=[
|
208
|
+
USNewYearsDay,
|
209
|
+
Christmas,
|
210
|
+
])
|
211
|
+
|
212
|
+
@property
|
213
|
+
def adhoc_holidays(self):
|
214
|
+
return list(chain(USNationalDaysofMourning, BondsGoodFridayClosed))
|
215
|
+
|
216
|
+
@property
|
217
|
+
def special_closes(self):
|
218
|
+
return [
|
219
|
+
(time(12),
|
220
|
+
AbstractHolidayCalendar(rules=[
|
221
|
+
USMartinLutherKingJrAfter1998,
|
222
|
+
USPresidentsDay,
|
223
|
+
USMemorialDay,
|
224
|
+
USIndependenceDay,
|
225
|
+
USLaborDay,
|
226
|
+
USThanksgivingDay,
|
227
|
+
])),
|
228
|
+
(time(12, 15),
|
229
|
+
AbstractHolidayCalendar(rules=[
|
230
|
+
USBlackFridayInOrAfter1993,
|
231
|
+
ChristmasEveBefore1993,
|
232
|
+
ChristmasEveInOrAfter1993,
|
233
|
+
]))
|
234
|
+
]
|
235
|
+
|
236
|
+
@property
|
237
|
+
def special_closes_adhoc(self):
|
238
|
+
return [
|
239
|
+
(time(10, tzinfo=self.tz), BondsGoodFridayOpen)
|
240
|
+
]
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016 Quantopian, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
from abc import abstractmethod
|
17
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
18
|
+
|
19
|
+
from datetime import time
|
20
|
+
|
21
|
+
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
22
|
+
|
23
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
24
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
|
25
|
+
USNewYearsDay)
|
26
|
+
|
27
|
+
|
28
|
+
class CMEGlobexAgricultureExchangeCalendar(CMEGlobexBaseExchangeCalendar):
|
29
|
+
"""
|
30
|
+
Exchange calendar for CME for Agriculture products
|
31
|
+
|
32
|
+
Products:
|
33
|
+
- Grains and Oilseeds (same trading hours and holidays)
|
34
|
+
- Livestock
|
35
|
+
- Dairy
|
36
|
+
- Fertilizer
|
37
|
+
- Lumber and Softs
|
38
|
+
|
39
|
+
|
40
|
+
"""
|
41
|
+
|
42
|
+
@property
|
43
|
+
@abstractmethod
|
44
|
+
def name(self):
|
45
|
+
"""
|
46
|
+
Name of the market
|
47
|
+
|
48
|
+
:return: string name
|
49
|
+
"""
|
50
|
+
raise NotImplementedError()
|
51
|
+
|
52
|
+
|
53
|
+
class CMEGlobexLivestockExchangeCalendar(CMEGlobexAgricultureExchangeCalendar):
|
54
|
+
"""
|
55
|
+
Exchange calendar for CME for Livestock products
|
56
|
+
|
57
|
+
https://www.cmegroup.com/trading/agricultural/livestock.html
|
58
|
+
|
59
|
+
GLOBEX Trading Times
|
60
|
+
https://www.cmegroup.com/markets/agriculture/livestock/live-cattle.contractSpecs.html
|
61
|
+
Monday - Friday: 8:30 a.m. - 1:05 p.m. CT
|
62
|
+
"""
|
63
|
+
aliases = ['CMEGlobex_Livestock', 'CMEGlobex_Live_Cattle', 'CMEGlobex_Feeder_Cattle', 'CMEGlobex_Lean_Hog', 'CMEGlobex_Port_Cutout']
|
64
|
+
|
65
|
+
regular_market_times = {
|
66
|
+
"market_open": ((None, time(8, 30)),),
|
67
|
+
"market_close": ((None, time(13, 5)),)
|
68
|
+
}
|
69
|
+
|
70
|
+
@property
|
71
|
+
def name(self):
|
72
|
+
return "CMEGlobex_Livestock"
|
73
|
+
|
74
|
+
@property
|
75
|
+
def regular_holidays(self):
|
76
|
+
return AbstractHolidayCalendar(rules=[
|
77
|
+
USNewYearsDay,
|
78
|
+
USMartinLutherKingJrAfter1998,
|
79
|
+
USPresidentsDay,
|
80
|
+
GoodFriday,
|
81
|
+
USMemorialDay,
|
82
|
+
USIndependenceDay,
|
83
|
+
USLaborDay,
|
84
|
+
USThanksgivingDay,
|
85
|
+
Christmas,
|
86
|
+
])
|
87
|
+
|
88
|
+
# @property
|
89
|
+
# def adhoc_holidays(self):
|
90
|
+
# return USNationalDaysofMourning
|
91
|
+
|
92
|
+
@property
|
93
|
+
def special_closes(self):
|
94
|
+
return [(
|
95
|
+
time(12, 5),
|
96
|
+
AbstractHolidayCalendar(rules=[
|
97
|
+
USBlackFridayInOrAfter1993,
|
98
|
+
ChristmasEveBefore1993,
|
99
|
+
ChristmasEveInOrAfter1993,
|
100
|
+
])
|
101
|
+
)]
|
102
|
+
|
103
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016 Quantopian, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
from abc import ABC, abstractmethod
|
17
|
+
|
18
|
+
from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
|
19
|
+
from pytz import timezone
|
20
|
+
|
21
|
+
from pandas_market_calendars.holidays.us import (Christmas, ChristmasEveBefore1993, ChristmasEveInOrAfter1993, USBlackFridayInOrAfter1993,
|
22
|
+
USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay, USJuneteenthAfter2022,
|
23
|
+
USNewYearsDay)
|
24
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
25
|
+
|
26
|
+
|
27
|
+
class CMEGlobexBaseExchangeCalendar(MarketCalendar, ABC):
|
28
|
+
"""
|
29
|
+
Base Exchange Calendar for CME.
|
30
|
+
|
31
|
+
CME Markets: https://www.cmegroup.com/markets/agriculture.html#overview
|
32
|
+
- Agriculture
|
33
|
+
- Crypto
|
34
|
+
- Energy
|
35
|
+
- Equity Index
|
36
|
+
- FX
|
37
|
+
- Interest Rates
|
38
|
+
- Metals
|
39
|
+
- Options
|
40
|
+
|
41
|
+
Holiays for which entire GLOBEX is closed:
|
42
|
+
- New Years Day
|
43
|
+
- Good Friday
|
44
|
+
- Christmas
|
45
|
+
|
46
|
+
Product Specific Closures:
|
47
|
+
- MLK Day
|
48
|
+
- Presidents Day
|
49
|
+
- Memorial Day
|
50
|
+
- Juneteenth
|
51
|
+
- US Independence Day
|
52
|
+
- US Labor Day
|
53
|
+
- US Thanksgiving Day
|
54
|
+
"""
|
55
|
+
@property
|
56
|
+
@abstractmethod
|
57
|
+
def name(self):
|
58
|
+
"""
|
59
|
+
Name of the market
|
60
|
+
|
61
|
+
:return: string name
|
62
|
+
"""
|
63
|
+
raise NotImplementedError()
|
64
|
+
|
65
|
+
@property
|
66
|
+
def tz(self):
|
67
|
+
return timezone('America/Chicago')
|
68
|
+
|
69
|
+
@property
|
70
|
+
def regular_holidays(self):
|
71
|
+
return AbstractHolidayCalendar(rules=[
|
72
|
+
USNewYearsDay,
|
73
|
+
GoodFriday,
|
74
|
+
Christmas,
|
75
|
+
])
|
76
|
+
|
77
|
+
# I can't find any reference to these special closings onther than NYSE
|
78
|
+
# @property
|
79
|
+
# def adhoc_holidays(self):
|
80
|
+
# return USNationalDaysofMourning
|
81
|
+
|
82
|
+
@property
|
83
|
+
def special_closes(self):
|
84
|
+
return [(
|
85
|
+
self.special_close_time,
|
86
|
+
AbstractHolidayCalendar(rules=[
|
87
|
+
USMartinLutherKingJrAfter1998,
|
88
|
+
USPresidentsDay,
|
89
|
+
USMemorialDay,
|
90
|
+
USJuneteenthAfter2022,
|
91
|
+
USLaborDay,
|
92
|
+
USIndependenceDay,
|
93
|
+
USThanksgivingDay,
|
94
|
+
USBlackFridayInOrAfter1993,
|
95
|
+
ChristmasEveBefore1993,
|
96
|
+
ChristmasEveInOrAfter1993,
|
97
|
+
])
|
98
|
+
)]
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
@@ -0,0 +1,147 @@
|
|
1
|
+
import datetime as dt
|
2
|
+
|
3
|
+
from pandas.tseries.holiday import AbstractHolidayCalendar
|
4
|
+
import pytz
|
5
|
+
|
6
|
+
from .cme_globex_base import CMEGlobexBaseExchangeCalendar
|
7
|
+
from pandas_market_calendars.holidays.cme import (
|
8
|
+
GoodFriday2021,
|
9
|
+
GoodFridayAfter2021,
|
10
|
+
GoodFridayBefore2021,
|
11
|
+
USIndependenceDayBefore2022PreviousDay,
|
12
|
+
)
|
13
|
+
from pandas_market_calendars.holidays.cme_globex import (
|
14
|
+
ChristmasCME,
|
15
|
+
USMartinLutherKingJrFrom2022,
|
16
|
+
USMartinLutherKingJrPre2022,
|
17
|
+
USPresidentsDayFrom2022,
|
18
|
+
USPresidentsDayPre2022,
|
19
|
+
USMemorialDayFrom2022,
|
20
|
+
USMemorialDayPre2022,
|
21
|
+
USJuneteenthFrom2022,
|
22
|
+
USIndependenceDayFrom2022,
|
23
|
+
USIndependenceDayPre2022,
|
24
|
+
USLaborDayFrom2022,
|
25
|
+
USLaborDayPre2022,
|
26
|
+
USThanksgivingDayFrom2022,
|
27
|
+
USThanksgivingDayPre2022,
|
28
|
+
USThanksgivingFridayFrom2021,
|
29
|
+
USThanksgivingFridayPre2021,
|
30
|
+
)
|
31
|
+
from pandas_market_calendars.holidays.us import (
|
32
|
+
ChristmasEveInOrAfter1993,
|
33
|
+
USNewYearsDay,
|
34
|
+
)
|
35
|
+
|
36
|
+
|
37
|
+
# https://github.com/rsheftel/pandas_market_calendars/blob/master/docs/new_market.rst
|
38
|
+
class CMEGlobexCryptoExchangeCalendar(CMEGlobexBaseExchangeCalendar):
|
39
|
+
# The label you fetch the exchange with in mcal.get_calendar('CME Globex ...')
|
40
|
+
aliases = ["CME Globex Cryptocurrencies", "CME Globex Crypto"]
|
41
|
+
|
42
|
+
# https://www.cmegroup.com/markets/cryptocurrencies/bitcoin/bitcoin.contractSpecs.html
|
43
|
+
regular_market_times = {
|
44
|
+
# Tuple[Tuple[first date used, time, offset], ...]
|
45
|
+
# -1 offset indicates that the open is on the previous day
|
46
|
+
# None for first date used marks the start, subsequent market times must have an actual timestamp
|
47
|
+
"market_open": (
|
48
|
+
(None, dt.time(17, tzinfo=pytz.timezone("America/Chicago")), -1),
|
49
|
+
),
|
50
|
+
"market_close": (
|
51
|
+
(
|
52
|
+
None,
|
53
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
54
|
+
),
|
55
|
+
),
|
56
|
+
"break_start": (
|
57
|
+
(
|
58
|
+
None,
|
59
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
60
|
+
),
|
61
|
+
),
|
62
|
+
"break_end": (
|
63
|
+
(
|
64
|
+
None,
|
65
|
+
dt.time(17, tzinfo=pytz.timezone("America/Chicago")),
|
66
|
+
),
|
67
|
+
),
|
68
|
+
}
|
69
|
+
|
70
|
+
@property
|
71
|
+
def tz(self):
|
72
|
+
# Central Time
|
73
|
+
return pytz.timezone("America/Chicago")
|
74
|
+
|
75
|
+
@property
|
76
|
+
def name(self):
|
77
|
+
return "CME Globex Crypto"
|
78
|
+
|
79
|
+
# Check the .zip files at the bottom of this page
|
80
|
+
# https://www.cmegroup.com/tools-information/holiday-calendar.html?redirect=/tools-information/holiday-calendar/#cmeGlobex
|
81
|
+
# Note: many of the holiday objects (ie. GoodFridayBefore2021) were originally made for equities and other markets
|
82
|
+
# and hence have a start_date starting before crypto is actually available
|
83
|
+
|
84
|
+
@property
|
85
|
+
def regular_holidays(self):
|
86
|
+
# Days where the market is fully closed
|
87
|
+
return AbstractHolidayCalendar(
|
88
|
+
rules=[
|
89
|
+
GoodFridayBefore2021,
|
90
|
+
GoodFridayAfter2021,
|
91
|
+
ChristmasCME,
|
92
|
+
USNewYearsDay,
|
93
|
+
]
|
94
|
+
)
|
95
|
+
|
96
|
+
@property
|
97
|
+
def special_closes(self):
|
98
|
+
# Days where the market closes early
|
99
|
+
# list[Tuple[time, AbstractHolidayCalendar]]
|
100
|
+
return [
|
101
|
+
(
|
102
|
+
dt.time(8, 15, tzinfo=pytz.timezone("America/Chicago")),
|
103
|
+
AbstractHolidayCalendar(rules=[GoodFriday2021]),
|
104
|
+
),
|
105
|
+
(
|
106
|
+
dt.time(12, tzinfo=pytz.timezone("America/Chicago")),
|
107
|
+
AbstractHolidayCalendar(
|
108
|
+
rules=[
|
109
|
+
USMartinLutherKingJrPre2022,
|
110
|
+
USPresidentsDayPre2022,
|
111
|
+
USMemorialDayPre2022,
|
112
|
+
USIndependenceDayPre2022,
|
113
|
+
USLaborDayPre2022,
|
114
|
+
USThanksgivingDayPre2022,
|
115
|
+
]
|
116
|
+
),
|
117
|
+
),
|
118
|
+
(
|
119
|
+
dt.time(12, 15, tzinfo=pytz.timezone("America/Chicago")),
|
120
|
+
AbstractHolidayCalendar(
|
121
|
+
rules=[
|
122
|
+
ChristmasEveInOrAfter1993,
|
123
|
+
USIndependenceDayBefore2022PreviousDay,
|
124
|
+
USThanksgivingFridayPre2021,
|
125
|
+
]
|
126
|
+
),
|
127
|
+
),
|
128
|
+
(
|
129
|
+
dt.time(12, 45, tzinfo=pytz.timezone("America/Chicago")),
|
130
|
+
AbstractHolidayCalendar(rules=[USThanksgivingFridayFrom2021]),
|
131
|
+
),
|
132
|
+
# TODO: this market already closes at 1600 normally, do we need these holidays?
|
133
|
+
(
|
134
|
+
dt.time(16, tzinfo=pytz.timezone("America/Chicago")),
|
135
|
+
AbstractHolidayCalendar(
|
136
|
+
rules=[
|
137
|
+
USMartinLutherKingJrFrom2022,
|
138
|
+
USPresidentsDayFrom2022,
|
139
|
+
USMemorialDayFrom2022,
|
140
|
+
USJuneteenthFrom2022,
|
141
|
+
USIndependenceDayFrom2022,
|
142
|
+
USLaborDayFrom2022,
|
143
|
+
USThanksgivingDayFrom2022,
|
144
|
+
]
|
145
|
+
),
|
146
|
+
),
|
147
|
+
]
|