pandas-market-calendars 5.0.0__py3-none-any.whl → 5.1.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.
Files changed (48) hide show
  1. pandas_market_calendars/__init__.py +39 -39
  2. pandas_market_calendars/calendar_registry.py +57 -57
  3. pandas_market_calendars/calendar_utils.py +1151 -1147
  4. pandas_market_calendars/calendars/asx.py +77 -70
  5. pandas_market_calendars/calendars/bmf.py +226 -219
  6. pandas_market_calendars/calendars/bse.py +432 -425
  7. pandas_market_calendars/calendars/cboe.py +156 -149
  8. pandas_market_calendars/calendars/cme.py +412 -405
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -172
  10. pandas_market_calendars/calendars/cme_globex_base.py +126 -119
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +165 -158
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +223 -216
  13. pandas_market_calendars/calendars/cme_globex_equities.py +130 -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 +138 -131
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +105 -98
  18. pandas_market_calendars/calendars/hkex.py +438 -431
  19. pandas_market_calendars/calendars/ice.py +88 -81
  20. pandas_market_calendars/calendars/iex.py +162 -155
  21. pandas_market_calendars/calendars/jpx.py +124 -117
  22. pandas_market_calendars/calendars/lse.py +125 -118
  23. pandas_market_calendars/calendars/mirror.py +144 -144
  24. pandas_market_calendars/calendars/nyse.py +1472 -1466
  25. pandas_market_calendars/calendars/ose.py +125 -118
  26. pandas_market_calendars/calendars/sifma.py +390 -356
  27. pandas_market_calendars/calendars/six.py +143 -136
  28. pandas_market_calendars/calendars/sse.py +322 -315
  29. pandas_market_calendars/calendars/tase.py +231 -224
  30. pandas_market_calendars/calendars/tsx.py +192 -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 +63 -63
  39. pandas_market_calendars/holidays/sifma.py +350 -350
  40. pandas_market_calendars/holidays/us.py +376 -376
  41. pandas_market_calendars/market_calendar.py +1008 -1008
  42. {pandas_market_calendars-5.0.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/METADATA +3 -1
  43. pandas_market_calendars-5.1.1.dist-info/RECORD +50 -0
  44. {pandas_market_calendars-5.0.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/WHEEL +1 -1
  45. pandas_market_calendars-5.0.0.dist-info/RECORD +0 -50
  46. {pandas_market_calendars-5.0.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/licenses/LICENSE +0 -0
  47. {pandas_market_calendars-5.0.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/licenses/NOTICE +0 -0
  48. {pandas_market_calendars-5.0.0.dist-info → pandas_market_calendars-5.1.1.dist-info}/top_level.txt +0 -0
@@ -1,81 +1,88 @@
1
- from datetime import time
2
- from itertools import chain
3
-
4
- from pandas import Timestamp
5
- from pandas.tseries.holiday import (
6
- AbstractHolidayCalendar,
7
- GoodFriday,
8
- USLaborDay,
9
- USPresidentsDay,
10
- USThanksgivingDay,
11
- )
12
- from zoneinfo import ZoneInfo
13
-
14
- from pandas_market_calendars.holidays.us import (
15
- Christmas,
16
- USIndependenceDay,
17
- USMartinLutherKingJrAfter1998,
18
- USMemorialDay,
19
- USNationalDaysofMourning,
20
- USNewYearsDay,
21
- )
22
- from pandas_market_calendars.market_calendar import MarketCalendar
23
-
24
-
25
- class ICEExchangeCalendar(MarketCalendar):
26
- """
27
- Exchange calendar for ICE US.
28
-
29
- Open Time: 8pm, US/Eastern
30
- Close Time: 6pm, US/Eastern
31
-
32
- https://www.theice.com/publicdocs/futures_us/ICE_Futures_US_Regular_Trading_Hours.pdf # noqa
33
- """
34
-
35
- aliases = ["ICE", "ICEUS", "NYFE"]
36
- regular_market_times = {
37
- "market_open": ((None, time(20, 1), -1),), # offset by -1 day
38
- "market_close": ((None, time(18)),),
39
- }
40
-
41
- @property
42
- def name(self):
43
- return "ICE"
44
-
45
- @property
46
- def tz(self):
47
- return ZoneInfo("US/Eastern")
48
-
49
- @property
50
- def special_closes(self):
51
- return [
52
- (
53
- time(13),
54
- AbstractHolidayCalendar(
55
- rules=[
56
- USMartinLutherKingJrAfter1998,
57
- USPresidentsDay,
58
- USMemorialDay,
59
- USIndependenceDay,
60
- USLaborDay,
61
- USThanksgivingDay,
62
- ]
63
- ),
64
- )
65
- ]
66
-
67
- @property
68
- def adhoc_holidays(self):
69
- return list(
70
- chain(
71
- USNationalDaysofMourning,
72
- # ICE was only closed on the first day of the Hurricane Sandy
73
- # closings (was not closed on 2012-10-30)
74
- [Timestamp("2012-10-29", tz="UTC")],
75
- )
76
- )
77
-
78
- @property
79
- def regular_holidays(self):
80
- # https://www.theice.com/publicdocs/futures_us/exchange_notices/NewExNot2016Holidays.pdf # noqa
81
- return AbstractHolidayCalendar(rules=[USNewYearsDay, GoodFriday, Christmas])
1
+ from datetime import time
2
+ from itertools import chain
3
+
4
+ from pandas import Timestamp
5
+ from pandas.tseries.holiday import (
6
+ AbstractHolidayCalendar,
7
+ GoodFriday,
8
+ USLaborDay,
9
+ USPresidentsDay,
10
+ USThanksgivingDay,
11
+ )
12
+ import sys
13
+ # check python versiOn aNd import accordingly
14
+ if sys.version_info >= (3, 9):
15
+ # For Python 3.9 and later, import directly
16
+ from zoneinfo import ZoneInfo
17
+ else:
18
+ # For Python 3.8 and earlier, import from backports
19
+ from backports.zoneinfo import ZoneInfo
20
+
21
+ from pandas_market_calendars.holidays.us import (
22
+ Christmas,
23
+ USIndependenceDay,
24
+ USMartinLutherKingJrAfter1998,
25
+ USMemorialDay,
26
+ USNationalDaysofMourning,
27
+ USNewYearsDay,
28
+ )
29
+ from pandas_market_calendars.market_calendar import MarketCalendar
30
+
31
+
32
+ class ICEExchangeCalendar(MarketCalendar):
33
+ """
34
+ Exchange calendar for ICE US.
35
+
36
+ Open Time: 8pm, US/Eastern
37
+ Close Time: 6pm, US/Eastern
38
+
39
+ https://www.theice.com/publicdocs/futures_us/ICE_Futures_US_Regular_Trading_Hours.pdf # noqa
40
+ """
41
+
42
+ aliases = ["ICE", "ICEUS", "NYFE"]
43
+ regular_market_times = {
44
+ "market_open": ((None, time(20, 1), -1),), # offset by -1 day
45
+ "market_close": ((None, time(18)),),
46
+ }
47
+
48
+ @property
49
+ def name(self):
50
+ return "ICE"
51
+
52
+ @property
53
+ def tz(self):
54
+ return ZoneInfo("US/Eastern")
55
+
56
+ @property
57
+ def special_closes(self):
58
+ return [
59
+ (
60
+ time(13),
61
+ AbstractHolidayCalendar(
62
+ rules=[
63
+ USMartinLutherKingJrAfter1998,
64
+ USPresidentsDay,
65
+ USMemorialDay,
66
+ USIndependenceDay,
67
+ USLaborDay,
68
+ USThanksgivingDay,
69
+ ]
70
+ ),
71
+ )
72
+ ]
73
+
74
+ @property
75
+ def adhoc_holidays(self):
76
+ return list(
77
+ chain(
78
+ USNationalDaysofMourning,
79
+ # ICE was only closed on the first day of the Hurricane Sandy
80
+ # closings (was not closed on 2012-10-30)
81
+ [Timestamp("2012-10-29", tz="UTC")],
82
+ )
83
+ )
84
+
85
+ @property
86
+ def regular_holidays(self):
87
+ # https://www.theice.com/publicdocs/futures_us/exchange_notices/NewExNot2016Holidays.pdf # noqa
88
+ return AbstractHolidayCalendar(rules=[USNewYearsDay, GoodFriday, Christmas])
@@ -1,155 +1,162 @@
1
- from datetime import time
2
- from itertools import chain
3
-
4
- from pandas import Timestamp, DatetimeIndex, Timedelta
5
- from pandas.tseries.holiday import AbstractHolidayCalendar
6
- from zoneinfo import ZoneInfo
7
-
8
- from typing import Literal, Union
9
- from pandas_market_calendars import calendar_utils as u
10
-
11
- from pandas_market_calendars.holidays.nyse import (
12
- USPresidentsDay,
13
- GoodFriday,
14
- USMemorialDay,
15
- USJuneteenthAfter2022,
16
- USIndependenceDay,
17
- USThanksgivingDay,
18
- ChristmasNYSE,
19
- USMartinLutherKingJrAfter1998,
20
- # Ad-Hoc
21
- DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
22
- DaysBeforeIndependenceDay1pmEarlyCloseAdhoc,
23
- ChristmasEvesAdhoc,
24
- )
25
- from .nyse import NYSEExchangeCalendar
26
-
27
-
28
- class IEXExchangeCalendar(NYSEExchangeCalendar):
29
- """
30
- Exchange calendar for the Investor's Exchange (IEX).
31
-
32
- IEX Exchange is a U.S. stock exchange focused on driving performance
33
- for broker-dealers and investors through innovative design and technology.
34
-
35
- Most of this class inherits from NYSEExchangeCalendar since
36
- the holidays are the same. The only variation is (1) IEX began
37
- operation in 2013, and (2) IEX has different hours of operation
38
-
39
- References:
40
- - https://exchange.iex.io/
41
- - https://iexexchange.io/resources/trading/trading-hours-holidays/index.html
42
- """
43
-
44
- regular_market_times = {
45
- "pre": (("2013-03-25", time(8)),),
46
- "market_open": ((None, time(9, 30)),),
47
- "market_close": ((None, time(16)),),
48
- "post": ((None, time(17)),),
49
- }
50
-
51
- aliases = ["IEX", "Investors_Exchange"]
52
-
53
- @property
54
- def name(self):
55
- return "IEX"
56
-
57
- @property
58
- def full_name(self):
59
- return "Investor's Exchange"
60
-
61
- @property
62
- def weekmask(self):
63
- return "Mon Tue Wed Thu Fri"
64
-
65
- @property
66
- def regular_holidays(self):
67
- return AbstractHolidayCalendar(
68
- rules=[
69
- USPresidentsDay,
70
- GoodFriday,
71
- USMemorialDay,
72
- USJuneteenthAfter2022,
73
- USIndependenceDay,
74
- USThanksgivingDay,
75
- ChristmasNYSE,
76
- USMartinLutherKingJrAfter1998,
77
- ]
78
- )
79
-
80
- @property
81
- def adhoc_holidays(self):
82
- return list(
83
- chain(
84
- ChristmasEvesAdhoc,
85
- )
86
- )
87
-
88
- @property
89
- def special_closes(self):
90
- return [
91
- (
92
- time(hour=13, tzinfo=ZoneInfo("America/New_York")),
93
- AbstractHolidayCalendar(
94
- rules=[
95
- DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
96
- ]
97
- ),
98
- )
99
- ]
100
-
101
- """Override NYSE calendar special cases"""
102
-
103
- @property
104
- def special_closes_adhoc(self):
105
- return [
106
- (
107
- time(13, tzinfo=ZoneInfo("America/New_York")),
108
- DaysBeforeIndependenceDay1pmEarlyCloseAdhoc,
109
- )
110
- ]
111
-
112
- @property
113
- def special_opens(self):
114
- return []
115
-
116
- def valid_days(self, start_date, end_date, tz="UTC"):
117
- start_date = Timestamp(start_date)
118
- if start_date.tz is not None:
119
- # Ensure valid Comparison to "2013-08-25" is possible
120
- start_date.tz_convert(self.tz).tz_localize(None)
121
-
122
- # Limit Start_date to the Exchange's Open
123
- start_date = max(start_date, Timestamp("2013-08-25"))
124
- return super().valid_days(start_date, end_date, tz=tz)
125
-
126
- def date_range_htf(
127
- self,
128
- frequency: Union[str, Timedelta, int, float],
129
- start: Union[str, Timestamp, int, float, None] = None,
130
- end: Union[str, Timestamp, int, float, None] = None,
131
- periods: Union[int, None] = None,
132
- closed: Union[Literal["left", "right"], None] = "right",
133
- *,
134
- day_anchor: u.Day_Anchor = "SUN",
135
- month_anchor: u.Month_Anchor = "JAN",
136
- ) -> DatetimeIndex:
137
-
138
- start, end, periods = u._error_check_htf_range(start, end, periods)
139
-
140
- # Cap Beginning and end dates to the opening date of IEX
141
- if start is not None:
142
- start = max(start, Timestamp("2013-08-25"))
143
- if end is not None:
144
- end = max(end, Timestamp("2013-08-25"))
145
-
146
- return u.date_range_htf(
147
- self.holidays(),
148
- frequency,
149
- start,
150
- end,
151
- periods,
152
- closed,
153
- day_anchor=day_anchor,
154
- month_anchor=month_anchor,
155
- )
1
+ from datetime import time
2
+ from itertools import chain
3
+
4
+ from pandas import Timestamp, DatetimeIndex, Timedelta
5
+ from pandas.tseries.holiday import AbstractHolidayCalendar
6
+ import sys
7
+ # check python versiOn aNd import accordingly
8
+ if sys.version_info >= (3, 9):
9
+ # For Python 3.9 and later, import directly
10
+ from zoneinfo import ZoneInfo
11
+ else:
12
+ # For Python 3.8 and earlier, import from backports
13
+ from backports.zoneinfo import ZoneInfo
14
+
15
+ from typing import Literal, Union
16
+ from pandas_market_calendars import calendar_utils as u
17
+
18
+ from pandas_market_calendars.holidays.nyse import (
19
+ USPresidentsDay,
20
+ GoodFriday,
21
+ USMemorialDay,
22
+ USJuneteenthAfter2022,
23
+ USIndependenceDay,
24
+ USThanksgivingDay,
25
+ ChristmasNYSE,
26
+ USMartinLutherKingJrAfter1998,
27
+ # Ad-Hoc
28
+ DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
29
+ DaysBeforeIndependenceDay1pmEarlyCloseAdhoc,
30
+ ChristmasEvesAdhoc,
31
+ )
32
+ from .nyse import NYSEExchangeCalendar
33
+
34
+
35
+ class IEXExchangeCalendar(NYSEExchangeCalendar):
36
+ """
37
+ Exchange calendar for the Investor's Exchange (IEX).
38
+
39
+ IEX Exchange is a U.S. stock exchange focused on driving performance
40
+ for broker-dealers and investors through innovative design and technology.
41
+
42
+ Most of this class inherits from NYSEExchangeCalendar since
43
+ the holidays are the same. The only variation is (1) IEX began
44
+ operation in 2013, and (2) IEX has different hours of operation
45
+
46
+ References:
47
+ - https://exchange.iex.io/
48
+ - https://iexexchange.io/resources/trading/trading-hours-holidays/index.html
49
+ """
50
+
51
+ regular_market_times = {
52
+ "pre": (("2013-03-25", time(8)),),
53
+ "market_open": ((None, time(9, 30)),),
54
+ "market_close": ((None, time(16)),),
55
+ "post": ((None, time(17)),),
56
+ }
57
+
58
+ aliases = ["IEX", "Investors_Exchange"]
59
+
60
+ @property
61
+ def name(self):
62
+ return "IEX"
63
+
64
+ @property
65
+ def full_name(self):
66
+ return "Investor's Exchange"
67
+
68
+ @property
69
+ def weekmask(self):
70
+ return "Mon Tue Wed Thu Fri"
71
+
72
+ @property
73
+ def regular_holidays(self):
74
+ return AbstractHolidayCalendar(
75
+ rules=[
76
+ USPresidentsDay,
77
+ GoodFriday,
78
+ USMemorialDay,
79
+ USJuneteenthAfter2022,
80
+ USIndependenceDay,
81
+ USThanksgivingDay,
82
+ ChristmasNYSE,
83
+ USMartinLutherKingJrAfter1998,
84
+ ]
85
+ )
86
+
87
+ @property
88
+ def adhoc_holidays(self):
89
+ return list(
90
+ chain(
91
+ ChristmasEvesAdhoc,
92
+ )
93
+ )
94
+
95
+ @property
96
+ def special_closes(self):
97
+ return [
98
+ (
99
+ time(hour=13, tzinfo=ZoneInfo("America/New_York")),
100
+ AbstractHolidayCalendar(
101
+ rules=[
102
+ DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
103
+ ]
104
+ ),
105
+ )
106
+ ]
107
+
108
+ """Override NYSE calendar special cases"""
109
+
110
+ @property
111
+ def special_closes_adhoc(self):
112
+ return [
113
+ (
114
+ time(13, tzinfo=ZoneInfo("America/New_York")),
115
+ DaysBeforeIndependenceDay1pmEarlyCloseAdhoc,
116
+ )
117
+ ]
118
+
119
+ @property
120
+ def special_opens(self):
121
+ return []
122
+
123
+ def valid_days(self, start_date, end_date, tz="UTC"):
124
+ start_date = Timestamp(start_date)
125
+ if start_date.tz is not None:
126
+ # Ensure valid Comparison to "2013-08-25" is possible
127
+ start_date.tz_convert(self.tz).tz_localize(None)
128
+
129
+ # Limit Start_date to the Exchange's Open
130
+ start_date = max(start_date, Timestamp("2013-08-25"))
131
+ return super().valid_days(start_date, end_date, tz=tz)
132
+
133
+ def date_range_htf(
134
+ self,
135
+ frequency: Union[str, Timedelta, int, float],
136
+ start: Union[str, Timestamp, int, float, None] = None,
137
+ end: Union[str, Timestamp, int, float, None] = None,
138
+ periods: Union[int, None] = None,
139
+ closed: Union[Literal["left", "right"], None] = "right",
140
+ *,
141
+ day_anchor: u.Day_Anchor = "SUN",
142
+ month_anchor: u.Month_Anchor = "JAN",
143
+ ) -> DatetimeIndex:
144
+
145
+ start, end, periods = u._error_check_htf_range(start, end, periods)
146
+
147
+ # Cap Beginning and end dates to the opening date of IEX
148
+ if start is not None:
149
+ start = max(start, Timestamp("2013-08-25"))
150
+ if end is not None:
151
+ end = max(end, Timestamp("2013-08-25"))
152
+
153
+ return u.date_range_htf(
154
+ self.holidays(),
155
+ frequency,
156
+ start,
157
+ end,
158
+ periods,
159
+ closed,
160
+ day_anchor=day_anchor,
161
+ month_anchor=month_anchor,
162
+ )