pandas-market-calendars 4.4.0__tar.gz → 4.4.1__tar.gz

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 (88) hide show
  1. {pandas_market_calendars-4.4.0/pandas_market_calendars.egg-info → pandas_market_calendars-4.4.1}/PKG-INFO +2 -2
  2. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendar_registry.py +5 -1
  3. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendar_utils.py +1 -0
  4. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme.py +3 -0
  5. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_agriculture.py +46 -0
  6. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/eurex.py +0 -8
  7. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/hkex.py +3 -0
  8. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/mirror.py +19 -0
  9. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/cn.py +1 -0
  10. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/jpx_equinox.py +1 -0
  11. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/market_calendar.py +34 -7
  12. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1/pandas_market_calendars.egg-info}/PKG-INFO +2 -2
  13. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars.egg-info/SOURCES.txt +4 -1
  14. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pyproject.toml +2 -2
  15. pandas_market_calendars-4.4.1/tests/test_24_7_calendar.py +25 -0
  16. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_cme_agriculture_calendar.py +0 -1
  17. pandas_market_calendars-4.4.1/tests/test_exchange_calendar_cme_globex_grains.py +30 -0
  18. pandas_market_calendars-4.4.1/tests/test_xtae_calendar.py +53 -0
  19. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/LICENSE +0 -0
  20. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/NOTICE +0 -0
  21. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/README.rst +0 -0
  22. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/__init__.py +0 -0
  23. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/__init__.py +0 -0
  24. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/asx.py +0 -0
  25. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/bmf.py +0 -0
  26. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/bse.py +0 -0
  27. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cboe.py +0 -0
  28. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_base.py +0 -0
  29. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_crypto.py +0 -0
  30. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +0 -0
  31. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_equities.py +0 -0
  32. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_fixed_income.py +0 -0
  33. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/cme_globex_fx.py +0 -0
  34. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/eurex_fixed_income.py +0 -0
  35. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/ice.py +0 -0
  36. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/iex.py +0 -0
  37. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/jpx.py +0 -0
  38. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/lse.py +0 -0
  39. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/nyse.py +0 -0
  40. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/ose.py +0 -0
  41. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/sifma.py +0 -0
  42. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/six.py +0 -0
  43. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/sse.py +0 -0
  44. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/tase.py +0 -0
  45. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/calendars/tsx.py +0 -0
  46. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/class_registry.py +0 -0
  47. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/__init__.py +0 -0
  48. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/cme.py +0 -0
  49. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/cme_globex.py +0 -0
  50. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/jp.py +0 -0
  51. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/nyse.py +0 -0
  52. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/oz.py +0 -0
  53. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/sifma.py +0 -0
  54. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/uk.py +0 -0
  55. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars/holidays/us.py +0 -0
  56. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars.egg-info/dependency_links.txt +0 -0
  57. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars.egg-info/requires.txt +0 -0
  58. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/pandas_market_calendars.egg-info/top_level.txt +0 -0
  59. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/setup.cfg +0 -0
  60. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_XNYS_calendar.py +0 -0
  61. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_asx_calendar.py +0 -0
  62. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_bmf_calendar.py +0 -0
  63. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_bse_calendar.py +0 -0
  64. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_cboe_calendars.py +0 -0
  65. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_class_registry.py +0 -0
  66. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_cme_bond_calendar.py +0 -0
  67. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_cme_equity_calendar.py +0 -0
  68. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_eurex_calendar.py +0 -0
  69. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_eurex_fixed_income_calendar.py +0 -0
  70. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_exchange_calendar_cme_globex_crypto.py +0 -0
  71. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_exchange_calendar_cme_globex_energy_and_metals.py +0 -0
  72. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_exchange_calendar_cme_globex_equities.py +0 -0
  73. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_exchange_calendar_cme_globex_fixed_income.py +0 -0
  74. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_exchange_calendar_cme_globex_fx.py +0 -0
  75. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_hkex_calendar.py +0 -0
  76. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_ice_calendar.py +0 -0
  77. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_iex_calendar.py +0 -0
  78. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_jpx_calendar.py +0 -0
  79. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_lse_calendar.py +0 -0
  80. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_market_calendar.py +0 -0
  81. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_nyse_calendar.py +0 -0
  82. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_nyse_calendar_early_years.py +0 -0
  83. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_ose_calendar.py +0 -0
  84. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_sifma_calendars.py +0 -0
  85. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_six_calendar.py +0 -0
  86. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_sse_calendar.py +0 -0
  87. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_tsx_calendar.py +0 -0
  88. {pandas_market_calendars-4.4.0 → pandas_market_calendars-4.4.1}/tests/test_utils.py +0 -0
@@ -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
@@ -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
@@ -51,6 +51,7 @@ pandas_market_calendars/holidays/oz.py
51
51
  pandas_market_calendars/holidays/sifma.py
52
52
  pandas_market_calendars/holidays/uk.py
53
53
  pandas_market_calendars/holidays/us.py
54
+ tests/test_24_7_calendar.py
54
55
  tests/test_XNYS_calendar.py
55
56
  tests/test_asx_calendar.py
56
57
  tests/test_bmf_calendar.py
@@ -67,6 +68,7 @@ tests/test_exchange_calendar_cme_globex_energy_and_metals.py
67
68
  tests/test_exchange_calendar_cme_globex_equities.py
68
69
  tests/test_exchange_calendar_cme_globex_fixed_income.py
69
70
  tests/test_exchange_calendar_cme_globex_fx.py
71
+ tests/test_exchange_calendar_cme_globex_grains.py
70
72
  tests/test_hkex_calendar.py
71
73
  tests/test_ice_calendar.py
72
74
  tests/test_iex_calendar.py
@@ -80,4 +82,5 @@ tests/test_sifma_calendars.py
80
82
  tests/test_six_calendar.py
81
83
  tests/test_sse_calendar.py
82
84
  tests/test_tsx_calendar.py
83
- tests/test_utils.py
85
+ tests/test_utils.py
86
+ tests/test_xtae_calendar.py
@@ -1,12 +1,12 @@
1
1
  [project]
2
2
  name = "pandas_market_calendars"
3
- version = "4.4.0"
3
+ version = "4.4.1"
4
4
  authors = [
5
5
  { name = "Ryan Sheftel", email = "rsheftel@alumni.upenn.edu" },
6
6
  ]
7
7
  description = "Market and exchange trading calendars for pandas"
8
8
  readme = "README.rst"
9
- requires-python = ">=3.9"
9
+ requires-python = ">=3.8"
10
10
  keywords = ["trading", "exchanges", "markets", "OTC", "datetime", "holiday", "business days"]
11
11
  license = { text = "MIT" }
12
12
  classifiers = [
@@ -0,0 +1,25 @@
1
+ import pandas as pd
2
+ from pandas.testing import assert_index_equal
3
+
4
+ import pandas_market_calendars as mcal
5
+
6
+
7
+ def test_weekends():
8
+ actual = mcal.get_calendar("24/7").schedule("2012-07-01", "2012-07-10").index
9
+
10
+ expected = pd.DatetimeIndex(
11
+ [
12
+ pd.Timestamp("2012-07-01"),
13
+ pd.Timestamp("2012-07-02"),
14
+ pd.Timestamp("2012-07-03"),
15
+ pd.Timestamp("2012-07-04"),
16
+ pd.Timestamp("2012-07-05"),
17
+ pd.Timestamp("2012-07-06"),
18
+ pd.Timestamp("2012-07-07"),
19
+ pd.Timestamp("2012-07-08"),
20
+ pd.Timestamp("2012-07-09"),
21
+ pd.Timestamp("2012-07-10"),
22
+ ]
23
+ )
24
+
25
+ assert_index_equal(actual, expected)
@@ -44,7 +44,6 @@ def test_dec_jan():
44
44
  cme = CMEAgricultureExchangeCalendar()
45
45
  schedule = cme.schedule("2020-12-30", "2021-01-10")
46
46
 
47
- print(schedule)
48
47
  assert schedule["market_open"].iloc[0] == pd.Timestamp(
49
48
  "2020-12-29 23:01:00", tz="UTC"
50
49
  )
@@ -0,0 +1,30 @@
1
+ import pandas as pd
2
+ import pytz
3
+ from pandas.testing import assert_index_equal
4
+
5
+ from pandas_market_calendars.calendars.cme_globex_agriculture import (
6
+ CMEGlobexGrainsAndOilseedsExchangeCalendar,
7
+ )
8
+
9
+ cal = CMEGlobexGrainsAndOilseedsExchangeCalendar()
10
+
11
+
12
+ def test_time_zone():
13
+ assert cal.tz == pytz.timezone("America/Chicago")
14
+ assert cal.name == "CMEGlobex_GrainsAndOilseeds"
15
+
16
+
17
+ def test_x():
18
+ schedule = cal.schedule("2023-01-01", "2023-01-10", tz="America/New_York")
19
+
20
+ good_dates = cal.valid_days("2023-01-01", "2023-12-31")
21
+
22
+ assert all(
23
+ d not in good_dates
24
+ for d in {"2023-01-01", "2023-12-24", "2023-12-25", "2023-12-30", "2023-12-31"}
25
+ )
26
+
27
+ assert all(
28
+ d in good_dates
29
+ for d in {"2023-01-03", "2023-01-05", "2023-12-26", "2023-12-27", "2023-12-28"}
30
+ )
@@ -0,0 +1,53 @@
1
+ import pandas as pd
2
+ from pandas.testing import assert_index_equal, assert_series_equal
3
+
4
+ import pandas_market_calendars as mcal
5
+
6
+
7
+ def test_xtae_schedule():
8
+ actual = mcal.get_calendar("XTAE").schedule("2012-07-01", "2012-07-10").index
9
+
10
+ expected = pd.DatetimeIndex(
11
+ [
12
+ pd.Timestamp("2012-07-01"),
13
+ pd.Timestamp("2012-07-02"),
14
+ pd.Timestamp("2012-07-03"),
15
+ pd.Timestamp("2012-07-04"),
16
+ pd.Timestamp("2012-07-05"),
17
+ pd.Timestamp("2012-07-08"),
18
+ pd.Timestamp("2012-07-09"),
19
+ pd.Timestamp("2012-07-10"),
20
+ ]
21
+ )
22
+
23
+ assert_index_equal(actual, expected)
24
+
25
+
26
+ def test_xtae_sunday_close():
27
+ actual = mcal.get_calendar("XTAE").schedule("2012-07-01", "2012-07-10")
28
+
29
+ expected = pd.Series(
30
+ index=[
31
+ pd.Timestamp("2012-07-01"),
32
+ pd.Timestamp("2012-07-02"),
33
+ pd.Timestamp("2012-07-03"),
34
+ pd.Timestamp("2012-07-04"),
35
+ pd.Timestamp("2012-07-05"),
36
+ pd.Timestamp("2012-07-08"),
37
+ pd.Timestamp("2012-07-09"),
38
+ pd.Timestamp("2012-07-10"),
39
+ ],
40
+ data=[
41
+ pd.Timestamp("2012-07-01 12:40:00+00:00"),
42
+ pd.Timestamp("2012-07-02 14:15:00+00:00"),
43
+ pd.Timestamp("2012-07-03 14:15:00+00:00"),
44
+ pd.Timestamp("2012-07-04 14:15:00+00:00"),
45
+ pd.Timestamp("2012-07-05 14:15:00+00:00"),
46
+ pd.Timestamp("2012-07-08 12:40:00+00:00"),
47
+ pd.Timestamp("2012-07-09 14:15:00+00:00"),
48
+ pd.Timestamp("2012-07-10 14:15:00+00:00"),
49
+ ],
50
+ name="market_close",
51
+ )
52
+
53
+ assert_series_equal(actual["market_close"], expected)