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.
- pandas_market_calendars/__init__.py +38 -37
- pandas_market_calendars/calendar_registry.py +53 -48
- pandas_market_calendars/calendar_utils.py +261 -225
- pandas_market_calendars/calendars/asx.py +66 -63
- pandas_market_calendars/calendars/bmf.py +206 -227
- pandas_market_calendars/calendars/bse.py +407 -409
- pandas_market_calendars/calendars/cboe.py +145 -115
- pandas_market_calendars/calendars/cme.py +402 -240
- pandas_market_calendars/calendars/cme_globex_agriculture.py +126 -103
- pandas_market_calendars/calendars/cme_globex_base.py +119 -103
- pandas_market_calendars/calendars/cme_globex_crypto.py +160 -147
- pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +216 -138
- pandas_market_calendars/calendars/cme_globex_equities.py +123 -104
- pandas_market_calendars/calendars/cme_globex_fixed_income.py +136 -113
- pandas_market_calendars/calendars/cme_globex_fx.py +101 -78
- pandas_market_calendars/calendars/eurex.py +139 -119
- pandas_market_calendars/calendars/eurex_fixed_income.py +98 -0
- pandas_market_calendars/calendars/hkex.py +426 -408
- pandas_market_calendars/calendars/ice.py +81 -65
- pandas_market_calendars/calendars/iex.py +112 -98
- pandas_market_calendars/calendars/jpx.py +109 -103
- pandas_market_calendars/calendars/lse.py +114 -91
- pandas_market_calendars/calendars/mirror.py +130 -114
- pandas_market_calendars/calendars/nyse.py +1324 -1127
- pandas_market_calendars/calendars/ose.py +116 -150
- pandas_market_calendars/calendars/sifma.py +350 -297
- pandas_market_calendars/calendars/six.py +132 -114
- pandas_market_calendars/calendars/sse.py +311 -290
- pandas_market_calendars/calendars/tase.py +197 -195
- pandas_market_calendars/calendars/tsx.py +181 -159
- pandas_market_calendars/class_registry.py +22 -16
- pandas_market_calendars/holidays/cme.py +385 -340
- pandas_market_calendars/holidays/cme_globex.py +214 -198
- pandas_market_calendars/holidays/cn.py +1455 -1436
- pandas_market_calendars/holidays/jp.py +398 -396
- pandas_market_calendars/holidays/jpx_equinox.py +453 -95
- pandas_market_calendars/holidays/nyse.py +1531 -1472
- pandas_market_calendars/holidays/oz.py +63 -65
- pandas_market_calendars/holidays/sifma.py +338 -321
- pandas_market_calendars/holidays/uk.py +32 -26
- pandas_market_calendars/holidays/us.py +376 -360
- pandas_market_calendars/market_calendar.py +895 -789
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/METADATA +7 -5
- pandas_market_calendars-4.3.3.dist-info/RECORD +50 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/WHEEL +1 -1
- pandas_market_calendars-4.3.1.dist-info/RECORD +0 -49
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/LICENSE +0 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/NOTICE +0 -0
- {pandas_market_calendars-4.3.1.dist-info → pandas_market_calendars-4.3.3.dist-info}/top_level.txt +0 -0
@@ -1,408 +1,426 @@
|
|
1
|
-
from datetime import time, timedelta
|
2
|
-
from functools import partial
|
3
|
-
|
4
|
-
from pandas import DateOffset, Timestamp
|
5
|
-
from pandas.tseries.holiday import
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
if
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
)
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
)
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
)
|
230
|
-
|
231
|
-
|
232
|
-
name="
|
233
|
-
month=
|
234
|
-
day=
|
235
|
-
observance=
|
236
|
-
start_date=Timestamp(
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
Timestamp(
|
263
|
-
Timestamp(
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
Timestamp(
|
272
|
-
Timestamp(
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
Timestamp(
|
278
|
-
Timestamp(
|
279
|
-
Timestamp(
|
280
|
-
Timestamp(
|
281
|
-
Timestamp(
|
282
|
-
Timestamp(
|
283
|
-
Timestamp(
|
284
|
-
Timestamp(
|
285
|
-
Timestamp(
|
286
|
-
Timestamp(
|
287
|
-
Timestamp(
|
288
|
-
Timestamp(
|
289
|
-
Timestamp(
|
290
|
-
Timestamp(
|
291
|
-
Timestamp(
|
292
|
-
Timestamp(
|
293
|
-
Timestamp(
|
294
|
-
Timestamp(
|
295
|
-
Timestamp(
|
296
|
-
Timestamp(
|
297
|
-
Timestamp(
|
298
|
-
Timestamp(
|
299
|
-
Timestamp(
|
300
|
-
Timestamp(
|
301
|
-
Timestamp(
|
302
|
-
Timestamp(
|
303
|
-
Timestamp(
|
304
|
-
|
305
|
-
Timestamp(
|
306
|
-
Timestamp(
|
307
|
-
|
308
|
-
Timestamp(
|
309
|
-
Timestamp(
|
310
|
-
Timestamp(
|
311
|
-
Timestamp(
|
312
|
-
Timestamp(
|
313
|
-
Timestamp(
|
314
|
-
Timestamp(
|
315
|
-
Timestamp(
|
316
|
-
Timestamp(
|
317
|
-
Timestamp(
|
318
|
-
Timestamp(
|
319
|
-
Timestamp(
|
320
|
-
Timestamp('
|
321
|
-
|
322
|
-
Timestamp(
|
323
|
-
Timestamp('
|
324
|
-
|
325
|
-
Timestamp(
|
326
|
-
Timestamp(
|
327
|
-
|
328
|
-
Timestamp(
|
329
|
-
|
330
|
-
Timestamp(
|
331
|
-
|
332
|
-
|
333
|
-
Timestamp(
|
334
|
-
|
335
|
-
Timestamp(
|
336
|
-
|
337
|
-
Timestamp(
|
338
|
-
Timestamp(
|
339
|
-
|
340
|
-
Timestamp(
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
"""
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
""
|
372
|
-
|
373
|
-
|
374
|
-
""
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
1
|
+
from datetime import time, timedelta
|
2
|
+
from functools import partial
|
3
|
+
|
4
|
+
from pandas import DateOffset, Timestamp
|
5
|
+
from pandas.tseries.holiday import (
|
6
|
+
AbstractHolidayCalendar,
|
7
|
+
EasterMonday,
|
8
|
+
GoodFriday,
|
9
|
+
Holiday,
|
10
|
+
sunday_to_monday,
|
11
|
+
)
|
12
|
+
from pandas.tseries.offsets import LastWeekOfMonth, WeekOfMonth
|
13
|
+
from pytz import timezone
|
14
|
+
|
15
|
+
from pandas_market_calendars.holidays.cn import (
|
16
|
+
bsd_mapping,
|
17
|
+
dbf_mapping,
|
18
|
+
dnf_mapping,
|
19
|
+
maf_mapping,
|
20
|
+
sf_mapping,
|
21
|
+
tsd_mapping,
|
22
|
+
)
|
23
|
+
from pandas_market_calendars.holidays.us import USNewYearsDay
|
24
|
+
from pandas_market_calendars.market_calendar import MarketCalendar
|
25
|
+
|
26
|
+
|
27
|
+
def process_date(dt, mapping=None, func=None, delta=None, offset=None):
|
28
|
+
if mapping and (dt.year in mapping):
|
29
|
+
new_dt = mapping[dt.year]
|
30
|
+
else:
|
31
|
+
new_dt = dt
|
32
|
+
if delta:
|
33
|
+
new_dt = new_dt + timedelta(delta)
|
34
|
+
dow = new_dt.weekday()
|
35
|
+
if dow == 6 and offset: # sunday
|
36
|
+
new_dt = new_dt + timedelta(offset)
|
37
|
+
if func:
|
38
|
+
return func(new_dt)
|
39
|
+
return new_dt
|
40
|
+
|
41
|
+
|
42
|
+
def process_queen_birthday(dt):
|
43
|
+
# before 1983
|
44
|
+
if dt.year in [1974, 1981]:
|
45
|
+
return dt + DateOffset(weekday=6)
|
46
|
+
elif dt.year < 1983:
|
47
|
+
return sunday_to_monday(dt)
|
48
|
+
# after 1983
|
49
|
+
wom = WeekOfMonth(week=2, weekday=0)
|
50
|
+
if dt.year in [1983, 1988, 1993, 1994]:
|
51
|
+
wom = WeekOfMonth(week=1, weekday=0)
|
52
|
+
if dt.year in [1985]:
|
53
|
+
wom = WeekOfMonth(week=3, weekday=0)
|
54
|
+
return dt + wom
|
55
|
+
|
56
|
+
|
57
|
+
HKNewYearsDay = USNewYearsDay
|
58
|
+
|
59
|
+
SpringFestivalDayBefore1983 = Holiday(
|
60
|
+
name="Spring Festival",
|
61
|
+
month=1,
|
62
|
+
day=21,
|
63
|
+
observance=partial(process_date, mapping=sf_mapping, delta=0, offset=3),
|
64
|
+
start_date=Timestamp("1961-01-01"),
|
65
|
+
end_date=Timestamp("1983-01-01"),
|
66
|
+
)
|
67
|
+
|
68
|
+
SpringFestivalDay2Before1983 = Holiday(
|
69
|
+
name="Spring Festival",
|
70
|
+
month=1,
|
71
|
+
day=21,
|
72
|
+
observance=partial(process_date, mapping=sf_mapping, delta=1, offset=2),
|
73
|
+
start_date=Timestamp("1961-01-01"),
|
74
|
+
end_date=Timestamp("1983-01-01"),
|
75
|
+
)
|
76
|
+
|
77
|
+
SpringFestivalDay3Before1983 = Holiday(
|
78
|
+
name="Spring Festival",
|
79
|
+
month=1,
|
80
|
+
day=21,
|
81
|
+
observance=partial(process_date, mapping=sf_mapping, delta=2, offset=1),
|
82
|
+
start_date=Timestamp("1961-01-01"),
|
83
|
+
end_date=Timestamp("1983-01-01"),
|
84
|
+
)
|
85
|
+
|
86
|
+
SpringFestivalDayBefore2010 = Holiday(
|
87
|
+
name="Spring Festival",
|
88
|
+
month=1,
|
89
|
+
day=21,
|
90
|
+
observance=partial(process_date, mapping=sf_mapping, delta=0, offset=-1),
|
91
|
+
start_date=Timestamp("1983-01-01"),
|
92
|
+
end_date=Timestamp("2010-07-01"),
|
93
|
+
)
|
94
|
+
|
95
|
+
SpringFestivalDay2Before2010 = Holiday(
|
96
|
+
name="Spring Festival",
|
97
|
+
month=1,
|
98
|
+
day=21,
|
99
|
+
observance=partial(process_date, mapping=sf_mapping, delta=1, offset=-2),
|
100
|
+
start_date=Timestamp("1983-01-01"),
|
101
|
+
end_date=Timestamp("2010-07-01"),
|
102
|
+
)
|
103
|
+
|
104
|
+
SpringFestivalDay3Before2010 = Holiday(
|
105
|
+
name="Spring Festival",
|
106
|
+
month=1,
|
107
|
+
day=21,
|
108
|
+
observance=partial(process_date, mapping=sf_mapping, delta=2, offset=-3),
|
109
|
+
start_date=Timestamp("1983-01-01"),
|
110
|
+
end_date=Timestamp("2010-07-01"),
|
111
|
+
)
|
112
|
+
|
113
|
+
SpringFestivalDay = Holiday(
|
114
|
+
name="Spring Festival",
|
115
|
+
month=1,
|
116
|
+
day=21,
|
117
|
+
observance=partial(process_date, mapping=sf_mapping, delta=0, offset=3),
|
118
|
+
start_date=Timestamp("2010-07-01"),
|
119
|
+
)
|
120
|
+
|
121
|
+
SpringFestivalDay2 = Holiday(
|
122
|
+
name="Spring Festival",
|
123
|
+
month=1,
|
124
|
+
day=21,
|
125
|
+
observance=partial(process_date, mapping=sf_mapping, delta=1, offset=2),
|
126
|
+
start_date=Timestamp("2010-07-01"),
|
127
|
+
)
|
128
|
+
|
129
|
+
SpringFestivalDay3 = Holiday(
|
130
|
+
name="Spring Festival",
|
131
|
+
month=1,
|
132
|
+
day=21,
|
133
|
+
observance=partial(process_date, mapping=sf_mapping, delta=2, offset=1),
|
134
|
+
start_date=Timestamp("2010-07-01"),
|
135
|
+
)
|
136
|
+
|
137
|
+
TombSweepingDay = Holiday(
|
138
|
+
name="Tomb-sweeping Day", # 清明节4月5日
|
139
|
+
month=4,
|
140
|
+
day=4,
|
141
|
+
observance=partial(process_date, mapping=tsd_mapping, func=sunday_to_monday),
|
142
|
+
start_date=Timestamp("1961-01-01"),
|
143
|
+
)
|
144
|
+
|
145
|
+
LabourDay = Holiday(
|
146
|
+
name="Labour Day", # 劳动节
|
147
|
+
month=5,
|
148
|
+
day=1,
|
149
|
+
observance=sunday_to_monday,
|
150
|
+
start_date=Timestamp("1999-05-01"),
|
151
|
+
)
|
152
|
+
|
153
|
+
BuddhaShakyamuniDay = Holiday(
|
154
|
+
name="Buddha Shakyamuni Day", # 浴佛节 98年农历4月8日定为法定假日
|
155
|
+
month=4,
|
156
|
+
day=28,
|
157
|
+
observance=partial(process_date, mapping=bsd_mapping, func=sunday_to_monday),
|
158
|
+
start_date=Timestamp("1999-04-28"),
|
159
|
+
)
|
160
|
+
|
161
|
+
DragonBoatFestivalDay = Holiday(
|
162
|
+
name="Dragon Boat Festival", # 端午节
|
163
|
+
month=5,
|
164
|
+
day=27,
|
165
|
+
observance=partial(process_date, mapping=dbf_mapping, func=sunday_to_monday),
|
166
|
+
start_date=Timestamp("1961-01-01"),
|
167
|
+
)
|
168
|
+
|
169
|
+
HKRegionEstablishmentDay = Holiday(
|
170
|
+
name="Hong Kong Special Region Establishment Day",
|
171
|
+
month=7,
|
172
|
+
day=1,
|
173
|
+
observance=sunday_to_monday,
|
174
|
+
start_date=Timestamp("1997-07-01"),
|
175
|
+
)
|
176
|
+
|
177
|
+
MidAutumnFestivalDayBefore1983 = Holiday(
|
178
|
+
name="Mid-autumn Festival", # 中秋节翌日
|
179
|
+
month=9,
|
180
|
+
day=7,
|
181
|
+
observance=partial(
|
182
|
+
process_date, mapping=maf_mapping, delta=1, func=sunday_to_monday
|
183
|
+
),
|
184
|
+
start_date=Timestamp("1961-01-01"),
|
185
|
+
end_date=Timestamp("1983-01-01"),
|
186
|
+
)
|
187
|
+
|
188
|
+
MidAutumnFestivalDayBefore2010 = Holiday(
|
189
|
+
name="Mid-autumn Festival", # 中秋节翌日
|
190
|
+
month=9,
|
191
|
+
day=7,
|
192
|
+
observance=partial(process_date, mapping=maf_mapping, delta=1, offset=-1),
|
193
|
+
start_date=Timestamp("1983-01-01"),
|
194
|
+
end_date=Timestamp("2010-12-31"),
|
195
|
+
)
|
196
|
+
|
197
|
+
MidAutumnFestivalDay = Holiday(
|
198
|
+
name="Mid-autumn Festival", # 中秋节翌日
|
199
|
+
month=9,
|
200
|
+
day=7,
|
201
|
+
observance=partial(
|
202
|
+
process_date, mapping=maf_mapping, delta=1, func=sunday_to_monday
|
203
|
+
),
|
204
|
+
start_date=Timestamp("2011-01-01"),
|
205
|
+
)
|
206
|
+
|
207
|
+
DoubleNinthFestivalDay = Holiday(
|
208
|
+
name="Double Ninth Festival", # 重阳节
|
209
|
+
month=10,
|
210
|
+
day=2,
|
211
|
+
observance=partial(process_date, mapping=dnf_mapping, func=sunday_to_monday),
|
212
|
+
start_date=Timestamp("1961-01-01"),
|
213
|
+
)
|
214
|
+
|
215
|
+
NationalDay = Holiday(
|
216
|
+
name="National Day",
|
217
|
+
month=10,
|
218
|
+
day=1,
|
219
|
+
observance=sunday_to_monday,
|
220
|
+
start_date=Timestamp("1997-07-01"),
|
221
|
+
)
|
222
|
+
|
223
|
+
Christmas = Holiday(
|
224
|
+
name="Christmas",
|
225
|
+
month=12,
|
226
|
+
day=25,
|
227
|
+
observance=partial(process_date, offset=2),
|
228
|
+
start_date=Timestamp("1954-01-01"),
|
229
|
+
)
|
230
|
+
|
231
|
+
BoxingDay = Holiday(
|
232
|
+
name="Boxing day", # 圣诞节后第一个平日
|
233
|
+
month=12,
|
234
|
+
day=26,
|
235
|
+
observance=sunday_to_monday,
|
236
|
+
start_date=Timestamp("1954-01-01"),
|
237
|
+
)
|
238
|
+
|
239
|
+
QueenBirthday = Holiday(
|
240
|
+
name="Queen's Birthday", # 英女王生日 6月
|
241
|
+
month=6,
|
242
|
+
day=10,
|
243
|
+
observance=process_queen_birthday,
|
244
|
+
start_date=Timestamp("1983-01-01"),
|
245
|
+
end_date=Timestamp("1997-06-01"),
|
246
|
+
)
|
247
|
+
|
248
|
+
QueenBirthday2 = Holiday(
|
249
|
+
name="Queen's Birthday", # 英女王生日 4月
|
250
|
+
month=4,
|
251
|
+
day=21,
|
252
|
+
observance=process_queen_birthday,
|
253
|
+
start_date=Timestamp("1926-04-21"),
|
254
|
+
end_date=Timestamp("1983-01-01"),
|
255
|
+
)
|
256
|
+
|
257
|
+
CommemoratingAlliedVictory = Holiday(
|
258
|
+
name="Commemorating the allied victory", # 重光纪念日 8月最后一个星期一
|
259
|
+
month=8,
|
260
|
+
day=20,
|
261
|
+
offset=LastWeekOfMonth(weekday=0),
|
262
|
+
start_date=Timestamp("1945-08-30"),
|
263
|
+
end_date=Timestamp("1997-07-01"),
|
264
|
+
)
|
265
|
+
|
266
|
+
IDontKnow = Holiday(
|
267
|
+
name="I dont know these days, please tell me", # 8月第一个星期一
|
268
|
+
month=7,
|
269
|
+
day=31,
|
270
|
+
offset=WeekOfMonth(week=0, weekday=0),
|
271
|
+
start_date=Timestamp("1960-08-01"),
|
272
|
+
end_date=Timestamp("1983-01-01"),
|
273
|
+
)
|
274
|
+
|
275
|
+
HKClosedDay = [
|
276
|
+
# I dont know these days
|
277
|
+
Timestamp("1970-07-01", tz="UTC"),
|
278
|
+
Timestamp("1971-07-01", tz="UTC"),
|
279
|
+
Timestamp("1973-07-02", tz="UTC"),
|
280
|
+
Timestamp("1974-07-01", tz="UTC"),
|
281
|
+
Timestamp("1975-07-01", tz="UTC"),
|
282
|
+
Timestamp("1976-07-01", tz="UTC"),
|
283
|
+
Timestamp("1977-07-01", tz="UTC"),
|
284
|
+
Timestamp("1979-07-02", tz="UTC"),
|
285
|
+
Timestamp("1980-07-01", tz="UTC"),
|
286
|
+
Timestamp("1981-07-01", tz="UTC"),
|
287
|
+
Timestamp("1982-07-01", tz="UTC"),
|
288
|
+
Timestamp("1971-03-22", tz="UTC"),
|
289
|
+
Timestamp("1971-12-06", tz="UTC"),
|
290
|
+
Timestamp("1971-12-20", tz="UTC"),
|
291
|
+
Timestamp("1975-07-28", tz="UTC"),
|
292
|
+
Timestamp("1985-07-29", tz="UTC"),
|
293
|
+
Timestamp("1970-07-16", tz="UTC"), # 台风Ruby7003
|
294
|
+
Timestamp("1970-09-14", tz="UTC"), # 台风Georgia7011
|
295
|
+
Timestamp("1971-07-22", tz="UTC"), # 台风Lucy7114
|
296
|
+
Timestamp("1971-08-31", tz="UTC"), # 重光纪念日?
|
297
|
+
Timestamp("1973-04-16", tz="UTC"), # 股灾休市?
|
298
|
+
Timestamp("1973-07-17", tz="UTC"), # 台风Dot7304
|
299
|
+
Timestamp("1974-04-25", tz="UTC"), # 英国女王生日
|
300
|
+
Timestamp("1975-10-14", tz="UTC"), # 台风Elsie7514
|
301
|
+
Timestamp("1978-07-26", tz="UTC"), # 台风Agnes7807
|
302
|
+
Timestamp("1978-07-27", tz="UTC"),
|
303
|
+
Timestamp("1979-01-26", tz="UTC"), # 春节补假
|
304
|
+
Timestamp("1979-08-02", tz="UTC"), # 台风Hope7908
|
305
|
+
Timestamp("1980-05-21", tz="UTC"), # 台风Georgia8004
|
306
|
+
Timestamp("1980-07-22", tz="UTC"), # 台风Joy8007
|
307
|
+
Timestamp("1981-04-27", tz="UTC"), # 英国女王生日
|
308
|
+
Timestamp("1981-07-06", tz="UTC"), # 台风Lynn8106
|
309
|
+
Timestamp("1981-07-07", tz="UTC"),
|
310
|
+
Timestamp("1981-07-29", tz="UTC"), # 查理斯王子与戴安娜婚礼
|
311
|
+
Timestamp("1983-09-09", tz="UTC"), # 台风Ellen8309
|
312
|
+
Timestamp("1985-06-24", tz="UTC"), # 台风Hal8504
|
313
|
+
Timestamp("1986-04-01", tz="UTC"), # 复活节星期一翌日
|
314
|
+
Timestamp("1986-10-22", tz="UTC"), # 英女王伊丽莎白二世访港
|
315
|
+
Timestamp("1987-10-20", tz="UTC"), # 黑色星期一后,休市4天
|
316
|
+
Timestamp("1987-10-21", tz="UTC"),
|
317
|
+
Timestamp("1987-10-22", tz="UTC"),
|
318
|
+
Timestamp("1987-10-23", tz="UTC"),
|
319
|
+
Timestamp("1988-04-05", tz="UTC"), # 清明节翌日
|
320
|
+
# Timestamp('1988-06-13', tz='UTC'), # 英国女王生日
|
321
|
+
Timestamp("1991-06-18", tz="UTC"), # 英国女王生日翌日
|
322
|
+
Timestamp("1992-07-22", tz="UTC"), # 台风Cary9207
|
323
|
+
# Timestamp('1993-06-14', tz='UTC'), # 英国女王生日
|
324
|
+
Timestamp("1993-09-17", tz="UTC"), # 台风Becky9316
|
325
|
+
Timestamp("1994-06-14", tz="UTC"), # 英国女王生日翌日,端午节翌日
|
326
|
+
Timestamp("1997-06-30", tz="UTC"), # 英国女王生日
|
327
|
+
Timestamp("1997-07-02", tz="UTC"), # 香港回归纪念日翌日
|
328
|
+
Timestamp("1997-08-18", tz="UTC"), # 抗战胜利纪念日
|
329
|
+
Timestamp("1997-10-02", tz="UTC"), # 国庆节翌日
|
330
|
+
Timestamp("1998-08-17", tz="UTC"), # 抗战胜利纪念日
|
331
|
+
Timestamp("1998-10-02", tz="UTC"), # 国庆节翌日
|
332
|
+
Timestamp("1999-04-06", tz="UTC"), # 清明节翌日
|
333
|
+
Timestamp("1999-09-16", tz="UTC"), # 台风约克
|
334
|
+
Timestamp("1999-12-31", tz="UTC"), # 千年虫
|
335
|
+
Timestamp("2001-07-06", tz="UTC"), # 台风尤特0104
|
336
|
+
Timestamp("2001-07-25", tz="UTC"), # 台风玉兔0107
|
337
|
+
# Timestamp(2008-06-25', tz='UTC'), # 台风风神0806,上午休市
|
338
|
+
Timestamp("2008-08-06", tz="UTC"), # 台风北冕0809
|
339
|
+
Timestamp("2008-08-22", tz="UTC"), # 台风鹦鹉0810
|
340
|
+
# Timestamp(2009-09-15', tz='UTC'), # 台风巨爵0915,上午休市
|
341
|
+
Timestamp("2010-04-06", tz="UTC"), # 清明节翌日
|
342
|
+
Timestamp("2011-09-29", tz="UTC"), # 台风纳沙1117
|
343
|
+
# Timestamp(2012-07-24', tz='UTC'), # 台风韦森特1208,上午休市
|
344
|
+
Timestamp("2012-10-02", tz="UTC"), # 中秋节补假
|
345
|
+
# Timestamp(2013-05-22', tz='UTC'), # 暴雨,上午休市
|
346
|
+
Timestamp("2013-08-14", tz="UTC"), # 台风尤特1311
|
347
|
+
# Timestamp(2013-09-23', tz='UTC'), # 台风天兔1319,上午休市
|
348
|
+
# Timestamp(2014-09-16', tz='UTC'), # 台风海鸥1415,上午休市
|
349
|
+
Timestamp("2015-04-07", tz="UTC"), # 复活节+清明节补假
|
350
|
+
# Timestamp(2015-07-09', tz='UTC'), # 台风莲花1520,期货夜盘休市
|
351
|
+
Timestamp("2015-09-03", tz="UTC"), # 抗战70周年纪念
|
352
|
+
# Timestamp(2016-08-01', tz='UTC'), # 台风妮妲1604,期货夜盘20:55收市
|
353
|
+
Timestamp("2016-08-02", tz="UTC"), # 台风妮妲1604
|
354
|
+
Timestamp("2016-10-21", tz="UTC"), # 台风海马1622
|
355
|
+
# Timestamp(2017-06-12', tz='UTC'), # 台风苗柏1702,期货夜盘17:35休市
|
356
|
+
Timestamp("2017-08-23", tz="UTC"), # 台风天鸽1713
|
357
|
+
]
|
358
|
+
|
359
|
+
|
360
|
+
class HKEXExchangeCalendar(MarketCalendar):
|
361
|
+
"""
|
362
|
+
Exchange calendar for Hong Kong Stock Exchange
|
363
|
+
|
364
|
+
Open Time: 9:30 AM, Asia/Shanghai
|
365
|
+
LUNCH BREAK :facepalm: : 12:00 AM - 1:00 PM Asia/Shanghai
|
366
|
+
Close Time: 4:00 PM, Asia/Shanghai
|
367
|
+
"""
|
368
|
+
|
369
|
+
aliases = ["HKEX"]
|
370
|
+
regular_market_times = {
|
371
|
+
"market_open": ((None, time(9, 30)),),
|
372
|
+
"market_close": ((None, time(16)),),
|
373
|
+
"break_start": ((None, time(12)),),
|
374
|
+
"break_end": ((None, time(13)),),
|
375
|
+
}
|
376
|
+
|
377
|
+
@property
|
378
|
+
def name(self):
|
379
|
+
return "HKEX"
|
380
|
+
|
381
|
+
@property
|
382
|
+
def tz(self):
|
383
|
+
return timezone("Asia/Shanghai")
|
384
|
+
|
385
|
+
@property
|
386
|
+
def regular_holidays(self):
|
387
|
+
"""
|
388
|
+
Rules are guesses based on observations of recent year.
|
389
|
+
Rectify accordingly once the next year's holidays arrangement is published by the government.
|
390
|
+
"""
|
391
|
+
return AbstractHolidayCalendar(
|
392
|
+
rules=[
|
393
|
+
HKNewYearsDay,
|
394
|
+
SpringFestivalDayBefore1983,
|
395
|
+
SpringFestivalDay2Before1983,
|
396
|
+
SpringFestivalDay3Before1983,
|
397
|
+
SpringFestivalDayBefore2010,
|
398
|
+
SpringFestivalDay2Before2010,
|
399
|
+
SpringFestivalDay3Before2010,
|
400
|
+
SpringFestivalDay,
|
401
|
+
SpringFestivalDay2,
|
402
|
+
SpringFestivalDay3,
|
403
|
+
GoodFriday,
|
404
|
+
EasterMonday,
|
405
|
+
TombSweepingDay,
|
406
|
+
LabourDay,
|
407
|
+
BuddhaShakyamuniDay,
|
408
|
+
DragonBoatFestivalDay,
|
409
|
+
HKRegionEstablishmentDay,
|
410
|
+
MidAutumnFestivalDayBefore1983,
|
411
|
+
MidAutumnFestivalDayBefore2010,
|
412
|
+
MidAutumnFestivalDay,
|
413
|
+
NationalDay,
|
414
|
+
DoubleNinthFestivalDay,
|
415
|
+
Christmas,
|
416
|
+
BoxingDay,
|
417
|
+
CommemoratingAlliedVictory,
|
418
|
+
QueenBirthday,
|
419
|
+
QueenBirthday2,
|
420
|
+
IDontKnow,
|
421
|
+
]
|
422
|
+
)
|
423
|
+
|
424
|
+
@property
|
425
|
+
def adhoc_holidays(self):
|
426
|
+
return HKClosedDay
|