pandas-market-calendars 5.1.0__py3-none-any.whl → 5.1.3__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.
Files changed (49) hide show
  1. pandas_market_calendars/__init__.py +39 -39
  2. pandas_market_calendars/calendar_registry.py +58 -57
  3. pandas_market_calendars/calendar_utils.py +1151 -1151
  4. pandas_market_calendars/calendars/asx.py +100 -70
  5. pandas_market_calendars/calendars/bmf.py +225 -219
  6. pandas_market_calendars/calendars/bse.py +433 -425
  7. pandas_market_calendars/calendars/cboe.py +153 -149
  8. pandas_market_calendars/calendars/cme.py +417 -405
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -172
  10. pandas_market_calendars/calendars/cme_globex_base.py +127 -119
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +166 -158
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +224 -216
  13. pandas_market_calendars/calendars/cme_globex_equities.py +131 -123
  14. pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -136
  15. pandas_market_calendars/calendars/cme_globex_fx.py +101 -101
  16. pandas_market_calendars/calendars/eurex.py +139 -131
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +106 -98
  18. pandas_market_calendars/calendars/hkex.py +437 -431
  19. pandas_market_calendars/calendars/ice.py +89 -81
  20. pandas_market_calendars/calendars/iex.py +163 -155
  21. pandas_market_calendars/calendars/jpx.py +125 -117
  22. pandas_market_calendars/calendars/lse.py +126 -118
  23. pandas_market_calendars/calendars/mirror.py +144 -144
  24. pandas_market_calendars/calendars/nyse.py +1462 -1466
  25. pandas_market_calendars/calendars/ose.py +124 -118
  26. pandas_market_calendars/calendars/sifma.py +391 -383
  27. pandas_market_calendars/calendars/six.py +144 -136
  28. pandas_market_calendars/calendars/sse.py +305 -315
  29. pandas_market_calendars/calendars/tase.py +232 -224
  30. pandas_market_calendars/calendars/tsx.py +193 -185
  31. pandas_market_calendars/class_registry.py +115 -115
  32. pandas_market_calendars/holidays/cme.py +385 -385
  33. pandas_market_calendars/holidays/cme_globex.py +214 -214
  34. pandas_market_calendars/holidays/cn.py +1476 -1476
  35. pandas_market_calendars/holidays/jp.py +401 -401
  36. pandas_market_calendars/holidays/jpx_equinox.py +506 -506
  37. pandas_market_calendars/holidays/nyse.py +1536 -1536
  38. pandas_market_calendars/holidays/oz.py +82 -63
  39. pandas_market_calendars/holidays/sifma.py +350 -350
  40. pandas_market_calendars/holidays/uk.py +186 -186
  41. pandas_market_calendars/holidays/us.py +376 -376
  42. pandas_market_calendars/market_calendar.py +1006 -1008
  43. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/METADATA +5 -4
  44. pandas_market_calendars-5.1.3.dist-info/RECORD +50 -0
  45. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/WHEEL +1 -1
  46. pandas_market_calendars-5.1.0.dist-info/RECORD +0 -50
  47. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/licenses/LICENSE +0 -0
  48. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/licenses/NOTICE +0 -0
  49. {pandas_market_calendars-5.1.0.dist-info → pandas_market_calendars-5.1.3.dist-info}/top_level.txt +0 -0
@@ -1,149 +1,153 @@
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 zoneinfo import ZoneInfo
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 full_name(self):
88
- return "CBOE Futures Exchange"
89
-
90
- @property
91
- def tz(self):
92
- return ZoneInfo("America/Chicago")
93
-
94
- @property
95
- def regular_holidays(self):
96
- return AbstractHolidayCalendar(
97
- rules=[
98
- USNewYearsDay,
99
- USMartinLutherKingJrAfter1998,
100
- USPresidentsDay,
101
- GoodFridayUnlessChristmasNYEFriday,
102
- USJuneteenthAfter2022,
103
- USIndependenceDay,
104
- USMemorialDay,
105
- USLaborDay,
106
- USThanksgivingDay,
107
- Christmas,
108
- ]
109
- )
110
-
111
- @property
112
- def special_closes(self):
113
- return [
114
- (
115
- time(12, 15),
116
- AbstractHolidayCalendar(
117
- rules=[
118
- USBlackFridayInOrAfter1993,
119
- ]
120
- ),
121
- )
122
- ]
123
-
124
- @property
125
- def adhoc_holidays(self):
126
- return list(
127
- chain(
128
- HurricaneSandyClosings,
129
- USNationalDaysofMourning,
130
- )
131
- )
132
-
133
-
134
- class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
135
- name = "CBOE_Equity_Options"
136
- aliases = [name]
137
- regular_market_times = {
138
- "market_open": ((None, time(8, 30)),),
139
- "market_close": ((None, time(15)),),
140
- }
141
-
142
-
143
- class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
144
- name = "CBOE_Index_Options"
145
- aliases = [name]
146
- regular_market_times = {
147
- "market_open": ((None, time(8, 30)),),
148
- "market_close": ((None, time(15, 15)),),
149
- }
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
+ import sys
14
+
15
+ # check python versiOn aNd import accordingly
16
+ if sys.version_info >= (3, 9):
17
+ # For Python 3.9 and later, import directly
18
+ from zoneinfo import ZoneInfo
19
+ else:
20
+ # For Python 3.8 and earlier, import from backports
21
+ from backports.zoneinfo import ZoneInfo
22
+
23
+ from pandas_market_calendars.holidays.us import (
24
+ Christmas,
25
+ USBlackFridayInOrAfter1993,
26
+ USIndependenceDay,
27
+ USMartinLutherKingJrAfter1998,
28
+ USMemorialDay,
29
+ USNewYearsDay,
30
+ HurricaneSandyClosings,
31
+ USNationalDaysofMourning,
32
+ USJuneteenthAfter2022,
33
+ )
34
+ from pandas_market_calendars.market_calendar import MarketCalendar
35
+
36
+
37
+ def good_friday_unless_christmas_nye_friday(dt):
38
+ """
39
+ Good Friday is a valid trading day if Christmas Day or New Years Day fall
40
+ on a Friday.
41
+ """
42
+ if isinstance(dt, pd.DatetimeIndex):
43
+ # Pandas < 2.1.0 will call with an index and fall-back to element by element
44
+ # Pandas == 2.1.0 will only call element by element
45
+ raise NotImplementedError()
46
+
47
+ year = dt.year
48
+ christmas_weekday = Christmas.observance(pd.Timestamp(year=year, month=12, day=25)).weekday()
49
+ nyd_weekday = USNewYearsDay.observance(pd.Timestamp(year=year, month=1, day=1)).weekday()
50
+ if christmas_weekday != 4 and nyd_weekday != 4:
51
+ return GoodFriday.dates(
52
+ pd.Timestamp(year=year, month=1, day=1),
53
+ pd.Timestamp(year=year, month=12, day=31),
54
+ )[0]
55
+ else:
56
+ # Not a holiday so use NaT to ensure it gets removed
57
+ return pd.NaT
58
+
59
+
60
+ GoodFridayUnlessChristmasNYEFriday = Holiday(
61
+ name="Good Friday CFE",
62
+ month=1,
63
+ day=1,
64
+ observance=good_friday_unless_christmas_nye_friday,
65
+ )
66
+
67
+
68
+ class CFEExchangeCalendar(MarketCalendar):
69
+ """
70
+ Exchange calendar for the CBOE Futures Exchange (CFE).
71
+
72
+ http://cfe.cboe.com/aboutcfe/expirationcalendar.aspx
73
+
74
+ Open Time: 8:30am, America/Chicago
75
+ Close Time: 3:15pm, America/Chicago
76
+
77
+ (We are ignoring extended trading hours for now)
78
+ """
79
+
80
+ aliases = ["CFE", "CBOE_Futures"]
81
+ regular_market_times = {
82
+ "market_open": ((None, time(8, 30)),),
83
+ "market_close": ((None, time(15, 15)),),
84
+ }
85
+
86
+ @property
87
+ def name(self):
88
+ return "CFE"
89
+
90
+ @property
91
+ def full_name(self):
92
+ return "CBOE Futures Exchange"
93
+
94
+ @property
95
+ def tz(self):
96
+ return ZoneInfo("America/Chicago")
97
+
98
+ @property
99
+ def regular_holidays(self):
100
+ return AbstractHolidayCalendar(
101
+ rules=[
102
+ USNewYearsDay,
103
+ USMartinLutherKingJrAfter1998,
104
+ USPresidentsDay,
105
+ GoodFridayUnlessChristmasNYEFriday,
106
+ USJuneteenthAfter2022,
107
+ USIndependenceDay,
108
+ USMemorialDay,
109
+ USLaborDay,
110
+ USThanksgivingDay,
111
+ Christmas,
112
+ ]
113
+ )
114
+
115
+ @property
116
+ def special_closes(self):
117
+ return [
118
+ (
119
+ time(12, 15),
120
+ AbstractHolidayCalendar(
121
+ rules=[
122
+ USBlackFridayInOrAfter1993,
123
+ ]
124
+ ),
125
+ )
126
+ ]
127
+
128
+ @property
129
+ def adhoc_holidays(self):
130
+ return list(
131
+ chain(
132
+ HurricaneSandyClosings,
133
+ USNationalDaysofMourning,
134
+ )
135
+ )
136
+
137
+
138
+ class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
139
+ name = "CBOE_Equity_Options"
140
+ aliases = [name]
141
+ regular_market_times = {
142
+ "market_open": ((None, time(8, 30)),),
143
+ "market_close": ((None, time(15)),),
144
+ }
145
+
146
+
147
+ class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
148
+ name = "CBOE_Index_Options"
149
+ aliases = [name]
150
+ regular_market_times = {
151
+ "market_open": ((None, time(8, 30)),),
152
+ "market_close": ((None, time(15, 15)),),
153
+ }