pandas-market-calendars 4.3.1__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 -37
- pandas_market_calendars/calendar_registry.py +53 -48
- pandas_market_calendars/calendar_utils.py +261 -225
- pandas_market_calendars/calendars/asx.py +66 -63
- pandas_market_calendars/calendars/bmf.py +206 -227
- pandas_market_calendars/calendars/bse.py +407 -409
- pandas_market_calendars/calendars/cboe.py +145 -115
- pandas_market_calendars/calendars/cme.py +402 -240
- pandas_market_calendars/calendars/cme_globex_agriculture.py +126 -103
- pandas_market_calendars/calendars/cme_globex_base.py +119 -103
- pandas_market_calendars/calendars/cme_globex_crypto.py +160 -147
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -138
- pandas_market_calendars/calendars/cme_globex_equities.py +123 -104
- pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -113
- pandas_market_calendars/calendars/cme_globex_fx.py +101 -78
- pandas_market_calendars/calendars/eurex.py +139 -119
- pandas_market_calendars/calendars/eurex_fixed_income.py +98 -0
- pandas_market_calendars/calendars/hkex.py +426 -408
- pandas_market_calendars/calendars/ice.py +81 -65
- pandas_market_calendars/calendars/iex.py +112 -98
- pandas_market_calendars/calendars/jpx.py +109 -103
- pandas_market_calendars/calendars/lse.py +114 -91
- pandas_market_calendars/calendars/mirror.py +130 -114
- pandas_market_calendars/calendars/nyse.py +1324 -1127
- pandas_market_calendars/calendars/ose.py +116 -150
- pandas_market_calendars/calendars/sifma.py +350 -297
- pandas_market_calendars/calendars/six.py +132 -114
- pandas_market_calendars/calendars/sse.py +311 -290
- pandas_market_calendars/calendars/tase.py +197 -195
- pandas_market_calendars/calendars/tsx.py +181 -159
- pandas_market_calendars/class_registry.py +22 -16
- pandas_market_calendars/holidays/cme.py +385 -340
- pandas_market_calendars/holidays/cme_globex.py +214 -198
- pandas_market_calendars/holidays/cn.py +1455 -1436
- pandas_market_calendars/holidays/jp.py +398 -396
- pandas_market_calendars/holidays/jpx_equinox.py +453 -95
- pandas_market_calendars/holidays/nyse.py +1531 -1472
- pandas_market_calendars/holidays/oz.py +63 -65
- pandas_market_calendars/holidays/sifma.py +338 -321
- pandas_market_calendars/holidays/uk.py +32 -26
- pandas_market_calendars/holidays/us.py +376 -360
- pandas_market_calendars/market_calendar.py +895 -789
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/METADATA +7 -5
- pandas_market_calendars-4.3.3.dist-info/RECORD +50 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/WHEEL +1 -1
- pandas_market_calendars-4.3.1.dist-info/RECORD +0 -49
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/NOTICE +0 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/top_level.txt +0 -0
@@ -1,115 +1,145 @@
|
|
1
|
-
from datetime import time
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
from
|
6
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
+
}
|