pandas-market-calendars 4.4.2__py3-none-any.whl → 4.5.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 (46) hide show
  1. pandas_market_calendars/__init__.py +38 -38
  2. pandas_market_calendars/calendar_registry.py +57 -57
  3. pandas_market_calendars/calendar_utils.py +262 -262
  4. pandas_market_calendars/calendars/asx.py +66 -66
  5. pandas_market_calendars/calendars/bmf.py +223 -223
  6. pandas_market_calendars/calendars/bse.py +421 -421
  7. pandas_market_calendars/calendars/cboe.py +145 -145
  8. pandas_market_calendars/calendars/cme.py +405 -405
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +172 -172
  10. pandas_market_calendars/calendars/cme_globex_base.py +119 -119
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +160 -160
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -216
  13. pandas_market_calendars/calendars/cme_globex_equities.py +123 -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 +131 -131
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +98 -98
  18. pandas_market_calendars/calendars/hkex.py +429 -429
  19. pandas_market_calendars/calendars/ice.py +81 -81
  20. pandas_market_calendars/calendars/iex.py +112 -112
  21. pandas_market_calendars/calendars/lse.py +114 -114
  22. pandas_market_calendars/calendars/mirror.py +149 -149
  23. pandas_market_calendars/calendars/nyse.py +3 -0
  24. pandas_market_calendars/calendars/ose.py +116 -116
  25. pandas_market_calendars/calendars/sifma.py +354 -354
  26. pandas_market_calendars/calendars/six.py +132 -132
  27. pandas_market_calendars/calendars/sse.py +1 -1
  28. pandas_market_calendars/calendars/tase.py +197 -197
  29. pandas_market_calendars/calendars/tsx.py +181 -181
  30. pandas_market_calendars/holidays/cme.py +385 -385
  31. pandas_market_calendars/holidays/cme_globex.py +214 -214
  32. pandas_market_calendars/holidays/cn.py +20 -0
  33. pandas_market_calendars/holidays/jp.py +401 -401
  34. pandas_market_calendars/holidays/jpx_equinox.py +506 -506
  35. pandas_market_calendars/holidays/nyse.py +5 -0
  36. pandas_market_calendars/holidays/oz.py +63 -63
  37. pandas_market_calendars/holidays/sifma.py +350 -350
  38. pandas_market_calendars/holidays/us.py +376 -376
  39. pandas_market_calendars/market_calendar.py +20 -1
  40. {pandas_market_calendars-4.4.2.dist-info → pandas_market_calendars-4.5.1.dist-info}/METADATA +1 -1
  41. pandas_market_calendars-4.5.1.dist-info/RECORD +50 -0
  42. {pandas_market_calendars-4.4.2.dist-info → pandas_market_calendars-4.5.1.dist-info}/WHEEL +1 -1
  43. pandas_market_calendars-4.4.2.dist-info/RECORD +0 -50
  44. {pandas_market_calendars-4.4.2.dist-info → pandas_market_calendars-4.5.1.dist-info}/LICENSE +0 -0
  45. {pandas_market_calendars-4.4.2.dist-info → pandas_market_calendars-4.5.1.dist-info}/NOTICE +0 -0
  46. {pandas_market_calendars-4.4.2.dist-info → pandas_market_calendars-4.5.1.dist-info}/top_level.txt +0 -0
@@ -1,149 +1,149 @@
1
- """
2
- Imported calendars from the exchange_calendars project
3
-
4
- GitHub: https://github.com/gerrymanoim/exchange_calendars
5
- """
6
-
7
- import exchange_calendars
8
-
9
- from pandas_market_calendars.market_calendar import MarketCalendar
10
-
11
- DAYMASKS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
12
-
13
-
14
- class TradingCalendar(MarketCalendar):
15
- """
16
- This class provides access to all the information on opens, breaks and closes that are available
17
- in the exchange_calendars package, it will receive the correctly formatted regular_market_times
18
- dictionary in the for-loop below.
19
-
20
- The initialization of calendars from exchange_calendars, is bypassed until the `.ec` property is used,
21
- which returns the initialized exchange_calendar calendar, which is only initialized the first time.
22
- """
23
-
24
- # flag indicating that offset still needs to be checked.
25
- # A class attribute so we only do this once per class and not per instance
26
- _FINALIZE_TRADING_CALENDAR = True
27
-
28
- def __new__(cls, *args, **kwargs):
29
- self = super().__new__(cls)
30
- self._ec = super().__new__(cls._ec_class)
31
- # flag indicating that mirrored class is not initialized yet, which we only want to do
32
- # once per instance, if and only if the public `.ec` property is used.
33
- self._EC_NOT_INITIALIZED = True
34
-
35
- # offsets of exchange_calendar_mirrors are only available through the instance
36
- if cls._FINALIZE_TRADING_CALENDAR:
37
- if self._ec.open_offset:
38
- cls.regular_market_times._set(
39
- "market_open",
40
- tuple(
41
- (t[0], t[1], self._ec.open_offset)
42
- for t in cls.regular_market_times["market_open"]
43
- ),
44
- )
45
-
46
- if self._ec.close_offset:
47
- cls.regular_market_times._set(
48
- "market_close",
49
- tuple(
50
- (t[0], t[1], self._ec.close_offset)
51
- for t in cls.regular_market_times["market_close"]
52
- ),
53
- )
54
- cls._FINALIZE_TRADING_CALENDAR = False
55
-
56
- self.__init__(*args, **kwargs)
57
- return self
58
-
59
- def __init__(self, open_time=None, close_time=None):
60
- super().__init__(open_time, close_time)
61
-
62
- @property
63
- def ec(self):
64
- if self._EC_NOT_INITIALIZED:
65
- self._ec.__init__()
66
- self._EC_NOT_INITIALIZED = False
67
-
68
- return self._ec
69
-
70
- @property
71
- def name(self):
72
- return self._ec.name
73
-
74
- @property
75
- def tz(self):
76
- return self._ec.tz
77
-
78
- @property
79
- def regular_holidays(self):
80
- return self._ec.regular_holidays
81
-
82
- @property
83
- def adhoc_holidays(self):
84
- return self._ec.adhoc_holidays
85
-
86
- @property
87
- def special_opens(self):
88
- return self._ec.special_opens
89
-
90
- @property
91
- def special_opens_adhoc(self):
92
- return self._ec.special_opens_adhoc
93
-
94
- @property
95
- def special_closes(self):
96
- return self._ec.special_closes
97
-
98
- @property
99
- def special_closes_adhoc(self):
100
- return self._ec.special_closes_adhoc
101
-
102
- @property
103
- def weekmask(self):
104
- if hasattr(self._ec, "weekmask"):
105
- if "1" in self._ec.weekmask or "0" in self._ec.weekmask:
106
- # Convert 1s & 0s to Day Abbreviations
107
- return " ".join(
108
- [
109
- DAYMASKS[i]
110
- for i, val in enumerate(self._ec.weekmask)
111
- if val == "1"
112
- ]
113
- )
114
- else:
115
- return self._ec.weekmask
116
- else:
117
- return "Mon Tue Wed Thu Fri"
118
-
119
-
120
- calendars = exchange_calendars.calendar_utils._default_calendar_factories # noqa
121
-
122
- time_props = dict(
123
- open_times="market_open",
124
- close_times="market_close",
125
- break_start_times="break_start",
126
- break_end_times="break_end",
127
- )
128
-
129
- for exchange in calendars:
130
- cal = calendars[exchange]
131
-
132
- # this loop will set up the newly required regular_market_times dictionary
133
- regular_market_times = {}
134
- for prop, new in time_props.items():
135
- times = getattr(cal, prop)
136
- if times is None or isinstance(times, property):
137
- continue
138
- regular_market_times[new] = times
139
-
140
- cal = type(
141
- exchange,
142
- (TradingCalendar,),
143
- {
144
- "_ec_class": calendars[exchange],
145
- "alias": [exchange],
146
- "regular_market_times": regular_market_times,
147
- },
148
- )
149
- locals()[f"{exchange}ExchangeCalendar"] = cal
1
+ """
2
+ Imported calendars from the exchange_calendars project
3
+
4
+ GitHub: https://github.com/gerrymanoim/exchange_calendars
5
+ """
6
+
7
+ import exchange_calendars
8
+
9
+ from pandas_market_calendars.market_calendar import MarketCalendar
10
+
11
+ DAYMASKS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
12
+
13
+
14
+ class TradingCalendar(MarketCalendar):
15
+ """
16
+ This class provides access to all the information on opens, breaks and closes that are available
17
+ in the exchange_calendars package, it will receive the correctly formatted regular_market_times
18
+ dictionary in the for-loop below.
19
+
20
+ The initialization of calendars from exchange_calendars, is bypassed until the `.ec` property is used,
21
+ which returns the initialized exchange_calendar calendar, which is only initialized the first time.
22
+ """
23
+
24
+ # flag indicating that offset still needs to be checked.
25
+ # A class attribute so we only do this once per class and not per instance
26
+ _FINALIZE_TRADING_CALENDAR = True
27
+
28
+ def __new__(cls, *args, **kwargs):
29
+ self = super().__new__(cls)
30
+ self._ec = super().__new__(cls._ec_class)
31
+ # flag indicating that mirrored class is not initialized yet, which we only want to do
32
+ # once per instance, if and only if the public `.ec` property is used.
33
+ self._EC_NOT_INITIALIZED = True
34
+
35
+ # offsets of exchange_calendar_mirrors are only available through the instance
36
+ if cls._FINALIZE_TRADING_CALENDAR:
37
+ if self._ec.open_offset:
38
+ cls.regular_market_times._set(
39
+ "market_open",
40
+ tuple(
41
+ (t[0], t[1], self._ec.open_offset)
42
+ for t in cls.regular_market_times["market_open"]
43
+ ),
44
+ )
45
+
46
+ if self._ec.close_offset:
47
+ cls.regular_market_times._set(
48
+ "market_close",
49
+ tuple(
50
+ (t[0], t[1], self._ec.close_offset)
51
+ for t in cls.regular_market_times["market_close"]
52
+ ),
53
+ )
54
+ cls._FINALIZE_TRADING_CALENDAR = False
55
+
56
+ self.__init__(*args, **kwargs)
57
+ return self
58
+
59
+ def __init__(self, open_time=None, close_time=None):
60
+ super().__init__(open_time, close_time)
61
+
62
+ @property
63
+ def ec(self):
64
+ if self._EC_NOT_INITIALIZED:
65
+ self._ec.__init__()
66
+ self._EC_NOT_INITIALIZED = False
67
+
68
+ return self._ec
69
+
70
+ @property
71
+ def name(self):
72
+ return self._ec.name
73
+
74
+ @property
75
+ def tz(self):
76
+ return self._ec.tz
77
+
78
+ @property
79
+ def regular_holidays(self):
80
+ return self._ec.regular_holidays
81
+
82
+ @property
83
+ def adhoc_holidays(self):
84
+ return self._ec.adhoc_holidays
85
+
86
+ @property
87
+ def special_opens(self):
88
+ return self._ec.special_opens
89
+
90
+ @property
91
+ def special_opens_adhoc(self):
92
+ return self._ec.special_opens_adhoc
93
+
94
+ @property
95
+ def special_closes(self):
96
+ return self._ec.special_closes
97
+
98
+ @property
99
+ def special_closes_adhoc(self):
100
+ return self._ec.special_closes_adhoc
101
+
102
+ @property
103
+ def weekmask(self):
104
+ if hasattr(self._ec, "weekmask"):
105
+ if "1" in self._ec.weekmask or "0" in self._ec.weekmask:
106
+ # Convert 1s & 0s to Day Abbreviations
107
+ return " ".join(
108
+ [
109
+ DAYMASKS[i]
110
+ for i, val in enumerate(self._ec.weekmask)
111
+ if val == "1"
112
+ ]
113
+ )
114
+ else:
115
+ return self._ec.weekmask
116
+ else:
117
+ return "Mon Tue Wed Thu Fri"
118
+
119
+
120
+ calendars = exchange_calendars.calendar_utils._default_calendar_factories # noqa
121
+
122
+ time_props = dict(
123
+ open_times="market_open",
124
+ close_times="market_close",
125
+ break_start_times="break_start",
126
+ break_end_times="break_end",
127
+ )
128
+
129
+ for exchange in calendars:
130
+ cal = calendars[exchange]
131
+
132
+ # this loop will set up the newly required regular_market_times dictionary
133
+ regular_market_times = {}
134
+ for prop, new in time_props.items():
135
+ times = getattr(cal, prop)
136
+ if times is None or isinstance(times, property):
137
+ continue
138
+ regular_market_times[new] = times
139
+
140
+ cal = type(
141
+ exchange,
142
+ (TradingCalendar,),
143
+ {
144
+ "_ec_class": calendars[exchange],
145
+ "alias": [exchange],
146
+ "regular_market_times": regular_market_times,
147
+ },
148
+ )
149
+ locals()[f"{exchange}ExchangeCalendar"] = cal
@@ -297,6 +297,8 @@ from pandas_market_calendars.holidays.nyse import (
297
297
  HurricaneSandyClosings2012,
298
298
  # 2018
299
299
  GeorgeHWBushDeath2018,
300
+ # 2025
301
+ JimmyCarterDeath2025,
300
302
  )
301
303
  from pandas_market_calendars.market_calendar import MarketCalendar
302
304
 
@@ -961,6 +963,7 @@ class NYSEExchangeCalendar(MarketCalendar):
961
963
  September11Closings2001,
962
964
  HurricaneSandyClosings2012,
963
965
  GeorgeHWBushDeath2018,
966
+ JimmyCarterDeath2025,
964
967
  )
965
968
  )
966
969
 
@@ -1,116 +1,116 @@
1
- from datetime import time
2
-
3
- from pandas.tseries.holiday import (
4
- AbstractHolidayCalendar,
5
- EasterMonday,
6
- GoodFriday,
7
- Holiday,
8
- )
9
- from pandas.tseries.offsets import Day, Easter
10
- from pytz import timezone
11
-
12
- from pandas_market_calendars.market_calendar import MarketCalendar
13
-
14
- OSENewYearsDay = Holiday("New Year's Day", month=1, day=1)
15
-
16
- OSEWednesdayBeforeEaster = Holiday(
17
- "Wednesday before Easter", month=1, day=1, offset=[Easter(), Day(-4)]
18
- )
19
-
20
- OSEMaundyThursday = Holiday(
21
- "Maundy Thursday", month=1, day=1, offset=[Easter(), Day(-3)]
22
- )
23
-
24
- OSEGoodFriday = GoodFriday
25
-
26
- OSEEasterMonday = EasterMonday
27
-
28
- OSELabourDay = Holiday("Labour Day", month=5, day=1)
29
-
30
- OSEConstitutionDay = Holiday("Constitution Day", month=5, day=17)
31
-
32
- OSEWhitMonday = Holiday("Whit Monday", month=1, day=1, offset=[Easter(), Day(50)])
33
-
34
- OSEAscensionDay = Holiday("Ascension Day", month=1, day=1, offset=[Easter(), Day(39)])
35
-
36
- OSEChristmasEve = Holiday(
37
- "Christmas Eve",
38
- month=12,
39
- day=24,
40
- )
41
-
42
- OSEChristmasDay = Holiday("Christmas Day", month=12, day=25)
43
-
44
- OSEBoxingDay = Holiday("Boxing Day", month=12, day=26)
45
-
46
- OSENewYearsEve = Holiday("New Year's Eve", month=12, day=31)
47
-
48
-
49
- class OSEExchangeCalendar(MarketCalendar):
50
- """
51
- Exchange calendar for Oslo Stock Exchange
52
-
53
- Note these dates are only checked against 2017, 2018 and 2019
54
- https://www.oslobors.no/ob_eng/Oslo-Boers/About-Oslo-Boers/Opening-hours
55
-
56
- Opening times for the regular trading of equities (not including closing auction call)
57
- Open Time: 9:00 AM, CEST/EST
58
- Close Time: 4:20 PM, CEST/EST
59
-
60
- Regularly-Observed Holidays (not necessarily in order):
61
- - New Years Day
62
- - Wednesday before Easter (Half trading day)
63
- - Maundy Thursday
64
- - Good Friday
65
- - Easter Monday
66
- - Labour Day
67
- - Ascension Day
68
- - Constitution Day
69
- - Whit Monday
70
- - Christmas Eve
71
- - Christmas Day
72
- - Boxing Day
73
- - New Year's Eve
74
- """
75
-
76
- aliases = ["OSE"]
77
- regular_market_times = {
78
- "market_open": ((None, time(9)),),
79
- "market_close": ((None, time(16, 20)),),
80
- }
81
-
82
- @property
83
- def name(self):
84
- return "OSE"
85
-
86
- @property
87
- def tz(self):
88
- return timezone("Europe/Oslo")
89
-
90
- @property
91
- def regular_holidays(self):
92
- return AbstractHolidayCalendar(
93
- rules=[
94
- OSENewYearsDay,
95
- OSEMaundyThursday,
96
- OSEGoodFriday,
97
- OSEEasterMonday,
98
- OSELabourDay,
99
- OSEConstitutionDay,
100
- OSEWhitMonday,
101
- OSEAscensionDay,
102
- OSEChristmasEve,
103
- OSEChristmasDay,
104
- OSEBoxingDay,
105
- OSENewYearsEve,
106
- ]
107
- )
108
-
109
- @property
110
- def special_closes(self):
111
- return [
112
- (
113
- time(13, 0, tzinfo=self.tz),
114
- AbstractHolidayCalendar(rules=[OSEWednesdayBeforeEaster]),
115
- )
116
- ]
1
+ from datetime import time
2
+
3
+ from pandas.tseries.holiday import (
4
+ AbstractHolidayCalendar,
5
+ EasterMonday,
6
+ GoodFriday,
7
+ Holiday,
8
+ )
9
+ from pandas.tseries.offsets import Day, Easter
10
+ from pytz import timezone
11
+
12
+ from pandas_market_calendars.market_calendar import MarketCalendar
13
+
14
+ OSENewYearsDay = Holiday("New Year's Day", month=1, day=1)
15
+
16
+ OSEWednesdayBeforeEaster = Holiday(
17
+ "Wednesday before Easter", month=1, day=1, offset=[Easter(), Day(-4)]
18
+ )
19
+
20
+ OSEMaundyThursday = Holiday(
21
+ "Maundy Thursday", month=1, day=1, offset=[Easter(), Day(-3)]
22
+ )
23
+
24
+ OSEGoodFriday = GoodFriday
25
+
26
+ OSEEasterMonday = EasterMonday
27
+
28
+ OSELabourDay = Holiday("Labour Day", month=5, day=1)
29
+
30
+ OSEConstitutionDay = Holiday("Constitution Day", month=5, day=17)
31
+
32
+ OSEWhitMonday = Holiday("Whit Monday", month=1, day=1, offset=[Easter(), Day(50)])
33
+
34
+ OSEAscensionDay = Holiday("Ascension Day", month=1, day=1, offset=[Easter(), Day(39)])
35
+
36
+ OSEChristmasEve = Holiday(
37
+ "Christmas Eve",
38
+ month=12,
39
+ day=24,
40
+ )
41
+
42
+ OSEChristmasDay = Holiday("Christmas Day", month=12, day=25)
43
+
44
+ OSEBoxingDay = Holiday("Boxing Day", month=12, day=26)
45
+
46
+ OSENewYearsEve = Holiday("New Year's Eve", month=12, day=31)
47
+
48
+
49
+ class OSEExchangeCalendar(MarketCalendar):
50
+ """
51
+ Exchange calendar for Oslo Stock Exchange
52
+
53
+ Note these dates are only checked against 2017, 2018 and 2019
54
+ https://www.oslobors.no/ob_eng/Oslo-Boers/About-Oslo-Boers/Opening-hours
55
+
56
+ Opening times for the regular trading of equities (not including closing auction call)
57
+ Open Time: 9:00 AM, CEST/EST
58
+ Close Time: 4:20 PM, CEST/EST
59
+
60
+ Regularly-Observed Holidays (not necessarily in order):
61
+ - New Years Day
62
+ - Wednesday before Easter (Half trading day)
63
+ - Maundy Thursday
64
+ - Good Friday
65
+ - Easter Monday
66
+ - Labour Day
67
+ - Ascension Day
68
+ - Constitution Day
69
+ - Whit Monday
70
+ - Christmas Eve
71
+ - Christmas Day
72
+ - Boxing Day
73
+ - New Year's Eve
74
+ """
75
+
76
+ aliases = ["OSE"]
77
+ regular_market_times = {
78
+ "market_open": ((None, time(9)),),
79
+ "market_close": ((None, time(16, 20)),),
80
+ }
81
+
82
+ @property
83
+ def name(self):
84
+ return "OSE"
85
+
86
+ @property
87
+ def tz(self):
88
+ return timezone("Europe/Oslo")
89
+
90
+ @property
91
+ def regular_holidays(self):
92
+ return AbstractHolidayCalendar(
93
+ rules=[
94
+ OSENewYearsDay,
95
+ OSEMaundyThursday,
96
+ OSEGoodFriday,
97
+ OSEEasterMonday,
98
+ OSELabourDay,
99
+ OSEConstitutionDay,
100
+ OSEWhitMonday,
101
+ OSEAscensionDay,
102
+ OSEChristmasEve,
103
+ OSEChristmasDay,
104
+ OSEBoxingDay,
105
+ OSENewYearsEve,
106
+ ]
107
+ )
108
+
109
+ @property
110
+ def special_closes(self):
111
+ return [
112
+ (
113
+ time(13, 0, tzinfo=self.tz),
114
+ AbstractHolidayCalendar(rules=[OSEWednesdayBeforeEaster]),
115
+ )
116
+ ]