pandas-market-calendars 4.3.3__py3-none-any.whl → 4.6.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/__init__.py +39 -38
- pandas_market_calendars/calendar_registry.py +57 -53
- pandas_market_calendars/calendar_utils.py +1200 -261
- pandas_market_calendars/calendars/asx.py +66 -66
- pandas_market_calendars/calendars/bmf.py +223 -206
- pandas_market_calendars/calendars/bse.py +421 -407
- pandas_market_calendars/calendars/cboe.py +145 -145
- pandas_market_calendars/calendars/cme.py +405 -402
- pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -126
- pandas_market_calendars/calendars/cme_globex_base.py +119 -119
- pandas_market_calendars/calendars/cme_globex_crypto.py +160 -160
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -216
- pandas_market_calendars/calendars/cme_globex_equities.py +123 -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 +131 -139
- pandas_market_calendars/calendars/eurex_fixed_income.py +98 -98
- pandas_market_calendars/calendars/hkex.py +429 -426
- pandas_market_calendars/calendars/ice.py +81 -81
- pandas_market_calendars/calendars/iex.py +151 -112
- pandas_market_calendars/calendars/jpx.py +113 -109
- pandas_market_calendars/calendars/lse.py +114 -114
- pandas_market_calendars/calendars/mirror.py +149 -130
- pandas_market_calendars/calendars/nyse.py +1466 -1324
- pandas_market_calendars/calendars/ose.py +116 -116
- pandas_market_calendars/calendars/sifma.py +354 -350
- pandas_market_calendars/calendars/six.py +132 -132
- pandas_market_calendars/calendars/sse.py +311 -311
- pandas_market_calendars/calendars/tase.py +220 -197
- pandas_market_calendars/calendars/tsx.py +181 -181
- pandas_market_calendars/holidays/cme.py +385 -385
- pandas_market_calendars/holidays/cme_globex.py +214 -214
- pandas_market_calendars/holidays/cn.py +1476 -1455
- pandas_market_calendars/holidays/jp.py +401 -398
- pandas_market_calendars/holidays/jpx_equinox.py +1 -0
- pandas_market_calendars/holidays/nyse.py +1536 -1531
- pandas_market_calendars/holidays/oz.py +63 -63
- pandas_market_calendars/holidays/sifma.py +350 -338
- pandas_market_calendars/holidays/us.py +376 -376
- pandas_market_calendars/market_calendar.py +1057 -895
- {pandas_market_calendars-4.3.3.dist-info → pandas_market_calendars-4.6.0.dist-info}/METADATA +13 -9
- pandas_market_calendars-4.6.0.dist-info/RECORD +50 -0
- {pandas_market_calendars-4.3.3.dist-info → pandas_market_calendars-4.6.0.dist-info}/WHEEL +1 -1
- pandas_market_calendars-4.3.3.dist-info/RECORD +0 -50
- {pandas_market_calendars-4.3.3.dist-info → pandas_market_calendars-4.6.0.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.3.3.dist-info → pandas_market_calendars-4.6.0.dist-info}/NOTICE +0 -0
- {pandas_market_calendars-4.3.3.dist-info → pandas_market_calendars-4.6.0.dist-info}/top_level.txt +0 -0
@@ -1,145 +1,145 @@
|
|
1
|
-
from datetime import time
|
2
|
-
from itertools import chain
|
3
|
-
|
4
|
-
import pandas as pd
|
5
|
-
from pandas.tseries.holiday import (
|
6
|
-
AbstractHolidayCalendar,
|
7
|
-
GoodFriday,
|
8
|
-
USLaborDay,
|
9
|
-
USPresidentsDay,
|
10
|
-
USThanksgivingDay,
|
11
|
-
Holiday,
|
12
|
-
)
|
13
|
-
from pytz import timezone
|
14
|
-
|
15
|
-
from pandas_market_calendars.holidays.us import (
|
16
|
-
Christmas,
|
17
|
-
USBlackFridayInOrAfter1993,
|
18
|
-
USIndependenceDay,
|
19
|
-
USMartinLutherKingJrAfter1998,
|
20
|
-
USMemorialDay,
|
21
|
-
USNewYearsDay,
|
22
|
-
HurricaneSandyClosings,
|
23
|
-
USNationalDaysofMourning,
|
24
|
-
USJuneteenthAfter2022,
|
25
|
-
)
|
26
|
-
from pandas_market_calendars.market_calendar import MarketCalendar
|
27
|
-
|
28
|
-
|
29
|
-
def good_friday_unless_christmas_nye_friday(dt):
|
30
|
-
"""
|
31
|
-
Good Friday is a valid trading day if Christmas Day or New Years Day fall
|
32
|
-
on a Friday.
|
33
|
-
"""
|
34
|
-
if isinstance(dt, pd.DatetimeIndex):
|
35
|
-
# Pandas < 2.1.0 will call with an index and fall-back to element by element
|
36
|
-
# Pandas == 2.1.0 will only call element by element
|
37
|
-
raise NotImplementedError()
|
38
|
-
|
39
|
-
year = dt.year
|
40
|
-
christmas_weekday = Christmas.observance(
|
41
|
-
pd.Timestamp(year=year, month=12, day=25)
|
42
|
-
).weekday()
|
43
|
-
nyd_weekday = USNewYearsDay.observance(
|
44
|
-
pd.Timestamp(year=year, month=1, day=1)
|
45
|
-
).weekday()
|
46
|
-
if christmas_weekday != 4 and nyd_weekday != 4:
|
47
|
-
return GoodFriday.dates(
|
48
|
-
pd.Timestamp(year=year, month=1, day=1),
|
49
|
-
pd.Timestamp(year=year, month=12, day=31),
|
50
|
-
)[0]
|
51
|
-
else:
|
52
|
-
# Not a holiday so use NaT to ensure it gets removed
|
53
|
-
return pd.NaT
|
54
|
-
|
55
|
-
|
56
|
-
GoodFridayUnlessChristmasNYEFriday = Holiday(
|
57
|
-
name="Good Friday CFE",
|
58
|
-
month=1,
|
59
|
-
day=1,
|
60
|
-
observance=good_friday_unless_christmas_nye_friday,
|
61
|
-
)
|
62
|
-
|
63
|
-
|
64
|
-
class CFEExchangeCalendar(MarketCalendar):
|
65
|
-
"""
|
66
|
-
Exchange calendar for the CBOE Futures Exchange (CFE).
|
67
|
-
|
68
|
-
http://cfe.cboe.com/aboutcfe/expirationcalendar.aspx
|
69
|
-
|
70
|
-
Open Time: 8:30am, America/Chicago
|
71
|
-
Close Time: 3:15pm, America/Chicago
|
72
|
-
|
73
|
-
(We are ignoring extended trading hours for now)
|
74
|
-
"""
|
75
|
-
|
76
|
-
aliases = ["CFE", "CBOE_Futures"]
|
77
|
-
regular_market_times = {
|
78
|
-
"market_open": ((None, time(8, 30)),),
|
79
|
-
"market_close": ((None, time(15, 15)),),
|
80
|
-
}
|
81
|
-
|
82
|
-
@property
|
83
|
-
def name(self):
|
84
|
-
return "CFE"
|
85
|
-
|
86
|
-
@property
|
87
|
-
def tz(self):
|
88
|
-
return timezone("America/Chicago")
|
89
|
-
|
90
|
-
@property
|
91
|
-
def regular_holidays(self):
|
92
|
-
return AbstractHolidayCalendar(
|
93
|
-
rules=[
|
94
|
-
USNewYearsDay,
|
95
|
-
USMartinLutherKingJrAfter1998,
|
96
|
-
USPresidentsDay,
|
97
|
-
GoodFridayUnlessChristmasNYEFriday,
|
98
|
-
USJuneteenthAfter2022,
|
99
|
-
USIndependenceDay,
|
100
|
-
USMemorialDay,
|
101
|
-
USLaborDay,
|
102
|
-
USThanksgivingDay,
|
103
|
-
Christmas,
|
104
|
-
]
|
105
|
-
)
|
106
|
-
|
107
|
-
@property
|
108
|
-
def special_closes(self):
|
109
|
-
return [
|
110
|
-
(
|
111
|
-
time(12, 15),
|
112
|
-
AbstractHolidayCalendar(
|
113
|
-
rules=[
|
114
|
-
USBlackFridayInOrAfter1993,
|
115
|
-
]
|
116
|
-
),
|
117
|
-
)
|
118
|
-
]
|
119
|
-
|
120
|
-
@property
|
121
|
-
def adhoc_holidays(self):
|
122
|
-
return list(
|
123
|
-
chain(
|
124
|
-
HurricaneSandyClosings,
|
125
|
-
USNationalDaysofMourning,
|
126
|
-
)
|
127
|
-
)
|
128
|
-
|
129
|
-
|
130
|
-
class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
|
131
|
-
name = "CBOE_Equity_Options"
|
132
|
-
aliases = [name]
|
133
|
-
regular_market_times = {
|
134
|
-
"market_open": ((None, time(8, 30)),),
|
135
|
-
"market_close": ((None, time(15)),),
|
136
|
-
}
|
137
|
-
|
138
|
-
|
139
|
-
class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
|
140
|
-
name = "CBOE_Index_Options"
|
141
|
-
aliases = [name]
|
142
|
-
regular_market_times = {
|
143
|
-
"market_open": ((None, time(8, 30)),),
|
144
|
-
"market_close": ((None, time(15, 15)),),
|
145
|
-
}
|
1
|
+
from datetime import time
|
2
|
+
from itertools import chain
|
3
|
+
|
4
|
+
import pandas as pd
|
5
|
+
from pandas.tseries.holiday import (
|
6
|
+
AbstractHolidayCalendar,
|
7
|
+
GoodFriday,
|
8
|
+
USLaborDay,
|
9
|
+
USPresidentsDay,
|
10
|
+
USThanksgivingDay,
|
11
|
+
Holiday,
|
12
|
+
)
|
13
|
+
from pytz import timezone
|
14
|
+
|
15
|
+
from pandas_market_calendars.holidays.us import (
|
16
|
+
Christmas,
|
17
|
+
USBlackFridayInOrAfter1993,
|
18
|
+
USIndependenceDay,
|
19
|
+
USMartinLutherKingJrAfter1998,
|
20
|
+
USMemorialDay,
|
21
|
+
USNewYearsDay,
|
22
|
+
HurricaneSandyClosings,
|
23
|
+
USNationalDaysofMourning,
|
24
|
+
USJuneteenthAfter2022,
|
25
|
+
)
|
26
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
27
|
+
|
28
|
+
|
29
|
+
def good_friday_unless_christmas_nye_friday(dt):
|
30
|
+
"""
|
31
|
+
Good Friday is a valid trading day if Christmas Day or New Years Day fall
|
32
|
+
on a Friday.
|
33
|
+
"""
|
34
|
+
if isinstance(dt, pd.DatetimeIndex):
|
35
|
+
# Pandas < 2.1.0 will call with an index and fall-back to element by element
|
36
|
+
# Pandas == 2.1.0 will only call element by element
|
37
|
+
raise NotImplementedError()
|
38
|
+
|
39
|
+
year = dt.year
|
40
|
+
christmas_weekday = Christmas.observance(
|
41
|
+
pd.Timestamp(year=year, month=12, day=25)
|
42
|
+
).weekday()
|
43
|
+
nyd_weekday = USNewYearsDay.observance(
|
44
|
+
pd.Timestamp(year=year, month=1, day=1)
|
45
|
+
).weekday()
|
46
|
+
if christmas_weekday != 4 and nyd_weekday != 4:
|
47
|
+
return GoodFriday.dates(
|
48
|
+
pd.Timestamp(year=year, month=1, day=1),
|
49
|
+
pd.Timestamp(year=year, month=12, day=31),
|
50
|
+
)[0]
|
51
|
+
else:
|
52
|
+
# Not a holiday so use NaT to ensure it gets removed
|
53
|
+
return pd.NaT
|
54
|
+
|
55
|
+
|
56
|
+
GoodFridayUnlessChristmasNYEFriday = Holiday(
|
57
|
+
name="Good Friday CFE",
|
58
|
+
month=1,
|
59
|
+
day=1,
|
60
|
+
observance=good_friday_unless_christmas_nye_friday,
|
61
|
+
)
|
62
|
+
|
63
|
+
|
64
|
+
class CFEExchangeCalendar(MarketCalendar):
|
65
|
+
"""
|
66
|
+
Exchange calendar for the CBOE Futures Exchange (CFE).
|
67
|
+
|
68
|
+
http://cfe.cboe.com/aboutcfe/expirationcalendar.aspx
|
69
|
+
|
70
|
+
Open Time: 8:30am, America/Chicago
|
71
|
+
Close Time: 3:15pm, America/Chicago
|
72
|
+
|
73
|
+
(We are ignoring extended trading hours for now)
|
74
|
+
"""
|
75
|
+
|
76
|
+
aliases = ["CFE", "CBOE_Futures"]
|
77
|
+
regular_market_times = {
|
78
|
+
"market_open": ((None, time(8, 30)),),
|
79
|
+
"market_close": ((None, time(15, 15)),),
|
80
|
+
}
|
81
|
+
|
82
|
+
@property
|
83
|
+
def name(self):
|
84
|
+
return "CFE"
|
85
|
+
|
86
|
+
@property
|
87
|
+
def tz(self):
|
88
|
+
return timezone("America/Chicago")
|
89
|
+
|
90
|
+
@property
|
91
|
+
def regular_holidays(self):
|
92
|
+
return AbstractHolidayCalendar(
|
93
|
+
rules=[
|
94
|
+
USNewYearsDay,
|
95
|
+
USMartinLutherKingJrAfter1998,
|
96
|
+
USPresidentsDay,
|
97
|
+
GoodFridayUnlessChristmasNYEFriday,
|
98
|
+
USJuneteenthAfter2022,
|
99
|
+
USIndependenceDay,
|
100
|
+
USMemorialDay,
|
101
|
+
USLaborDay,
|
102
|
+
USThanksgivingDay,
|
103
|
+
Christmas,
|
104
|
+
]
|
105
|
+
)
|
106
|
+
|
107
|
+
@property
|
108
|
+
def special_closes(self):
|
109
|
+
return [
|
110
|
+
(
|
111
|
+
time(12, 15),
|
112
|
+
AbstractHolidayCalendar(
|
113
|
+
rules=[
|
114
|
+
USBlackFridayInOrAfter1993,
|
115
|
+
]
|
116
|
+
),
|
117
|
+
)
|
118
|
+
]
|
119
|
+
|
120
|
+
@property
|
121
|
+
def adhoc_holidays(self):
|
122
|
+
return list(
|
123
|
+
chain(
|
124
|
+
HurricaneSandyClosings,
|
125
|
+
USNationalDaysofMourning,
|
126
|
+
)
|
127
|
+
)
|
128
|
+
|
129
|
+
|
130
|
+
class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
|
131
|
+
name = "CBOE_Equity_Options"
|
132
|
+
aliases = [name]
|
133
|
+
regular_market_times = {
|
134
|
+
"market_open": ((None, time(8, 30)),),
|
135
|
+
"market_close": ((None, time(15)),),
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
|
140
|
+
name = "CBOE_Index_Options"
|
141
|
+
aliases = [name]
|
142
|
+
regular_market_times = {
|
143
|
+
"market_open": ((None, time(8, 30)),),
|
144
|
+
"market_close": ((None, time(15, 15)),),
|
145
|
+
}
|