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,115 +1,145 @@
1
- from datetime import time
2
-
3
- from pandas.tseries.holiday import AbstractHolidayCalendar, \
4
- GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay, Holiday
5
- from pytz import timezone
6
- from itertools import chain
7
- import pandas as pd
8
-
9
- from pandas_market_calendars.holidays.us import (Christmas, USBlackFridayInOrAfter1993, USIndependenceDay, USMartinLutherKingJrAfter1998,
10
- USMemorialDay, USNewYearsDay, HurricaneSandyClosings, USNationalDaysofMourning,
11
- USJuneteenthAfter2022)
12
- from pandas_market_calendars.market_calendar import MarketCalendar
13
-
14
-
15
- def good_friday_unless_christmas_nye_friday(dt):
16
- """
17
- Good Friday is a valid trading day if Christmas Day or New Years Day fall
18
- on a Friday.
19
- """
20
- if isinstance(dt, pd.DatetimeIndex):
21
- # Pandas < 2.1.0 will call with an index and fall-back to element by element
22
- # Pandas == 2.1.0 will only call element by element
23
- raise NotImplementedError()
24
-
25
- year = dt.year
26
- christmas_weekday = Christmas.observance(pd.Timestamp(year=year, month=12, day=25)).weekday()
27
- nyd_weekday = USNewYearsDay.observance(pd.Timestamp(year=year, month=1, day=1)).weekday()
28
- if christmas_weekday != 4 and nyd_weekday != 4:
29
- return GoodFriday.dates(pd.Timestamp(year=year, month=1, day=1), pd.Timestamp(year=year, month=12, day=31))[0]
30
- else:
31
- # Not a holiday so use NaT to ensure it gets removed
32
- return pd.NaT
33
-
34
-
35
- GoodFridayUnlessChristmasNYEFriday = Holiday(
36
- name="Good Friday CFE",
37
- month=1,
38
- day=1,
39
- observance=good_friday_unless_christmas_nye_friday,
40
- )
41
-
42
-
43
- class CFEExchangeCalendar(MarketCalendar):
44
- """
45
- Exchange calendar for the CBOE Futures Exchange (CFE).
46
-
47
- http://cfe.cboe.com/aboutcfe/expirationcalendar.aspx
48
-
49
- Open Time: 8:30am, America/Chicago
50
- Close Time: 3:15pm, America/Chicago
51
-
52
- (We are ignoring extended trading hours for now)
53
- """
54
- aliases = ['CFE', "CBOE_Futures"]
55
- regular_market_times = {
56
- "market_open": ((None, time(8, 30)),),
57
- "market_close": ((None, time(15, 15)),)
58
- }
59
-
60
- @property
61
- def name(self):
62
- return "CFE"
63
-
64
- @property
65
- def tz(self):
66
- return timezone("America/Chicago")
67
-
68
- @property
69
- def regular_holidays(self):
70
- return AbstractHolidayCalendar(rules=[
71
- USNewYearsDay,
72
- USMartinLutherKingJrAfter1998,
73
- USPresidentsDay,
74
- GoodFridayUnlessChristmasNYEFriday,
75
- USJuneteenthAfter2022,
76
- USIndependenceDay,
77
- USMemorialDay,
78
- USLaborDay,
79
- USThanksgivingDay,
80
- Christmas
81
- ])
82
-
83
- @property
84
- def special_closes(self):
85
- return [(
86
- time(12, 15),
87
- AbstractHolidayCalendar(rules=[
88
- USBlackFridayInOrAfter1993,
89
- ])
90
- )]
91
-
92
- @property
93
- def adhoc_holidays(self):
94
- return list(chain(
95
- HurricaneSandyClosings,
96
- USNationalDaysofMourning,
97
- ))
98
-
99
-
100
- class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
101
- name = "CBOE_Equity_Options"
102
- aliases = [name]
103
- regular_market_times = {
104
- "market_open": ((None, time(8, 30)),),
105
- "market_close": ((None, time(15)),)
106
- }
107
-
108
-
109
- class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
110
- name = "CBOE_Index_Options"
111
- aliases = [name]
112
- regular_market_times = {
113
- "market_open": ((None, time(8, 30)),),
114
- "market_close": ((None, time(15, 15)),)
115
- }
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
+ GoodFriday,
8
+ USLaborDay,
9
+ USPresidentsDay,
10
+ USThanksgivingDay,
11
+ Holiday,
12
+ )
13
+ from pytz import timezone
14
+
15
+ from pandas_market_calendars.holidays.us import (
16
+ Christmas,
17
+ USBlackFridayInOrAfter1993,
18
+ USIndependenceDay,
19
+ USMartinLutherKingJrAfter1998,
20
+ USMemorialDay,
21
+ USNewYearsDay,
22
+ HurricaneSandyClosings,
23
+ USNationalDaysofMourning,
24
+ USJuneteenthAfter2022,
25
+ )
26
+ from pandas_market_calendars.market_calendar import MarketCalendar
27
+
28
+
29
+ def good_friday_unless_christmas_nye_friday(dt):
30
+ """
31
+ Good Friday is a valid trading day if Christmas Day or New Years Day fall
32
+ on a Friday.
33
+ """
34
+ if isinstance(dt, pd.DatetimeIndex):
35
+ # Pandas < 2.1.0 will call with an index and fall-back to element by element
36
+ # Pandas == 2.1.0 will only call element by element
37
+ raise NotImplementedError()
38
+
39
+ year = dt.year
40
+ christmas_weekday = Christmas.observance(
41
+ pd.Timestamp(year=year, month=12, day=25)
42
+ ).weekday()
43
+ nyd_weekday = USNewYearsDay.observance(
44
+ pd.Timestamp(year=year, month=1, day=1)
45
+ ).weekday()
46
+ if christmas_weekday != 4 and nyd_weekday != 4:
47
+ return GoodFriday.dates(
48
+ pd.Timestamp(year=year, month=1, day=1),
49
+ pd.Timestamp(year=year, month=12, day=31),
50
+ )[0]
51
+ else:
52
+ # Not a holiday so use NaT to ensure it gets removed
53
+ return pd.NaT
54
+
55
+
56
+ GoodFridayUnlessChristmasNYEFriday = Holiday(
57
+ name="Good Friday CFE",
58
+ month=1,
59
+ day=1,
60
+ observance=good_friday_unless_christmas_nye_friday,
61
+ )
62
+
63
+
64
+ class CFEExchangeCalendar(MarketCalendar):
65
+ """
66
+ Exchange calendar for the CBOE Futures Exchange (CFE).
67
+
68
+ http://cfe.cboe.com/aboutcfe/expirationcalendar.aspx
69
+
70
+ Open Time: 8:30am, America/Chicago
71
+ Close Time: 3:15pm, America/Chicago
72
+
73
+ (We are ignoring extended trading hours for now)
74
+ """
75
+
76
+ aliases = ["CFE", "CBOE_Futures"]
77
+ regular_market_times = {
78
+ "market_open": ((None, time(8, 30)),),
79
+ "market_close": ((None, time(15, 15)),),
80
+ }
81
+
82
+ @property
83
+ def name(self):
84
+ return "CFE"
85
+
86
+ @property
87
+ def tz(self):
88
+ return timezone("America/Chicago")
89
+
90
+ @property
91
+ def regular_holidays(self):
92
+ return AbstractHolidayCalendar(
93
+ rules=[
94
+ USNewYearsDay,
95
+ USMartinLutherKingJrAfter1998,
96
+ USPresidentsDay,
97
+ GoodFridayUnlessChristmasNYEFriday,
98
+ USJuneteenthAfter2022,
99
+ USIndependenceDay,
100
+ USMemorialDay,
101
+ USLaborDay,
102
+ USThanksgivingDay,
103
+ Christmas,
104
+ ]
105
+ )
106
+
107
+ @property
108
+ def special_closes(self):
109
+ return [
110
+ (
111
+ time(12, 15),
112
+ AbstractHolidayCalendar(
113
+ rules=[
114
+ USBlackFridayInOrAfter1993,
115
+ ]
116
+ ),
117
+ )
118
+ ]
119
+
120
+ @property
121
+ def adhoc_holidays(self):
122
+ return list(
123
+ chain(
124
+ HurricaneSandyClosings,
125
+ USNationalDaysofMourning,
126
+ )
127
+ )
128
+
129
+
130
+ class CBOEEquityOptionsExchangeCalendar(CFEExchangeCalendar):
131
+ name = "CBOE_Equity_Options"
132
+ aliases = [name]
133
+ regular_market_times = {
134
+ "market_open": ((None, time(8, 30)),),
135
+ "market_close": ((None, time(15)),),
136
+ }
137
+
138
+
139
+ class CBOEIndexOptionsExchangeCalendar(CFEExchangeCalendar):
140
+ name = "CBOE_Index_Options"
141
+ aliases = [name]
142
+ regular_market_times = {
143
+ "market_open": ((None, time(8, 30)),),
144
+ "market_close": ((None, time(15, 15)),),
145
+ }