pandas-market-calendars 4.3.2__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 (46) hide show
  1. pandas_market_calendars/__init__.py +38 -38
  2. pandas_market_calendars/calendar_registry.py +53 -52
  3. pandas_market_calendars/calendar_utils.py +261 -261
  4. pandas_market_calendars/calendars/asx.py +66 -66
  5. pandas_market_calendars/calendars/bmf.py +206 -206
  6. pandas_market_calendars/calendars/bse.py +407 -407
  7. pandas_market_calendars/calendars/cboe.py +145 -145
  8. pandas_market_calendars/calendars/cme.py +402 -402
  9. pandas_market_calendars/calendars/cme_globex_agriculture.py +126 -127
  10. pandas_market_calendars/calendars/cme_globex_base.py +119 -119
  11. pandas_market_calendars/calendars/cme_globex_crypto.py +160 -147
  12. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -216
  13. pandas_market_calendars/calendars/cme_globex_equities.py +123 -121
  14. pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -134
  15. pandas_market_calendars/calendars/cme_globex_fx.py +101 -92
  16. pandas_market_calendars/calendars/eurex.py +139 -139
  17. pandas_market_calendars/calendars/eurex_fixed_income.py +98 -0
  18. pandas_market_calendars/calendars/hkex.py +426 -426
  19. pandas_market_calendars/calendars/ice.py +81 -81
  20. pandas_market_calendars/calendars/iex.py +112 -111
  21. pandas_market_calendars/calendars/jpx.py +109 -109
  22. pandas_market_calendars/calendars/lse.py +114 -114
  23. pandas_market_calendars/calendars/mirror.py +130 -129
  24. pandas_market_calendars/calendars/nyse.py +1324 -1324
  25. pandas_market_calendars/calendars/ose.py +116 -116
  26. pandas_market_calendars/calendars/sifma.py +350 -335
  27. pandas_market_calendars/calendars/six.py +132 -132
  28. pandas_market_calendars/calendars/sse.py +311 -311
  29. pandas_market_calendars/calendars/tase.py +197 -195
  30. pandas_market_calendars/calendars/tsx.py +181 -181
  31. pandas_market_calendars/holidays/cme.py +385 -372
  32. pandas_market_calendars/holidays/cme_globex.py +214 -223
  33. pandas_market_calendars/holidays/cn.py +1455 -1455
  34. pandas_market_calendars/holidays/jp.py +398 -394
  35. pandas_market_calendars/holidays/nyse.py +1531 -1539
  36. pandas_market_calendars/holidays/oz.py +63 -65
  37. pandas_market_calendars/holidays/sifma.py +338 -350
  38. pandas_market_calendars/holidays/us.py +376 -377
  39. pandas_market_calendars/market_calendar.py +895 -895
  40. {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/METADATA +3 -3
  41. pandas_market_calendars-4.3.3.dist-info/RECORD +50 -0
  42. pandas_market_calendars-4.3.2.dist-info/RECORD +0 -49
  43. {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/LICENSE +0 -0
  44. {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/NOTICE +0 -0
  45. {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/WHEEL +0 -0
  46. {pandas_market_calendars-4.3.2.dist-info → pandas_market_calendars-4.3.3.dist-info}/top_level.txt +0 -0
@@ -1,311 +1,311 @@
1
- from datetime import time, timedelta
2
- from functools import partial
3
-
4
- from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, next_monday
5
- from pytz import timezone
6
-
7
- from pandas_market_calendars.holidays.cn import *
8
- from pandas_market_calendars.market_calendar import MarketCalendar
9
-
10
-
11
- class SSEExchangeCalendar(MarketCalendar):
12
- """
13
- Exchange calendar for Shanghai Stock Exchange
14
-
15
- Open Time: 9:30 AM, Asia/Shanghai
16
- LUNCH BREAK :facepalm: : 11:30 AM - 1:00 PM Asia/Shanghai
17
- Close Time: 3:00 PM, Asia/Shanghai
18
- """
19
-
20
- aliases = ["SSE"]
21
- regular_market_times = {
22
- "market_open": ((None, time(9, 30)),),
23
- "market_close": ((None, time(15)),),
24
- "break_start": ((None, time(11, 30)),),
25
- "break_end": ((None, time(13)),),
26
- }
27
-
28
- @property
29
- def name(self):
30
- return "SSE"
31
-
32
- @property
33
- def tz(self):
34
- return timezone("Asia/Shanghai")
35
-
36
- @property
37
- def regular_holidays(self):
38
- """
39
- Rules are guesses based on observations of recent year.
40
- Rectify accordingly once the next year's holidays arrangement is published by the government.
41
- """
42
- # Since all past holidays are adhoc, start_year should always be a year in the future.
43
- # For example: Holiday arrangements for 2022 are now included,
44
- # then our guesswork starts from the next year so start_year = 2023
45
- start_year = 2024
46
-
47
- return AbstractHolidayCalendar(
48
- rules=[
49
- Holiday(
50
- name="New Year's Day",
51
- month=1,
52
- day=1,
53
- observance=next_monday,
54
- start_date=Timestamp(start_year, 1, 1),
55
- ),
56
- Holiday(
57
- name="New Year's Day",
58
- month=1,
59
- day=2,
60
- observance=partial(second_day_in_lieu),
61
- start_date=Timestamp(start_year, 1, 2),
62
- ),
63
- Holiday(
64
- name="New Year's Day",
65
- month=1,
66
- day=3,
67
- observance=partial(third_day_in_lieu),
68
- start_date=Timestamp(start_year, 1, 3),
69
- ),
70
- Holiday(
71
- name="Spring Festival",
72
- month=1,
73
- day=20,
74
- observance=partial(lunisolar, mapping=sf_mapping, delta=-1),
75
- start_date=Timestamp(start_year, 1, 20),
76
- ),
77
- Holiday(
78
- name="Spring Festival",
79
- month=1,
80
- day=21,
81
- observance=partial(lunisolar, mapping=sf_mapping, delta=0),
82
- start_date=Timestamp(start_year, 1, 21),
83
- ),
84
- Holiday(
85
- name="Spring Festival",
86
- month=1,
87
- day=21,
88
- observance=partial(lunisolar, mapping=sf_mapping, delta=1),
89
- start_date=Timestamp(start_year, 1, 22),
90
- ),
91
- Holiday(
92
- name="Spring Festival",
93
- month=1,
94
- day=21,
95
- observance=partial(lunisolar, mapping=sf_mapping, delta=2),
96
- start_date=Timestamp(start_year, 1, 23),
97
- ),
98
- Holiday(
99
- name="Spring Festival",
100
- month=1,
101
- day=21,
102
- observance=partial(lunisolar, mapping=sf_mapping, delta=3),
103
- start_date=Timestamp(start_year, 1, 24),
104
- ),
105
- Holiday(
106
- name="Spring Festival",
107
- month=1,
108
- day=21,
109
- observance=partial(lunisolar, mapping=sf_mapping, delta=4),
110
- start_date=Timestamp(start_year, 1, 25),
111
- ),
112
- Holiday(
113
- name="Spring Festival",
114
- month=1,
115
- day=21,
116
- observance=partial(lunisolar, mapping=sf_mapping, delta=5),
117
- start_date=Timestamp(start_year, 1, 26),
118
- ),
119
- Holiday(
120
- name="Labour Day",
121
- month=5,
122
- day=1,
123
- observance=next_monday,
124
- start_date=Timestamp(start_year, 5, 1),
125
- ),
126
- Holiday(
127
- name="Labour Day",
128
- month=5,
129
- day=2,
130
- observance=second_day_in_lieu,
131
- start_date=Timestamp(start_year, 5, 2),
132
- ),
133
- Holiday(
134
- name="Labour Day",
135
- month=5,
136
- day=3,
137
- observance=third_day_in_lieu,
138
- start_date=Timestamp(start_year, 5, 3),
139
- ),
140
- Holiday(
141
- name="Tomb-sweeping Day",
142
- month=4,
143
- day=4,
144
- observance=partial(
145
- lunisolar, mapping=tsd_mapping, func=next_monday
146
- ),
147
- start_date=Timestamp(start_year, 4, 4),
148
- ),
149
- Holiday(
150
- name="Tomb-sweeping Day",
151
- month=4,
152
- day=5,
153
- observance=partial(
154
- lunisolar, mapping=tsd_mapping, func=second_day_in_lieu, delta=1
155
- ),
156
- start_date=Timestamp(start_year, 4, 4),
157
- ),
158
- Holiday(
159
- name="Tomb-sweeping Day",
160
- month=4,
161
- day=6,
162
- observance=partial(
163
- lunisolar, mapping=tsd_mapping, func=third_day_in_lieu, delta=2
164
- ),
165
- start_date=Timestamp(start_year, 4, 4),
166
- ),
167
- Holiday(
168
- name="Dragon Boat Festival",
169
- month=5,
170
- day=27,
171
- observance=partial(
172
- lunisolar, mapping=dbf_mapping, func=next_monday
173
- ),
174
- start_date=Timestamp(start_year, 5, 27),
175
- ),
176
- Holiday(
177
- name="Dragon Boat Festival",
178
- month=5,
179
- day=28,
180
- observance=partial(
181
- lunisolar, mapping=dbf_mapping, func=second_day_in_lieu, delta=1
182
- ),
183
- start_date=Timestamp(start_year, 5, 27),
184
- ),
185
- Holiday(
186
- name="Dragon Boat Festival",
187
- month=5,
188
- day=29,
189
- observance=partial(
190
- lunisolar, mapping=dbf_mapping, func=third_day_in_lieu, delta=2
191
- ),
192
- start_date=Timestamp(start_year, 5, 27),
193
- ),
194
- Holiday(
195
- name="Mid-autumn Festival",
196
- month=9,
197
- day=7,
198
- observance=partial(
199
- lunisolar, mapping=maf_mapping, func=next_monday
200
- ),
201
- start_date=Timestamp(start_year, 9, 7),
202
- ),
203
- Holiday(
204
- name="Mid-autumn Festival",
205
- month=9,
206
- day=8,
207
- observance=partial(
208
- lunisolar, mapping=maf_mapping, func=second_day_in_lieu, delta=1
209
- ),
210
- start_date=Timestamp(start_year, 9, 7),
211
- ),
212
- Holiday(
213
- name="Mid-autumn Festival",
214
- month=9,
215
- day=9,
216
- observance=partial(
217
- lunisolar, mapping=maf_mapping, func=third_day_in_lieu, delta=2
218
- ),
219
- start_date=Timestamp(start_year, 9, 7),
220
- ),
221
- Holiday(
222
- name="National Day",
223
- month=10,
224
- day=1,
225
- start_date=Timestamp(start_year, 10, 1),
226
- ),
227
- Holiday(
228
- name="National Day",
229
- month=10,
230
- day=2,
231
- start_date=Timestamp(start_year, 10, 2),
232
- ),
233
- Holiday(
234
- name="National Day",
235
- month=10,
236
- day=3,
237
- start_date=Timestamp(start_year, 10, 3),
238
- ),
239
- Holiday(
240
- name="National Day",
241
- month=10,
242
- day=4,
243
- start_date=Timestamp(start_year, 10, 4),
244
- ),
245
- Holiday(
246
- name="National Day",
247
- month=10,
248
- day=5,
249
- start_date=Timestamp(start_year, 10, 5),
250
- ),
251
- Holiday(
252
- name="National Day",
253
- month=10,
254
- day=6,
255
- start_date=Timestamp(start_year, 10, 6),
256
- ),
257
- Holiday(
258
- name="National Day",
259
- month=10,
260
- day=7,
261
- start_date=Timestamp(start_year, 10, 7),
262
- ),
263
- ]
264
- )
265
-
266
- @property
267
- def adhoc_holidays(self):
268
- return all_holidays
269
-
270
-
271
- def second_day_in_lieu(dt):
272
- dow = dt.weekday()
273
- if dow == 0: # Holiday is Sunday, use Saturday
274
- return dt - timedelta(2)
275
- elif dow == 1: # Holiday is Monday, use Saturday
276
- return dt - timedelta(3)
277
- elif dow == 2: # Holiday is Tuesday, use Sunday
278
- return dt - timedelta(3)
279
- elif dow == 3: # Holiday is Wednesday, use Saturday
280
- return dt - timedelta(5)
281
-
282
- return dt
283
-
284
-
285
- def third_day_in_lieu(dt):
286
- dow = dt.weekday()
287
- if dow == 0: # Holiday is Saturday, use Sunday
288
- return dt - timedelta(1)
289
- elif dow == 1: # Holiday is Sunday, use Sunday
290
- return dt - timedelta(2)
291
- elif dow == 2: # Holiday is Monday, use Sunday
292
- return dt - timedelta(3)
293
- elif dow == 3: # Holiday is Tuesday, use Monday
294
- return dt - timedelta(3)
295
- elif dow == 4: # Holiday is Wednesday, use Sunday
296
- return dt - timedelta(5)
297
-
298
- return dt
299
-
300
-
301
- def lunisolar(dt, mapping, func=None, delta=None):
302
- if mapping and (dt.year in mapping):
303
- new_dt = mapping[dt.year]
304
- else:
305
- new_dt = dt
306
- if delta:
307
- new_dt = new_dt + timedelta(delta)
308
- if func:
309
- return func(new_dt)
310
- else:
311
- return new_dt
1
+ from datetime import time, timedelta
2
+ from functools import partial
3
+
4
+ from pandas.tseries.holiday import AbstractHolidayCalendar, Holiday, next_monday
5
+ from pytz import timezone
6
+
7
+ from pandas_market_calendars.holidays.cn import *
8
+ from pandas_market_calendars.market_calendar import MarketCalendar
9
+
10
+
11
+ class SSEExchangeCalendar(MarketCalendar):
12
+ """
13
+ Exchange calendar for Shanghai Stock Exchange
14
+
15
+ Open Time: 9:30 AM, Asia/Shanghai
16
+ LUNCH BREAK :facepalm: : 11:30 AM - 1:00 PM Asia/Shanghai
17
+ Close Time: 3:00 PM, Asia/Shanghai
18
+ """
19
+
20
+ aliases = ["SSE"]
21
+ regular_market_times = {
22
+ "market_open": ((None, time(9, 30)),),
23
+ "market_close": ((None, time(15)),),
24
+ "break_start": ((None, time(11, 30)),),
25
+ "break_end": ((None, time(13)),),
26
+ }
27
+
28
+ @property
29
+ def name(self):
30
+ return "SSE"
31
+
32
+ @property
33
+ def tz(self):
34
+ return timezone("Asia/Shanghai")
35
+
36
+ @property
37
+ def regular_holidays(self):
38
+ """
39
+ Rules are guesses based on observations of recent year.
40
+ Rectify accordingly once the next year's holidays arrangement is published by the government.
41
+ """
42
+ # Since all past holidays are adhoc, start_year should always be a year in the future.
43
+ # For example: Holiday arrangements for 2022 are now included,
44
+ # then our guesswork starts from the next year so start_year = 2023
45
+ start_year = 2024
46
+
47
+ return AbstractHolidayCalendar(
48
+ rules=[
49
+ Holiday(
50
+ name="New Year's Day",
51
+ month=1,
52
+ day=1,
53
+ observance=next_monday,
54
+ start_date=Timestamp(start_year, 1, 1),
55
+ ),
56
+ Holiday(
57
+ name="New Year's Day",
58
+ month=1,
59
+ day=2,
60
+ observance=partial(second_day_in_lieu),
61
+ start_date=Timestamp(start_year, 1, 2),
62
+ ),
63
+ Holiday(
64
+ name="New Year's Day",
65
+ month=1,
66
+ day=3,
67
+ observance=partial(third_day_in_lieu),
68
+ start_date=Timestamp(start_year, 1, 3),
69
+ ),
70
+ Holiday(
71
+ name="Spring Festival",
72
+ month=1,
73
+ day=20,
74
+ observance=partial(lunisolar, mapping=sf_mapping, delta=-1),
75
+ start_date=Timestamp(start_year, 1, 20),
76
+ ),
77
+ Holiday(
78
+ name="Spring Festival",
79
+ month=1,
80
+ day=21,
81
+ observance=partial(lunisolar, mapping=sf_mapping, delta=0),
82
+ start_date=Timestamp(start_year, 1, 21),
83
+ ),
84
+ Holiday(
85
+ name="Spring Festival",
86
+ month=1,
87
+ day=21,
88
+ observance=partial(lunisolar, mapping=sf_mapping, delta=1),
89
+ start_date=Timestamp(start_year, 1, 22),
90
+ ),
91
+ Holiday(
92
+ name="Spring Festival",
93
+ month=1,
94
+ day=21,
95
+ observance=partial(lunisolar, mapping=sf_mapping, delta=2),
96
+ start_date=Timestamp(start_year, 1, 23),
97
+ ),
98
+ Holiday(
99
+ name="Spring Festival",
100
+ month=1,
101
+ day=21,
102
+ observance=partial(lunisolar, mapping=sf_mapping, delta=3),
103
+ start_date=Timestamp(start_year, 1, 24),
104
+ ),
105
+ Holiday(
106
+ name="Spring Festival",
107
+ month=1,
108
+ day=21,
109
+ observance=partial(lunisolar, mapping=sf_mapping, delta=4),
110
+ start_date=Timestamp(start_year, 1, 25),
111
+ ),
112
+ Holiday(
113
+ name="Spring Festival",
114
+ month=1,
115
+ day=21,
116
+ observance=partial(lunisolar, mapping=sf_mapping, delta=5),
117
+ start_date=Timestamp(start_year, 1, 26),
118
+ ),
119
+ Holiday(
120
+ name="Labour Day",
121
+ month=5,
122
+ day=1,
123
+ observance=next_monday,
124
+ start_date=Timestamp(start_year, 5, 1),
125
+ ),
126
+ Holiday(
127
+ name="Labour Day",
128
+ month=5,
129
+ day=2,
130
+ observance=second_day_in_lieu,
131
+ start_date=Timestamp(start_year, 5, 2),
132
+ ),
133
+ Holiday(
134
+ name="Labour Day",
135
+ month=5,
136
+ day=3,
137
+ observance=third_day_in_lieu,
138
+ start_date=Timestamp(start_year, 5, 3),
139
+ ),
140
+ Holiday(
141
+ name="Tomb-sweeping Day",
142
+ month=4,
143
+ day=4,
144
+ observance=partial(
145
+ lunisolar, mapping=tsd_mapping, func=next_monday
146
+ ),
147
+ start_date=Timestamp(start_year, 4, 4),
148
+ ),
149
+ Holiday(
150
+ name="Tomb-sweeping Day",
151
+ month=4,
152
+ day=5,
153
+ observance=partial(
154
+ lunisolar, mapping=tsd_mapping, func=second_day_in_lieu, delta=1
155
+ ),
156
+ start_date=Timestamp(start_year, 4, 4),
157
+ ),
158
+ Holiday(
159
+ name="Tomb-sweeping Day",
160
+ month=4,
161
+ day=6,
162
+ observance=partial(
163
+ lunisolar, mapping=tsd_mapping, func=third_day_in_lieu, delta=2
164
+ ),
165
+ start_date=Timestamp(start_year, 4, 4),
166
+ ),
167
+ Holiday(
168
+ name="Dragon Boat Festival",
169
+ month=5,
170
+ day=27,
171
+ observance=partial(
172
+ lunisolar, mapping=dbf_mapping, func=next_monday
173
+ ),
174
+ start_date=Timestamp(start_year, 5, 27),
175
+ ),
176
+ Holiday(
177
+ name="Dragon Boat Festival",
178
+ month=5,
179
+ day=28,
180
+ observance=partial(
181
+ lunisolar, mapping=dbf_mapping, func=second_day_in_lieu, delta=1
182
+ ),
183
+ start_date=Timestamp(start_year, 5, 27),
184
+ ),
185
+ Holiday(
186
+ name="Dragon Boat Festival",
187
+ month=5,
188
+ day=29,
189
+ observance=partial(
190
+ lunisolar, mapping=dbf_mapping, func=third_day_in_lieu, delta=2
191
+ ),
192
+ start_date=Timestamp(start_year, 5, 27),
193
+ ),
194
+ Holiday(
195
+ name="Mid-autumn Festival",
196
+ month=9,
197
+ day=7,
198
+ observance=partial(
199
+ lunisolar, mapping=maf_mapping, func=next_monday
200
+ ),
201
+ start_date=Timestamp(start_year, 9, 7),
202
+ ),
203
+ Holiday(
204
+ name="Mid-autumn Festival",
205
+ month=9,
206
+ day=8,
207
+ observance=partial(
208
+ lunisolar, mapping=maf_mapping, func=second_day_in_lieu, delta=1
209
+ ),
210
+ start_date=Timestamp(start_year, 9, 7),
211
+ ),
212
+ Holiday(
213
+ name="Mid-autumn Festival",
214
+ month=9,
215
+ day=9,
216
+ observance=partial(
217
+ lunisolar, mapping=maf_mapping, func=third_day_in_lieu, delta=2
218
+ ),
219
+ start_date=Timestamp(start_year, 9, 7),
220
+ ),
221
+ Holiday(
222
+ name="National Day",
223
+ month=10,
224
+ day=1,
225
+ start_date=Timestamp(start_year, 10, 1),
226
+ ),
227
+ Holiday(
228
+ name="National Day",
229
+ month=10,
230
+ day=2,
231
+ start_date=Timestamp(start_year, 10, 2),
232
+ ),
233
+ Holiday(
234
+ name="National Day",
235
+ month=10,
236
+ day=3,
237
+ start_date=Timestamp(start_year, 10, 3),
238
+ ),
239
+ Holiday(
240
+ name="National Day",
241
+ month=10,
242
+ day=4,
243
+ start_date=Timestamp(start_year, 10, 4),
244
+ ),
245
+ Holiday(
246
+ name="National Day",
247
+ month=10,
248
+ day=5,
249
+ start_date=Timestamp(start_year, 10, 5),
250
+ ),
251
+ Holiday(
252
+ name="National Day",
253
+ month=10,
254
+ day=6,
255
+ start_date=Timestamp(start_year, 10, 6),
256
+ ),
257
+ Holiday(
258
+ name="National Day",
259
+ month=10,
260
+ day=7,
261
+ start_date=Timestamp(start_year, 10, 7),
262
+ ),
263
+ ]
264
+ )
265
+
266
+ @property
267
+ def adhoc_holidays(self):
268
+ return all_holidays
269
+
270
+
271
+ def second_day_in_lieu(dt):
272
+ dow = dt.weekday()
273
+ if dow == 0: # Holiday is Sunday, use Saturday
274
+ return dt - timedelta(2)
275
+ elif dow == 1: # Holiday is Monday, use Saturday
276
+ return dt - timedelta(3)
277
+ elif dow == 2: # Holiday is Tuesday, use Sunday
278
+ return dt - timedelta(3)
279
+ elif dow == 3: # Holiday is Wednesday, use Saturday
280
+ return dt - timedelta(5)
281
+
282
+ return dt
283
+
284
+
285
+ def third_day_in_lieu(dt):
286
+ dow = dt.weekday()
287
+ if dow == 0: # Holiday is Saturday, use Sunday
288
+ return dt - timedelta(1)
289
+ elif dow == 1: # Holiday is Sunday, use Sunday
290
+ return dt - timedelta(2)
291
+ elif dow == 2: # Holiday is Monday, use Sunday
292
+ return dt - timedelta(3)
293
+ elif dow == 3: # Holiday is Tuesday, use Monday
294
+ return dt - timedelta(3)
295
+ elif dow == 4: # Holiday is Wednesday, use Sunday
296
+ return dt - timedelta(5)
297
+
298
+ return dt
299
+
300
+
301
+ def lunisolar(dt, mapping, func=None, delta=None):
302
+ if mapping and (dt.year in mapping):
303
+ new_dt = mapping[dt.year]
304
+ else:
305
+ new_dt = dt
306
+ if delta:
307
+ new_dt = new_dt + timedelta(delta)
308
+ if func:
309
+ return func(new_dt)
310
+ else:
311
+ return new_dt