pandas-market-calendars 4.4.0__py3-none-any.whl → 4.4.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.
@@ -5,7 +5,11 @@ from .calendars.bse import BSEExchangeCalendar
5
5
  from .calendars.cboe import CFEExchangeCalendar
6
6
  from .calendars.cme import CMEEquityExchangeCalendar, CMEBondExchangeCalendar
7
7
  from .calendars.cme_globex_base import CMEGlobexBaseExchangeCalendar
8
- from .calendars.cme_globex_agriculture import CMEGlobexAgricultureExchangeCalendar
8
+ from .calendars.cme_globex_agriculture import (
9
+ CMEGlobexAgricultureExchangeCalendar,
10
+ CMEGlobexLivestockExchangeCalendar,
11
+ CMEGlobexGrainsAndOilseedsExchangeCalendar,
12
+ )
9
13
  from .calendars.cme_globex_crypto import CMEGlobexCryptoExchangeCalendar
10
14
  from .calendars.cme_globex_energy_and_metals import (
11
15
  CMEGlobexEnergyAndMetalsExchangeCalendar,
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Utilities to use with market_calendars
3
3
  """
4
+
4
5
  import itertools
5
6
  import warnings
6
7
 
@@ -31,6 +31,7 @@ from pandas_market_calendars.holidays.us import (
31
31
  ChristmasEveBefore1993,
32
32
  ChristmasEveInOrAfter1993,
33
33
  USBlackFridayInOrAfter1993,
34
+ USJuneteenthAfter2022,
34
35
  USIndependenceDay,
35
36
  USMartinLutherKingJrAfter1998,
36
37
  USMemorialDay,
@@ -98,6 +99,7 @@ class CMEEquityExchangeCalendar(MarketCalendar):
98
99
  USPresidentsDay,
99
100
  USMemorialDay,
100
101
  USLaborDay,
102
+ USJuneteenthAfter2022,
101
103
  USIndependenceDay,
102
104
  USThanksgivingDay,
103
105
  USBlackFridayInOrAfter1993,
@@ -158,6 +160,7 @@ class CMEAgricultureExchangeCalendar(MarketCalendar):
158
160
  USPresidentsDay,
159
161
  GoodFriday,
160
162
  USMemorialDay,
163
+ USJuneteenthAfter2022,
161
164
  USIndependenceDay,
162
165
  USLaborDay,
163
166
  USThanksgivingDay,
@@ -124,3 +124,49 @@ class CMEGlobexLivestockExchangeCalendar(CMEGlobexAgricultureExchangeCalendar):
124
124
  ),
125
125
  )
126
126
  ]
127
+
128
+
129
+ class CMEGlobexGrainsAndOilseedsExchangeCalendar(CMEGlobexAgricultureExchangeCalendar):
130
+ """
131
+ Exchange calendar for CME for Grains & Oilseeds
132
+
133
+ https://www.cmegroup.com/trading/agricultural/grain-and-oilseed.html
134
+
135
+ GLOBEX Trading Times
136
+ https://www.cmegroup.com/markets/agriculture/oilseeds/soybean.contractSpecs.html
137
+ https://www.cmegroup.com/markets/agriculture/grains/corn.contractSpecs.html
138
+ https://www.cmegroup.com/markets/agriculture/grains/wheat.contractSpecs.html
139
+ Sunday - Friday: 7:00 p.m. - 7:45 a.m. CT and Monday - Friday: 8:30 a.m. - 1:20 p.m. CT
140
+ """
141
+
142
+ aliases = [
143
+ "CMEGlobex_Grains",
144
+ "CMEGlobex_Oilseeds",
145
+ ]
146
+
147
+ regular_market_times = {
148
+ "market_open": ((None, time(19), -1),), # offset by -1 day
149
+ "market_close": ((None, time(13, 20)),),
150
+ "break_start": ((None, time(7, 45)),),
151
+ "break_end": ((None, time(8, 30)),),
152
+ }
153
+
154
+ @property
155
+ def name(self):
156
+ return "CMEGlobex_GrainsAndOilseeds"
157
+
158
+ @property
159
+ def regular_holidays(self):
160
+ return AbstractHolidayCalendar(
161
+ rules=[
162
+ USNewYearsDay,
163
+ USMartinLutherKingJrAfter1998,
164
+ USPresidentsDay,
165
+ GoodFriday,
166
+ USMemorialDay,
167
+ USIndependenceDay,
168
+ USLaborDay,
169
+ USThanksgivingDay,
170
+ Christmas,
171
+ ]
172
+ )
@@ -43,13 +43,6 @@ MayBank = Holiday(
43
43
  day=1,
44
44
  days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
45
45
  )
46
- # German National Holiday (Tag der Deutschen Einheit)
47
- GermanNationalDay = Holiday(
48
- "Tag der Deutschen Einheit",
49
- month=10,
50
- day=3,
51
- days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY),
52
- )
53
46
  # Christmas Eve
54
47
  ChristmasEve = Holiday(
55
48
  "Christmas Eve",
@@ -116,7 +109,6 @@ class EUREXExchangeCalendar(MarketCalendar):
116
109
  GoodFriday,
117
110
  EasterMonday,
118
111
  MayBank,
119
- GermanNationalDay,
120
112
  Christmas,
121
113
  WeekendChristmas,
122
114
  BoxingDay,
@@ -354,6 +354,9 @@ HKClosedDay = [
354
354
  Timestamp("2016-10-21", tz="UTC"), # 台风海马1622
355
355
  # Timestamp(2017-06-12', tz='UTC'), # 台风苗柏1702,期货夜盘17:35休市
356
356
  Timestamp("2017-08-23", tz="UTC"), # 台风天鸽1713
357
+ Timestamp("2023-07-17", tz="UTC"), # Typhoon closure
358
+ Timestamp("2023-09-01", tz="UTC"), # Typhoon closure
359
+ Timestamp("2023-09-08", tz="UTC"), # Typhoon closure
357
360
  ]
358
361
 
359
362
 
@@ -8,6 +8,8 @@ import exchange_calendars
8
8
 
9
9
  from pandas_market_calendars.market_calendar import MarketCalendar
10
10
 
11
+ DAYMASKS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
12
+
11
13
 
12
14
  class TradingCalendar(MarketCalendar):
13
15
  """
@@ -97,6 +99,23 @@ class TradingCalendar(MarketCalendar):
97
99
  def special_closes_adhoc(self):
98
100
  return self._ec.special_closes_adhoc
99
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
+
100
119
 
101
120
  calendars = exchange_calendars.calendar_utils._default_calendar_factories # noqa
102
121
 
@@ -565,6 +565,7 @@ all_holidays = [
565
565
  Timestamp("2023-10-05"),
566
566
  Timestamp("2023-10-06"),
567
567
  Timestamp("2024-01-01"),
568
+ Timestamp("2024-02-09"),
568
569
  Timestamp("2024-02-12"),
569
570
  Timestamp("2024-02-13"),
570
571
  Timestamp("2024-02-14"),
@@ -11,6 +11,7 @@ from the Tokyo exchange inauguration through 2099,
11
11
  using pyephem (http://rhodesmill.org/pyephem/quick.html#equinoxes-solstices).
12
12
  For a double check, see: https://aa.usno.navy.mil/data/docs/EarthSeasons.php
13
13
  """
14
+
14
15
  import pandas as pd
15
16
  from pandas.tseries.holiday import sunday_to_monday
16
17
 
@@ -24,6 +24,16 @@ from .class_registry import RegisteryMeta, ProtectedDict
24
24
 
25
25
  MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY = range(7)
26
26
 
27
+ WEEKMASK_ABBR = {
28
+ MONDAY: "Mon",
29
+ TUESDAY: "Tue",
30
+ WEDNESDAY: "Wed",
31
+ THURSDAY: "Thu",
32
+ FRIDAY: "Fri",
33
+ SATURDAY: "Sat",
34
+ SUNDAY: "Sun",
35
+ }
36
+
27
37
 
28
38
  class DEFAULT:
29
39
  pass
@@ -621,15 +631,28 @@ class MarketCalendar(metaclass=MarketCalendarMeta):
621
631
 
622
632
  def _special_dates(self, calendars, ad_hoc_dates, start, end):
623
633
  """
624
- Union an iterable of pairs of the form (time, calendar)
625
- and an iterable of pairs of the form (time, [dates])
634
+ Union an iterable of pairs of the forms (time, calendar),
635
+ (time, [dates]), and (time, int). If the second item in the pair
636
+ is an int it will be interpreted as a specific day of the week.
626
637
 
627
638
  (This is shared logic for computing special opens and special closes.)
628
639
  """
629
- indexes = [
630
- self.days_at_time(self._tryholidays(calendar, start, end), time_)
631
- for time_, calendar in calendars
632
- ] + [self.days_at_time(dates, time_) for time_, dates in ad_hoc_dates]
640
+ indexes = []
641
+ for time_, calendar in calendars:
642
+ if isinstance(calendar, int):
643
+ day_of_week = CustomBusinessDay(weekmask=WEEKMASK_ABBR[calendar])
644
+ indexes.append(
645
+ self.days_at_time(
646
+ pd.date_range(start, end, freq=day_of_week), time_
647
+ )
648
+ )
649
+ else:
650
+ indexes.append(
651
+ self.days_at_time(self._tryholidays(calendar, start, end), time_)
652
+ )
653
+
654
+ indexes += [self.days_at_time(dates, time_) for time_, dates in ad_hoc_dates]
655
+
633
656
  if indexes:
634
657
  dates = pd.concat(indexes).sort_index().drop_duplicates()
635
658
  return dates.loc[start : end.replace(hour=23, minute=59, second=59)]
@@ -812,7 +835,11 @@ class MarketCalendar(metaclass=MarketCalendarMeta):
812
835
 
813
836
  # When post follows market_close, market_close should not be considered a close
814
837
  day.loc[day.eq("market_close") & day.shift(-1).eq("post")] = "market_open"
815
- day = day.replace(self.open_close_map)
838
+ day = day.map(
839
+ lambda x: (
840
+ self.open_close_map.get(x) if x in self.open_close_map.keys() else x
841
+ )
842
+ )
816
843
 
817
844
  if include_close:
818
845
  below = day.index < timestamp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pandas_market_calendars
3
- Version: 4.4.0
3
+ Version: 4.4.1
4
4
  Summary: Market and exchange trading calendars for pandas
5
5
  Author-email: Ryan Sheftel <rsheftel@alumni.upenn.edu>
6
6
  License: MIT
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
- Requires-Python: >=3.9
21
+ Requires-Python: >=3.8
22
22
  Description-Content-Type: text/x-rst
23
23
  License-File: LICENSE
24
24
  License-File: NOTICE
@@ -1,29 +1,29 @@
1
1
  pandas_market_calendars/__init__.py,sha256=prBpkD2f2mShZjZePVa0L3_Cf-Tv48r6q-J_mFNFFuY,1323
2
- pandas_market_calendars/calendar_registry.py,sha256=S7TKQgrOXQr2sJP3e1-x6VBfB6OB8R8CVIzNZv1cp9U,2398
3
- pandas_market_calendars/calendar_utils.py,sha256=gCL-FWYm18jDkzw-pWGxD0W2rgaVeYPbP5cQ_g0nJOM,11628
2
+ pandas_market_calendars/calendar_registry.py,sha256=9ecKkERkztiwVaOXVsWfUcEvaT5_SwwpD5VaUAJhR1Y,2495
3
+ pandas_market_calendars/calendar_utils.py,sha256=6yBqT_FBBicSVurudGgCGpKakomnXfYORxnWLYVH2l8,11629
4
4
  pandas_market_calendars/class_registry.py,sha256=lpRSp1E_1vcY73a--daCIOsJpoxpJVuhlurRGDVUqlc,3868
5
- pandas_market_calendars/market_calendar.py,sha256=gtpI9s7S1tP2ZpfJLvLDIrwO8M7YUBPsD7yTMaVG4Sc,33155
5
+ pandas_market_calendars/market_calendar.py,sha256=0Df4H8YZm5DBwAOzvVl4LysQ9FzqGnAqf6rfL05RNuc,33905
6
6
  pandas_market_calendars/calendars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  pandas_market_calendars/calendars/asx.py,sha256=tocL_VXzbPNx89mmtXmSw7FKHy2Hzlj5HxcYjfJSn6w,1789
8
8
  pandas_market_calendars/calendars/bmf.py,sha256=eyCFpG-ziuI862V5E41PFQw5cD3cOvmgnlAqcYuk9r4,5939
9
9
  pandas_market_calendars/calendars/bse.py,sha256=mclRAAK5AvF9vyuIos1PexO0Z3d45ZolrPALVdcSoj0,16947
10
10
  pandas_market_calendars/calendars/cboe.py,sha256=tRfq1hiOU2LpEAk-8OC5difM2qLjxNDDpkgobTQtcVI,3765
11
- pandas_market_calendars/calendars/cme.py,sha256=lsYQT9bjnvqzms7Xvz2CmJmMBOXgasY62WDsvNXoH5s,10337
12
- pandas_market_calendars/calendars/cme_globex_agriculture.py,sha256=kX4GSdqDdWwzrxaXo4LROM8Rj8XgEVjVbuoZU2rvNKQ,3238
11
+ pandas_market_calendars/calendars/cme.py,sha256=YJH58ztmnKiyZZ7z2CK4pcvBLOQtflZcUFn1m3o5aLA,10450
12
+ pandas_market_calendars/calendars/cme_globex_agriculture.py,sha256=j1Dyg1Q_i3fh4452OeFa5Jw55FW0dhdjmPkmjP85KPc,4666
13
13
  pandas_market_calendars/calendars/cme_globex_base.py,sha256=0mvilo9TY5O5EVHNQVNcI8TGycKM5-ymsIcZ4a-ANhU,3062
14
14
  pandas_market_calendars/calendars/cme_globex_crypto.py,sha256=HbjTTN8pt2dGfgnE3LS0LIzJlaenYAzilvN9AMwkbfc,5463
15
15
  pandas_market_calendars/calendars/cme_globex_energy_and_metals.py,sha256=lcd09CIfZMaZ-mXrI-6c7bqgPx8tj6-2yCOG-f2Hlu4,6620
16
16
  pandas_market_calendars/calendars/cme_globex_equities.py,sha256=FMgBDPdamDAgcslQuf-BDUACCQDoYzV4lIbixNLOO-w,3639
17
17
  pandas_market_calendars/calendars/cme_globex_fixed_income.py,sha256=egxw-OKUI-SPbNjsLquqPDWQIVX94-torkAuzW6a0aA,4287
18
18
  pandas_market_calendars/calendars/cme_globex_fx.py,sha256=lZJpZvKWC9kGcHVjUSG69vH82VwiifLYt1rAlZsDVaM,3206
19
- pandas_market_calendars/calendars/eurex.py,sha256=nEQCg7aHb2UPbkt9oESIbprQ6GES3TwI7vKjYJnIHXg,2920
19
+ pandas_market_calendars/calendars/eurex.py,sha256=h9K0kvLggc50MKjGb61gfepuiyKovD2uPHCLBruvcBU,2677
20
20
  pandas_market_calendars/calendars/eurex_fixed_income.py,sha256=irtSJvCRsn_N2AjjYe5jMvuxblgOx1BTQW2C34RGFlg,2132
21
- pandas_market_calendars/calendars/hkex.py,sha256=Jcgsgx1ZAeXh32U2CDMEUGJgL_pgep84LVWyuZpLwhw,13822
21
+ pandas_market_calendars/calendars/hkex.py,sha256=dQj4roWPLxcxcMaYC9WBaFaHcqsXPdozTufF4ByZN-A,13996
22
22
  pandas_market_calendars/calendars/ice.py,sha256=CnlbD3g7L6goukKZtSm-deuCdlB4ZcILTkYbol43TPQ,2159
23
23
  pandas_market_calendars/calendars/iex.py,sha256=e85oEuqbyxLUkm7ZtvRw2A1RLNZj3F-v17MOFuLbCZY,3027
24
24
  pandas_market_calendars/calendars/jpx.py,sha256=cXi_qLcNG6OIaQy5oLl8XPzPMR58O4Tf9Kb1yPIxM5g,3595
25
25
  pandas_market_calendars/calendars/lse.py,sha256=qltdB1TdQ3F8jqx4oykzy_cZvqHlHwnsrpRXzBsovVc,3114
26
- pandas_market_calendars/calendars/mirror.py,sha256=mGqPVT7xOTLKolGJ1wPRuF9_fSD2TBSYHrPBBQa2--M,3938
26
+ pandas_market_calendars/calendars/mirror.py,sha256=Oq9jRXYpKmPv6PfoKDVVLyIG7hqcuFFC7fPLcCIhl7k,4555
27
27
  pandas_market_calendars/calendars/nyse.py,sha256=QtIltvSiANIAtkr3b1KQqRsZ5aT847WvxHwC0rbhgNc,60293
28
28
  pandas_market_calendars/calendars/ose.py,sha256=AfF11QxKYwozaaEc2PvuP3IPvVj5D70mIl0zyp5OogE,2938
29
29
  pandas_market_calendars/calendars/sifma.py,sha256=RgOX1yhT8-b6w029ILkOhU-delPCeX6uNWoWDm1Z0eE,9960
@@ -34,17 +34,17 @@ pandas_market_calendars/calendars/tsx.py,sha256=3zQwdU9LkiJjZRF1fgLGHYYcJMC-443Q
34
34
  pandas_market_calendars/holidays/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  pandas_market_calendars/holidays/cme.py,sha256=TrxR8xA6cgy0YcUfImaKI2QjRmqlwv6pW5KjMKsE1Rg,9089
36
36
  pandas_market_calendars/holidays/cme_globex.py,sha256=0SPVGABO7K66eRitDsDgxRU52aPX8SRGgtUVyB_-LYk,5090
37
- pandas_market_calendars/holidays/cn.py,sha256=DSVG1uWB9kmrZ4D-vuPc5Q6Rw8WCkCXkdDCifKHyygg,46740
37
+ pandas_market_calendars/holidays/cn.py,sha256=POVI0y12lSGo437K1zpeU4AdGO9FvJBfFAKUvYCsfm0,46769
38
38
  pandas_market_calendars/holidays/jp.py,sha256=rqobVw837Uxb-4D1Zq_PyBLoeyhImYW7DBwyJupJIp8,9216
39
- pandas_market_calendars/holidays/jpx_equinox.py,sha256=bEg0Dr3S6z28sG1dn2s_bU60Pf9gcwwsg7l4cWLdgQY,8069
39
+ pandas_market_calendars/holidays/jpx_equinox.py,sha256=KWbJqWsnkdyzG3fD2gJTXRLQOF3YTWSn9O6sYRL9Dnk,8070
40
40
  pandas_market_calendars/holidays/nyse.py,sha256=8A-Lc-mZXdWqMRXaC899unyQfjv2ixjJiC16jXZ5wGo,39757
41
41
  pandas_market_calendars/holidays/oz.py,sha256=P77pWe7ZQj4o-731w6fW_Vzmo41PRxh94QpclI3ZyFM,1042
42
42
  pandas_market_calendars/holidays/sifma.py,sha256=gELES9-NeV3QNGE4JpsVfmcs1-jtYQrLxjnG4B-4RmM,8754
43
43
  pandas_market_calendars/holidays/uk.py,sha256=dt5TNONlDMXPw8wjyyPBYNnLO5Yz6Mht8VrPUrNqy-M,4719
44
44
  pandas_market_calendars/holidays/us.py,sha256=OBBMMKTRzghD-b9CmPRe5zBh7zQYjWl4-9SogT6ZnBo,11515
45
- pandas_market_calendars-4.4.0.dist-info/LICENSE,sha256=qW51_A-I7YutlB-s8VSKeOP-aL83T-Lb8LqqU1x1ilw,1065
46
- pandas_market_calendars-4.4.0.dist-info/METADATA,sha256=-ifk1_aq0kJc1borEbTajEnivvHtjeUEhtaS-Wj0vl8,9011
47
- pandas_market_calendars-4.4.0.dist-info/NOTICE,sha256=mmH7c9aF5FsELh1OHXloXw1TajLD_mWDKO4dsVf43_E,11693
48
- pandas_market_calendars-4.4.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
49
- pandas_market_calendars-4.4.0.dist-info/top_level.txt,sha256=_4cUEFr07SuEAzZMT-5p0lJGXxO9imVbEK9_5oqcopQ,24
50
- pandas_market_calendars-4.4.0.dist-info/RECORD,,
45
+ pandas_market_calendars-4.4.1.dist-info/LICENSE,sha256=qW51_A-I7YutlB-s8VSKeOP-aL83T-Lb8LqqU1x1ilw,1065
46
+ pandas_market_calendars-4.4.1.dist-info/METADATA,sha256=AEdB9Of7N2uW4vT4a9izyABgrYnYmDpAsQ30HPpaCak,9011
47
+ pandas_market_calendars-4.4.1.dist-info/NOTICE,sha256=mmH7c9aF5FsELh1OHXloXw1TajLD_mWDKO4dsVf43_E,11693
48
+ pandas_market_calendars-4.4.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
49
+ pandas_market_calendars-4.4.1.dist-info/top_level.txt,sha256=_4cUEFr07SuEAzZMT-5p0lJGXxO9imVbEK9_5oqcopQ,24
50
+ pandas_market_calendars-4.4.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5