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.
Files changed (49) hide show
  1. pandas_market_calendars/__init__.py +38 -37
  2. pandas_market_calendars/calendar_registry.py +53 -48
  3. pandas_market_calendars/calendar_utils.py +261 -225
  4. pandas_market_calendars/calendars/asx.py +66 -63
  5. pandas_market_calendars/calendars/bmf.py +206 -227
  6. pandas_market_calendars/calendars/bse.py +407 -409
  7. pandas_market_calendars/calendars/cboe.py +145 -115
  8. pandas_market_calendars/calendars/cme.py +402 -240
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +126 -103
  10. pandas_market_calendars/calendars/cme_globex_base.py +119 -103
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +160 -147
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -138
  13. pandas_market_calendars/calendars/cme_globex_equities.py +123 -104
  14. pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -113
  15. pandas_market_calendars/calendars/cme_globex_fx.py +101 -78
  16. pandas_market_calendars/calendars/eurex.py +139 -119
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +98 -0
  18. pandas_market_calendars/calendars/hkex.py +426 -408
  19. pandas_market_calendars/calendars/ice.py +81 -65
  20. pandas_market_calendars/calendars/iex.py +112 -98
  21. pandas_market_calendars/calendars/jpx.py +109 -103
  22. pandas_market_calendars/calendars/lse.py +114 -91
  23. pandas_market_calendars/calendars/mirror.py +130 -114
  24. pandas_market_calendars/calendars/nyse.py +1324 -1127
  25. pandas_market_calendars/calendars/ose.py +116 -150
  26. pandas_market_calendars/calendars/sifma.py +350 -297
  27. pandas_market_calendars/calendars/six.py +132 -114
  28. pandas_market_calendars/calendars/sse.py +311 -290
  29. pandas_market_calendars/calendars/tase.py +197 -195
  30. pandas_market_calendars/calendars/tsx.py +181 -159
  31. pandas_market_calendars/class_registry.py +22 -16
  32. pandas_market_calendars/holidays/cme.py +385 -340
  33. pandas_market_calendars/holidays/cme_globex.py +214 -198
  34. pandas_market_calendars/holidays/cn.py +1455 -1436
  35. pandas_market_calendars/holidays/jp.py +398 -396
  36. pandas_market_calendars/holidays/jpx_equinox.py +453 -95
  37. pandas_market_calendars/holidays/nyse.py +1531 -1472
  38. pandas_market_calendars/holidays/oz.py +63 -65
  39. pandas_market_calendars/holidays/sifma.py +338 -321
  40. pandas_market_calendars/holidays/uk.py +32 -26
  41. pandas_market_calendars/holidays/us.py +376 -360
  42. pandas_market_calendars/market_calendar.py +895 -789
  43. {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/METADATA +7 -5
  44. pandas_market_calendars-4.3.3.dist-info/RECORD +50 -0
  45. {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/WHEEL +1 -1
  46. pandas_market_calendars-4.3.1.dist-info/RECORD +0 -49
  47. {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/LICENSE +0 -0
  48. {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/NOTICE +0 -0
  49. {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/top_level.txt +0 -0
@@ -1,159 +1,181 @@
1
- from datetime import time
2
-
3
- import pandas as pd
4
- from pandas.tseries.holiday import AbstractHolidayCalendar, DateOffset, GoodFriday, Holiday, MO, weekend_to_monday
5
- from pytz import timezone
6
- from itertools import chain
7
-
8
- from pandas_market_calendars.holidays.uk import BoxingDay, WeekendBoxingDay, WeekendChristmas
9
- from pandas_market_calendars.market_calendar import MarketCalendar, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY
10
-
11
- # New Year's Day
12
- TSXNewYearsDay = Holiday(
13
- "New Year's Day",
14
- month=1,
15
- day=1,
16
- observance=weekend_to_monday,
17
- )
18
- # Ontario Family Day
19
- FamilyDay = Holiday(
20
- "Family Day",
21
- month=2,
22
- day=1,
23
- offset=DateOffset(weekday=MO(3)),
24
- start_date='2008-01-01',
25
- )
26
- # Victoria Day
27
- # https://www.timeanddate.com/holidays/canada/victoria-day
28
- VictoriaDay = Holiday(
29
- 'Victoria Day',
30
- month=5,
31
- day=24,
32
- offset=DateOffset(weekday=MO(-1)),
33
- )
34
- # Canada Day
35
- CanadaDay = Holiday(
36
- 'Canada Day',
37
- month=7,
38
- day=1,
39
- observance=weekend_to_monday,
40
- )
41
- # Civic Holiday
42
- CivicHoliday = Holiday(
43
- 'Civic Holiday',
44
- month=8,
45
- day=1,
46
- offset=DateOffset(weekday=MO(1)),
47
- )
48
- # Labor Day
49
- LaborDay = Holiday(
50
- 'Labor Day',
51
- month=9,
52
- day=1,
53
- offset=DateOffset(weekday=MO(1)),
54
- )
55
- # Thanksgiving
56
- Thanksgiving = Holiday(
57
- 'Thanksgiving',
58
- month=10,
59
- day=1,
60
- offset=DateOffset(weekday=MO(2)),
61
- )
62
-
63
- Christmas = Holiday(
64
- 'Christmas',
65
- month=12,
66
- day=25,
67
- )
68
-
69
- ChristmasEveEarlyClose2010Onwards = Holiday(
70
- "Christmas Eve Early Close",
71
- month=12,
72
- day=24,
73
- days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
74
- start_date=pd.Timestamp("2010-01-01"),
75
- )
76
-
77
- September11Closings2001 = [
78
- pd.Timestamp("2001-09-11", tz='UTC'),
79
- pd.Timestamp("2001-09-12", tz='UTC'),
80
- ]
81
-
82
-
83
- class TSXExchangeCalendar(MarketCalendar):
84
- """
85
- Exchange calendar for the Toronto Stock Exchange
86
-
87
- Open Time: 9:30 AM, EST
88
- Close Time: 4:00 PM, EST
89
-
90
- Regularly-Observed Holidays:
91
- - New Years Day (observed on first business day on/after)
92
- - Family Day (Third Monday in February, starting in 2008)
93
- - Good Friday
94
- - Victoria Day (Monday before May 25th)
95
- - Canada Day (July 1st, observed first business day after)
96
- - Civic Holiday (First Monday in August)
97
- - Labor Day (First Monday in September)
98
- - Thanksgiving (Second Monday in October)
99
- - Christmas Day
100
- - Dec. 26th if Christmas is on a Sunday
101
- - Dec. 27th if Christmas is on a weekend
102
- - Boxing Day
103
- - Dec. 27th if Christmas is on a Sunday
104
- - Dec. 28th if Boxing Day is on a weekend
105
-
106
- Early closes:
107
- - Starting in 2010, if Christmas Eve falls on a weekday, the market
108
- closes at 1:00 pm that day. If it falls on a weekend, there is no
109
- early close.
110
- """
111
- aliases = ['TSX', 'TSXV']
112
-
113
- regular_market_times = {
114
- "market_open": ((None, time(9, 30)),),
115
- "market_close": ((None, time(16)),)
116
- }
117
-
118
-
119
- @property
120
- def name(self):
121
- return "TSX"
122
-
123
- @property
124
- def tz(self):
125
- return timezone('Canada/Eastern')
126
-
127
- regular_early_close = time(13)
128
-
129
- @property
130
- def regular_holidays(self):
131
- return AbstractHolidayCalendar(rules=[
132
- TSXNewYearsDay,
133
- FamilyDay,
134
- GoodFriday,
135
- VictoriaDay,
136
- CanadaDay,
137
- CivicHoliday,
138
- LaborDay,
139
- Thanksgiving,
140
- Christmas,
141
- WeekendChristmas,
142
- BoxingDay,
143
- WeekendBoxingDay
144
- ])
145
-
146
- @property
147
- def adhoc_holidays(self):
148
- return list(chain(
149
- September11Closings2001,
150
- ))
151
-
152
- @property
153
- def special_closes(self):
154
- return [
155
- (
156
- self.regular_early_close,
157
- AbstractHolidayCalendar([ChristmasEveEarlyClose2010Onwards]),
158
- )
159
- ]
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
+ DateOffset,
8
+ GoodFriday,
9
+ Holiday,
10
+ MO,
11
+ weekend_to_monday,
12
+ )
13
+ from pytz import timezone
14
+
15
+ from pandas_market_calendars.holidays.uk import (
16
+ BoxingDay,
17
+ WeekendBoxingDay,
18
+ WeekendChristmas,
19
+ )
20
+ from pandas_market_calendars.market_calendar import (
21
+ MarketCalendar,
22
+ MONDAY,
23
+ TUESDAY,
24
+ WEDNESDAY,
25
+ THURSDAY,
26
+ FRIDAY,
27
+ )
28
+
29
+ # New Year's Day
30
+ TSXNewYearsDay = Holiday(
31
+ "New Year's Day",
32
+ month=1,
33
+ day=1,
34
+ observance=weekend_to_monday,
35
+ )
36
+ # Ontario Family Day
37
+ FamilyDay = Holiday(
38
+ "Family Day",
39
+ month=2,
40
+ day=1,
41
+ offset=DateOffset(weekday=MO(3)),
42
+ start_date="2008-01-01",
43
+ )
44
+ # Victoria Day
45
+ # https://www.timeanddate.com/holidays/canada/victoria-day
46
+ VictoriaDay = Holiday(
47
+ "Victoria Day",
48
+ month=5,
49
+ day=24,
50
+ offset=DateOffset(weekday=MO(-1)),
51
+ )
52
+ # Canada Day
53
+ CanadaDay = Holiday(
54
+ "Canada Day",
55
+ month=7,
56
+ day=1,
57
+ observance=weekend_to_monday,
58
+ )
59
+ # Civic Holiday
60
+ CivicHoliday = Holiday(
61
+ "Civic Holiday",
62
+ month=8,
63
+ day=1,
64
+ offset=DateOffset(weekday=MO(1)),
65
+ )
66
+ # Labor Day
67
+ LaborDay = Holiday(
68
+ "Labor Day",
69
+ month=9,
70
+ day=1,
71
+ offset=DateOffset(weekday=MO(1)),
72
+ )
73
+ # Thanksgiving
74
+ Thanksgiving = Holiday(
75
+ "Thanksgiving",
76
+ month=10,
77
+ day=1,
78
+ offset=DateOffset(weekday=MO(2)),
79
+ )
80
+
81
+ Christmas = Holiday(
82
+ "Christmas",
83
+ month=12,
84
+ day=25,
85
+ )
86
+
87
+ ChristmasEveEarlyClose2010Onwards = Holiday(
88
+ "Christmas Eve Early Close",
89
+ month=12,
90
+ day=24,
91
+ days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
92
+ start_date=pd.Timestamp("2010-01-01"),
93
+ )
94
+
95
+ September11Closings2001 = [
96
+ pd.Timestamp("2001-09-11", tz="UTC"),
97
+ pd.Timestamp("2001-09-12", tz="UTC"),
98
+ ]
99
+
100
+
101
+ class TSXExchangeCalendar(MarketCalendar):
102
+ """
103
+ Exchange calendar for the Toronto Stock Exchange
104
+
105
+ Open Time: 9:30 AM, EST
106
+ Close Time: 4:00 PM, EST
107
+
108
+ Regularly-Observed Holidays:
109
+ - New Years Day (observed on first business day on/after)
110
+ - Family Day (Third Monday in February, starting in 2008)
111
+ - Good Friday
112
+ - Victoria Day (Monday before May 25th)
113
+ - Canada Day (July 1st, observed first business day after)
114
+ - Civic Holiday (First Monday in August)
115
+ - Labor Day (First Monday in September)
116
+ - Thanksgiving (Second Monday in October)
117
+ - Christmas Day
118
+ - Dec. 26th if Christmas is on a Sunday
119
+ - Dec. 27th if Christmas is on a weekend
120
+ - Boxing Day
121
+ - Dec. 27th if Christmas is on a Sunday
122
+ - Dec. 28th if Boxing Day is on a weekend
123
+
124
+ Early closes:
125
+ - Starting in 2010, if Christmas Eve falls on a weekday, the market
126
+ closes at 1:00 pm that day. If it falls on a weekend, there is no
127
+ early close.
128
+ """
129
+
130
+ aliases = ["TSX", "TSXV"]
131
+
132
+ regular_market_times = {
133
+ "market_open": ((None, time(9, 30)),),
134
+ "market_close": ((None, time(16)),),
135
+ }
136
+
137
+ @property
138
+ def name(self):
139
+ return "TSX"
140
+
141
+ @property
142
+ def tz(self):
143
+ return timezone("Canada/Eastern")
144
+
145
+ regular_early_close = time(13)
146
+
147
+ @property
148
+ def regular_holidays(self):
149
+ return AbstractHolidayCalendar(
150
+ rules=[
151
+ TSXNewYearsDay,
152
+ FamilyDay,
153
+ GoodFriday,
154
+ VictoriaDay,
155
+ CanadaDay,
156
+ CivicHoliday,
157
+ LaborDay,
158
+ Thanksgiving,
159
+ Christmas,
160
+ WeekendChristmas,
161
+ BoxingDay,
162
+ WeekendBoxingDay,
163
+ ]
164
+ )
165
+
166
+ @property
167
+ def adhoc_holidays(self):
168
+ return list(
169
+ chain(
170
+ September11Closings2001,
171
+ )
172
+ )
173
+
174
+ @property
175
+ def special_closes(self):
176
+ return [
177
+ (
178
+ self.regular_early_close,
179
+ AbstractHolidayCalendar([ChristmasEveEarlyClose2010Onwards]),
180
+ )
181
+ ]
@@ -1,6 +1,7 @@
1
1
  import inspect
2
2
  from pprint import pformat
3
3
 
4
+
4
5
  def _regmeta_instance_factory(cls, name, *args, **kwargs):
5
6
  """
6
7
  :param cls(RegisteryMeta): registration meta class
@@ -13,16 +14,20 @@ def _regmeta_instance_factory(cls, name, *args, **kwargs):
13
14
  class_ = cls._regmeta_class_registry[name]
14
15
  except KeyError:
15
16
  raise RuntimeError(
16
- 'Class {} is not one of the registered classes: {}'.format(name, cls._regmeta_class_registry.keys()))
17
+ "Class {} is not one of the registered classes: {}".format(
18
+ name, cls._regmeta_class_registry.keys()
19
+ )
20
+ )
17
21
  return class_(*args, **kwargs)
18
22
 
23
+
19
24
  def _regmeta_register_class(cls, regcls, name):
20
25
  """
21
26
  :param cls(RegisteryMeta): registration base class
22
27
  :param regcls(class): class to be registered
23
28
  :param name(str): name of the class to be registered
24
29
  """
25
- if hasattr(regcls, 'aliases'):
30
+ if hasattr(regcls, "aliases"):
26
31
  if regcls.aliases:
27
32
  for alias in regcls.aliases:
28
33
  cls._regmeta_class_registry[alias] = regcls
@@ -39,7 +44,7 @@ class RegisteryMeta(type):
39
44
 
40
45
  def __new__(mcs, name, bases, attr):
41
46
  cls = super(RegisteryMeta, mcs).__new__(mcs, name, bases, attr)
42
- if not hasattr(cls, '_regmeta_class_registry'):
47
+ if not hasattr(cls, "_regmeta_class_registry"):
43
48
  cls._regmeta_class_registry = {}
44
49
  cls.factory = classmethod(_regmeta_instance_factory)
45
50
 
@@ -49,7 +54,7 @@ class RegisteryMeta(type):
49
54
  if not inspect.isabstract(cls):
50
55
  _regmeta_register_class(cls, cls, name)
51
56
  for b in bases:
52
- if hasattr(b, '_regmeta_class_registry'):
57
+ if hasattr(b, "_regmeta_class_registry"):
53
58
  _regmeta_register_class(b, cls, name)
54
59
 
55
60
  super(RegisteryMeta, cls).__init__(name, bases, attr)
@@ -65,7 +70,6 @@ class RegisteryMeta(type):
65
70
 
66
71
 
67
72
  class ProtectedDict(dict):
68
-
69
73
  def __init__(self, *args, **kwargs):
70
74
  super().__init__(*args, **kwargs)
71
75
  # __init__ is bypassed when unpickling, which causes __setitem__ to fail
@@ -82,30 +86,32 @@ class ProtectedDict(dict):
82
86
  if not hasattr(self, "_INIT_RAN_NORMALLY"):
83
87
  return self._set(key, value)
84
88
 
85
- raise TypeError("You cannot set a value directly, you can change regular_market_times "
86
- "using .change_time, .add_time or .remove_time.")
89
+ raise TypeError(
90
+ "You cannot set a value directly, you can change regular_market_times "
91
+ "using .change_time, .add_time or .remove_time."
92
+ )
87
93
 
88
94
  def __delitem__(self, key):
89
95
  if not hasattr(self, "_INIT_RAN_NORMALLY"):
90
96
  return self._del(key)
91
97
 
92
- raise TypeError("You cannot delete an item directly. You can change regular_market_times "
93
- "using .change_time, .add_time or .remove_time")
98
+ raise TypeError(
99
+ "You cannot delete an item directly. You can change regular_market_times "
100
+ "using .change_time, .add_time or .remove_time"
101
+ )
94
102
 
95
103
  def __repr__(self):
96
- return self.__class__.__name__+ "(" + super().__repr__() + ")"
104
+ return self.__class__.__name__ + "(" + super().__repr__() + ")"
97
105
 
98
106
  def __str__(self):
99
107
  try:
100
- formatted = pformat(dict(self), sort_dicts= False) # sort_dicts apparently not available < python3.8
108
+ formatted = pformat(
109
+ dict(self), sort_dicts=False
110
+ ) # sort_dicts apparently not available < python3.8
101
111
  except TypeError:
102
112
  formatted = pformat(dict(self))
103
113
 
104
- return self.__class__.__name__+ "(\n" + formatted + "\n)"
114
+ return self.__class__.__name__ + "(\n" + formatted + "\n)"
105
115
 
106
116
  def copy(self):
107
117
  return self.__class__(super().copy())
108
-
109
-
110
-
111
-