pandas-market-calendars 4.3.0__py3-none-any.whl → 4.3.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. pandas_market_calendars/calendars/__init__.py +0 -0
  2. pandas_market_calendars/calendars/asx.py +63 -0
  3. pandas_market_calendars/calendars/bmf.py +227 -0
  4. pandas_market_calendars/calendars/bse.py +409 -0
  5. pandas_market_calendars/calendars/cboe.py +115 -0
  6. pandas_market_calendars/calendars/cme.py +240 -0
  7. pandas_market_calendars/calendars/cme_globex_agriculture.py +103 -0
  8. pandas_market_calendars/calendars/cme_globex_base.py +103 -0
  9. pandas_market_calendars/calendars/cme_globex_crypto.py +147 -0
  10. pandas_market_calendars/calendars/cme_globex_energy_and_metals.py +138 -0
  11. pandas_market_calendars/calendars/cme_globex_equities.py +104 -0
  12. pandas_market_calendars/calendars/cme_globex_fixed_income.py +113 -0
  13. pandas_market_calendars/calendars/cme_globex_fx.py +78 -0
  14. pandas_market_calendars/calendars/eurex.py +119 -0
  15. pandas_market_calendars/calendars/hkex.py +408 -0
  16. pandas_market_calendars/calendars/ice.py +65 -0
  17. pandas_market_calendars/calendars/iex.py +98 -0
  18. pandas_market_calendars/calendars/jpx.py +103 -0
  19. pandas_market_calendars/calendars/lse.py +91 -0
  20. pandas_market_calendars/calendars/mirror.py +114 -0
  21. pandas_market_calendars/calendars/nyse.py +1127 -0
  22. pandas_market_calendars/calendars/ose.py +150 -0
  23. pandas_market_calendars/calendars/sifma.py +297 -0
  24. pandas_market_calendars/calendars/six.py +114 -0
  25. pandas_market_calendars/calendars/sse.py +290 -0
  26. pandas_market_calendars/calendars/tase.py +195 -0
  27. pandas_market_calendars/calendars/tsx.py +159 -0
  28. pandas_market_calendars/holidays/__init__.py +0 -0
  29. pandas_market_calendars/holidays/cme.py +340 -0
  30. pandas_market_calendars/holidays/cme_globex.py +198 -0
  31. pandas_market_calendars/holidays/cn.py +1436 -0
  32. pandas_market_calendars/holidays/jp.py +396 -0
  33. pandas_market_calendars/holidays/jpx_equinox.py +147 -0
  34. pandas_market_calendars/holidays/nyse.py +1472 -0
  35. pandas_market_calendars/holidays/oz.py +65 -0
  36. pandas_market_calendars/holidays/sifma.py +321 -0
  37. pandas_market_calendars/holidays/uk.py +180 -0
  38. pandas_market_calendars/holidays/us.py +360 -0
  39. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/METADATA +1 -1
  40. pandas_market_calendars-4.3.1.dist-info/RECORD +49 -0
  41. pandas_market_calendars-4.3.0.dist-info/RECORD +0 -11
  42. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/LICENSE +0 -0
  43. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/NOTICE +0 -0
  44. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/WHEEL +0 -0
  45. {pandas_market_calendars-4.3.0.dist-info → pandas_market_calendars-4.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,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 AbstractHolidayCalendar, EasterMonday, GoodFriday, Holiday, sunday_to_monday
6
+ from pandas.tseries.offsets import LastWeekOfMonth, WeekOfMonth
7
+ from pytz import timezone
8
+
9
+ from pandas_market_calendars.holidays.us import USNewYearsDay
10
+ from pandas_market_calendars.holidays.cn import bsd_mapping, dbf_mapping, dnf_mapping, maf_mapping, sf_mapping, tsd_mapping
11
+ from pandas_market_calendars.market_calendar import MarketCalendar
12
+
13
+
14
+ def process_date(dt, mapping=None, func=None, delta=None, offset=None):
15
+ if mapping and (dt.year in mapping):
16
+ new_dt = mapping[dt.year]
17
+ else:
18
+ new_dt = dt
19
+ if delta:
20
+ new_dt = new_dt + timedelta(delta)
21
+ dow = new_dt.weekday()
22
+ if dow == 6 and offset: # sunday
23
+ new_dt = new_dt + timedelta(offset)
24
+ if func:
25
+ return func(new_dt)
26
+ return new_dt
27
+
28
+
29
+ def process_queen_birthday(dt):
30
+ # before 1983
31
+ if dt.year in [1974, 1981]:
32
+ return dt + DateOffset(weekday=6)
33
+ elif dt.year < 1983:
34
+ return sunday_to_monday(dt)
35
+ # after 1983
36
+ wom = WeekOfMonth(week=2, weekday=0)
37
+ if dt.year in [1983, 1988, 1993, 1994]:
38
+ wom = WeekOfMonth(week=1, weekday=0)
39
+ if dt.year in [1985]:
40
+ wom = WeekOfMonth(week=3, weekday=0)
41
+ return dt + wom
42
+
43
+
44
+ HKNewYearsDay = USNewYearsDay
45
+
46
+ SpringFestivalDayBefore1983 = Holiday(
47
+ name="Spring Festival",
48
+ month=1,
49
+ day=21,
50
+ observance=partial(process_date, mapping=sf_mapping, delta=0, offset=3),
51
+ start_date=Timestamp('1961-01-01'),
52
+ end_date=Timestamp('1983-01-01')
53
+ )
54
+
55
+ SpringFestivalDay2Before1983 = Holiday(
56
+ name="Spring Festival",
57
+ month=1,
58
+ day=21,
59
+ observance=partial(process_date, mapping=sf_mapping, delta=1, offset=2),
60
+ start_date=Timestamp('1961-01-01'),
61
+ end_date=Timestamp('1983-01-01')
62
+ )
63
+
64
+ SpringFestivalDay3Before1983 = Holiday(
65
+ name="Spring Festival",
66
+ month=1,
67
+ day=21,
68
+ observance=partial(process_date, mapping=sf_mapping, delta=2, offset=1),
69
+ start_date=Timestamp('1961-01-01'),
70
+ end_date=Timestamp('1983-01-01')
71
+ )
72
+
73
+ SpringFestivalDayBefore2010 = Holiday(
74
+ name="Spring Festival",
75
+ month=1,
76
+ day=21,
77
+ observance=partial(process_date, mapping=sf_mapping, delta=0, offset=-1),
78
+ start_date=Timestamp('1983-01-01'),
79
+ end_date=Timestamp('2010-07-01')
80
+ )
81
+
82
+ SpringFestivalDay2Before2010 = Holiday(
83
+ name="Spring Festival",
84
+ month=1,
85
+ day=21,
86
+ observance=partial(process_date, mapping=sf_mapping, delta=1, offset=-2),
87
+ start_date=Timestamp('1983-01-01'),
88
+ end_date=Timestamp('2010-07-01')
89
+ )
90
+
91
+ SpringFestivalDay3Before2010 = Holiday(
92
+ name="Spring Festival",
93
+ month=1,
94
+ day=21,
95
+ observance=partial(process_date, mapping=sf_mapping, delta=2, offset=-3),
96
+ start_date=Timestamp('1983-01-01'),
97
+ end_date=Timestamp('2010-07-01')
98
+ )
99
+
100
+ SpringFestivalDay = Holiday(
101
+ name="Spring Festival",
102
+ month=1,
103
+ day=21,
104
+ observance=partial(process_date, mapping=sf_mapping, delta=0, offset=3),
105
+ start_date=Timestamp('2010-07-01')
106
+ )
107
+
108
+ SpringFestivalDay2 = Holiday(
109
+ name="Spring Festival",
110
+ month=1,
111
+ day=21,
112
+ observance=partial(process_date, mapping=sf_mapping, delta=1, offset=2),
113
+ start_date=Timestamp('2010-07-01')
114
+ )
115
+
116
+ SpringFestivalDay3 = Holiday(
117
+ name="Spring Festival",
118
+ month=1,
119
+ day=21,
120
+ observance=partial(process_date, mapping=sf_mapping, delta=2, offset=1),
121
+ start_date=Timestamp('2010-07-01')
122
+ )
123
+
124
+ TombSweepingDay = Holiday(
125
+ name="Tomb-sweeping Day", # 清明节4月5日
126
+ month=4,
127
+ day=4,
128
+ observance=partial(process_date, mapping=tsd_mapping, func=sunday_to_monday),
129
+ start_date=Timestamp('1961-01-01')
130
+ )
131
+
132
+ LabourDay = Holiday(
133
+ name="Labour Day", # 劳动节
134
+ month=5,
135
+ day=1,
136
+ observance=sunday_to_monday,
137
+ start_date=Timestamp('1999-05-01')
138
+ )
139
+
140
+ BuddhaShakyamuniDay = Holiday(
141
+ name="Buddha Shakyamuni Day", # 浴佛节 98年农历4月8日定为法定假日
142
+ month=4,
143
+ day=28,
144
+ observance=partial(process_date, mapping=bsd_mapping, func=sunday_to_monday),
145
+ start_date=Timestamp('1999-04-28')
146
+ )
147
+
148
+ DragonBoatFestivalDay = Holiday(
149
+ name="Dragon Boat Festival", # 端午节
150
+ month=5,
151
+ day=27,
152
+ observance=partial(process_date, mapping=dbf_mapping, func=sunday_to_monday),
153
+ start_date=Timestamp('1961-01-01')
154
+ )
155
+
156
+ HKRegionEstablishmentDay = Holiday(
157
+ name="Hong Kong Special Region Establishment Day",
158
+ month=7,
159
+ day=1,
160
+ observance=sunday_to_monday,
161
+ start_date=Timestamp('1997-07-01')
162
+ )
163
+
164
+ MidAutumnFestivalDayBefore1983 = Holiday(
165
+ name="Mid-autumn Festival", # 中秋节翌日
166
+ month=9,
167
+ day=7,
168
+ observance=partial(process_date, mapping=maf_mapping, delta=1, func=sunday_to_monday),
169
+ start_date=Timestamp('1961-01-01'),
170
+ end_date=Timestamp('1983-01-01')
171
+ )
172
+
173
+ MidAutumnFestivalDayBefore2010 = Holiday(
174
+ name="Mid-autumn Festival", # 中秋节翌日
175
+ month=9,
176
+ day=7,
177
+ observance=partial(process_date, mapping=maf_mapping, delta=1, offset=-1),
178
+ start_date=Timestamp('1983-01-01'),
179
+ end_date=Timestamp('2010-12-31')
180
+ )
181
+
182
+ MidAutumnFestivalDay = Holiday(
183
+ name="Mid-autumn Festival", # 中秋节翌日
184
+ month=9,
185
+ day=7,
186
+ observance=partial(process_date, mapping=maf_mapping, delta=1, func=sunday_to_monday),
187
+ start_date=Timestamp('2011-01-01')
188
+ )
189
+
190
+ DoubleNinthFestivalDay = Holiday(
191
+ name="Double Ninth Festival", # 重阳节
192
+ month=10,
193
+ day=2,
194
+ observance=partial(process_date, mapping=dnf_mapping, func=sunday_to_monday),
195
+ start_date=Timestamp('1961-01-01')
196
+ )
197
+
198
+ NationalDay = Holiday(
199
+ name="National Day",
200
+ month=10,
201
+ day=1,
202
+ observance=sunday_to_monday,
203
+ start_date=Timestamp('1997-07-01')
204
+ )
205
+
206
+ Christmas = Holiday(
207
+ name='Christmas',
208
+ month=12,
209
+ day=25,
210
+ observance=partial(process_date, offset=2),
211
+ start_date=Timestamp('1954-01-01')
212
+ )
213
+
214
+ BoxingDay = Holiday(
215
+ name='Boxing day', # 圣诞节后第一个平日
216
+ month=12,
217
+ day=26,
218
+ observance=sunday_to_monday,
219
+ start_date=Timestamp('1954-01-01')
220
+ )
221
+
222
+ QueenBirthday = Holiday(
223
+ name="Queen's Birthday", # 英女王生日 6月
224
+ month=6,
225
+ day=10,
226
+ observance=process_queen_birthday,
227
+ start_date=Timestamp('1983-01-01'),
228
+ end_date=Timestamp('1997-06-01')
229
+ )
230
+
231
+ QueenBirthday2 = Holiday(
232
+ name="Queen's Birthday", # 英女王生日 4月
233
+ month=4,
234
+ day=21,
235
+ observance=process_queen_birthday,
236
+ start_date=Timestamp('1926-04-21'),
237
+ end_date=Timestamp('1983-01-01')
238
+ )
239
+
240
+ CommemoratingAlliedVictory = Holiday(
241
+ name="Commemorating the allied victory", # 重光纪念日 8月最后一个星期一
242
+ month=8,
243
+ day=20,
244
+ offset=LastWeekOfMonth(weekday=0),
245
+ start_date=Timestamp('1945-08-30'),
246
+ end_date=Timestamp('1997-07-01')
247
+ )
248
+
249
+ IDontKnow = Holiday(
250
+ name="I dont know these days, please tell me", # 8月第一个星期一
251
+ month=7,
252
+ day=31,
253
+ offset=WeekOfMonth(week=0, weekday=0),
254
+ start_date=Timestamp('1960-08-01'),
255
+ end_date=Timestamp('1983-01-01')
256
+ )
257
+
258
+ HKClosedDay = [
259
+ # I dont know these days
260
+ Timestamp('1970-07-01', tz='UTC'),
261
+ Timestamp('1971-07-01', tz='UTC'),
262
+ Timestamp('1973-07-02', tz='UTC'),
263
+ Timestamp('1974-07-01', tz='UTC'),
264
+ Timestamp('1975-07-01', tz='UTC'),
265
+ Timestamp('1976-07-01', tz='UTC'),
266
+ Timestamp('1977-07-01', tz='UTC'),
267
+ Timestamp('1979-07-02', tz='UTC'),
268
+ Timestamp('1980-07-01', tz='UTC'),
269
+ Timestamp('1981-07-01', tz='UTC'),
270
+ Timestamp('1982-07-01', tz='UTC'),
271
+ Timestamp('1971-03-22', tz='UTC'),
272
+ Timestamp('1971-12-06', tz='UTC'),
273
+ Timestamp('1971-12-20', tz='UTC'),
274
+ Timestamp('1975-07-28', tz='UTC'),
275
+ Timestamp('1985-07-29', tz='UTC'),
276
+
277
+ Timestamp('1970-07-16', tz='UTC'), # 台风Ruby7003
278
+ Timestamp('1970-09-14', tz='UTC'), # 台风Georgia7011
279
+ Timestamp('1971-07-22', tz='UTC'), # 台风Lucy7114
280
+ Timestamp('1971-08-31', tz='UTC'), # 重光纪念日?
281
+ Timestamp('1973-04-16', tz='UTC'), # 股灾休市?
282
+ Timestamp('1973-07-17', tz='UTC'), # 台风Dot7304
283
+ Timestamp('1974-04-25', tz='UTC'), # 英国女王生日
284
+ Timestamp('1975-10-14', tz='UTC'), # 台风Elsie7514
285
+ Timestamp('1978-07-26', tz='UTC'), # 台风Agnes7807
286
+ Timestamp('1978-07-27', tz='UTC'),
287
+ Timestamp('1979-01-26', tz='UTC'), # 春节补假
288
+ Timestamp('1979-08-02', tz='UTC'), # 台风Hope7908
289
+ Timestamp('1980-05-21', tz='UTC'), # 台风Georgia8004
290
+ Timestamp('1980-07-22', tz='UTC'), # 台风Joy8007
291
+ Timestamp('1981-04-27', tz='UTC'), # 英国女王生日
292
+ Timestamp('1981-07-06', tz='UTC'), # 台风Lynn8106
293
+ Timestamp('1981-07-07', tz='UTC'),
294
+ Timestamp('1981-07-29', tz='UTC'), # 查理斯王子与戴安娜婚礼
295
+ Timestamp('1983-09-09', tz='UTC'), # 台风Ellen8309
296
+ Timestamp('1985-06-24', tz='UTC'), # 台风Hal8504
297
+ Timestamp('1986-04-01', tz='UTC'), # 复活节星期一翌日
298
+ Timestamp('1986-10-22', tz='UTC'), # 英女王伊丽莎白二世访港
299
+ Timestamp('1987-10-20', tz='UTC'), # 黑色星期一后,休市4天
300
+ Timestamp('1987-10-21', tz='UTC'),
301
+ Timestamp('1987-10-22', tz='UTC'),
302
+ Timestamp('1987-10-23', tz='UTC'),
303
+ Timestamp('1988-04-05', tz='UTC'), # 清明节翌日
304
+ # Timestamp('1988-06-13', tz='UTC'), # 英国女王生日
305
+ Timestamp('1991-06-18', tz='UTC'), # 英国女王生日翌日
306
+ Timestamp('1992-07-22', tz='UTC'), # 台风Cary9207
307
+ # Timestamp('1993-06-14', tz='UTC'), # 英国女王生日
308
+ Timestamp('1993-09-17', tz='UTC'), # 台风Becky9316
309
+ Timestamp('1994-06-14', tz='UTC'), # 英国女王生日翌日,端午节翌日
310
+ Timestamp('1997-06-30', tz='UTC'), # 英国女王生日
311
+ Timestamp('1997-07-02', tz='UTC'), # 香港回归纪念日翌日
312
+ Timestamp('1997-08-18', tz='UTC'), # 抗战胜利纪念日
313
+ Timestamp('1997-10-02', tz='UTC'), # 国庆节翌日
314
+ Timestamp('1998-08-17', tz='UTC'), # 抗战胜利纪念日
315
+ Timestamp('1998-10-02', tz='UTC'), # 国庆节翌日
316
+ Timestamp('1999-04-06', tz='UTC'), # 清明节翌日
317
+ Timestamp('1999-09-16', tz='UTC'), # 台风约克
318
+ Timestamp('1999-12-31', tz='UTC'), # 千年虫
319
+ Timestamp('2001-07-06', tz='UTC'), # 台风尤特0104
320
+ Timestamp('2001-07-25', tz='UTC'), # 台风玉兔0107
321
+ # Timestamp(2008-06-25', tz='UTC'), # 台风风神0806,上午休市
322
+ Timestamp('2008-08-06', tz='UTC'), # 台风北冕0809
323
+ Timestamp('2008-08-22', tz='UTC'), # 台风鹦鹉0810
324
+ # Timestamp(2009-09-15', tz='UTC'), # 台风巨爵0915,上午休市
325
+ Timestamp('2010-04-06', tz='UTC'), # 清明节翌日
326
+ Timestamp('2011-09-29', tz='UTC'), # 台风纳沙1117
327
+ # Timestamp(2012-07-24', tz='UTC'), # 台风韦森特1208,上午休市
328
+ Timestamp('2012-10-02', tz='UTC'), # 中秋节补假
329
+ # Timestamp(2013-05-22', tz='UTC'), # 暴雨,上午休市
330
+ Timestamp('2013-08-14', tz='UTC'), # 台风尤特1311
331
+ # Timestamp(2013-09-23', tz='UTC'), # 台风天兔1319,上午休市
332
+ # Timestamp(2014-09-16', tz='UTC'), # 台风海鸥1415,上午休市
333
+ Timestamp('2015-04-07', tz='UTC'), # 复活节+清明节补假
334
+ # Timestamp(2015-07-09', tz='UTC'), # 台风莲花1520,期货夜盘休市
335
+ Timestamp('2015-09-03', tz='UTC'), # 抗战70周年纪念
336
+ # Timestamp(2016-08-01', tz='UTC'), # 台风妮妲1604,期货夜盘20:55收市
337
+ Timestamp('2016-08-02', tz='UTC'), # 台风妮妲1604
338
+ Timestamp('2016-10-21', tz='UTC'), # 台风海马1622
339
+ # Timestamp(2017-06-12', tz='UTC'), # 台风苗柏1702,期货夜盘17:35休市
340
+ Timestamp('2017-08-23', tz='UTC'), # 台风天鸽1713
341
+ ]
342
+
343
+
344
+ class HKEXExchangeCalendar(MarketCalendar):
345
+ """
346
+ Exchange calendar for Hong Kong Stock Exchange
347
+
348
+ Open Time: 9:30 AM, Asia/Shanghai
349
+ LUNCH BREAK :facepalm: : 12:00 AM - 1:00 PM Asia/Shanghai
350
+ Close Time: 4:00 PM, Asia/Shanghai
351
+ """
352
+ aliases = ['HKEX']
353
+ regular_market_times = {
354
+ "market_open": ((None, time(9, 30)),),
355
+ "market_close": ((None, time(16)),),
356
+ "break_start": ((None, time(12)),),
357
+ "break_end": ((None, time(13)),)
358
+ }
359
+
360
+ @property
361
+ def name(self):
362
+ return "HKEX"
363
+
364
+ @property
365
+ def tz(self):
366
+ return timezone('Asia/Shanghai')
367
+
368
+
369
+ @property
370
+ def regular_holidays(self):
371
+ """
372
+ Rules are guesses based on observations of recent year.
373
+ Rectify accordingly once the next year's holidays arrangement is published by the government.
374
+ """
375
+ return AbstractHolidayCalendar(rules=[
376
+ HKNewYearsDay,
377
+ SpringFestivalDayBefore1983,
378
+ SpringFestivalDay2Before1983,
379
+ SpringFestivalDay3Before1983,
380
+ SpringFestivalDayBefore2010,
381
+ SpringFestivalDay2Before2010,
382
+ SpringFestivalDay3Before2010,
383
+ SpringFestivalDay,
384
+ SpringFestivalDay2,
385
+ SpringFestivalDay3,
386
+ GoodFriday,
387
+ EasterMonday,
388
+ TombSweepingDay,
389
+ LabourDay,
390
+ BuddhaShakyamuniDay,
391
+ DragonBoatFestivalDay,
392
+ HKRegionEstablishmentDay,
393
+ MidAutumnFestivalDayBefore1983,
394
+ MidAutumnFestivalDayBefore2010,
395
+ MidAutumnFestivalDay,
396
+ NationalDay,
397
+ DoubleNinthFestivalDay,
398
+ Christmas,
399
+ BoxingDay,
400
+ CommemoratingAlliedVictory,
401
+ QueenBirthday,
402
+ QueenBirthday2,
403
+ IDontKnow
404
+ ])
405
+
406
+ @property
407
+ def adhoc_holidays(self):
408
+ return HKClosedDay
@@ -0,0 +1,65 @@
1
+ from datetime import time
2
+ from itertools import chain
3
+
4
+ from pandas import Timestamp
5
+ from pandas.tseries.holiday import AbstractHolidayCalendar, GoodFriday, USLaborDay, USPresidentsDay, USThanksgivingDay
6
+ from pytz import timezone
7
+
8
+ from pandas_market_calendars.holidays.us import (Christmas, USIndependenceDay, USMartinLutherKingJrAfter1998, USMemorialDay,
9
+ USNationalDaysofMourning, USNewYearsDay)
10
+ from pandas_market_calendars.market_calendar import MarketCalendar
11
+
12
+
13
+ class ICEExchangeCalendar(MarketCalendar):
14
+ """
15
+ Exchange calendar for ICE US.
16
+
17
+ Open Time: 8pm, US/Eastern
18
+ Close Time: 6pm, US/Eastern
19
+
20
+ https://www.theice.com/publicdocs/futures_us/ICE_Futures_US_Regular_Trading_Hours.pdf # noqa
21
+ """
22
+ aliases = ['ICE', 'ICEUS', 'NYFE']
23
+ regular_market_times = {
24
+ "market_open": ((None, time(20, 1), -1),), # offset by -1 day
25
+ "market_close": ((None, time(18)),)
26
+ }
27
+
28
+ @property
29
+ def name(self):
30
+ return "ICE"
31
+
32
+ @property
33
+ def tz(self):
34
+ return timezone("US/Eastern")
35
+
36
+ @property
37
+ def special_closes(self):
38
+ return [
39
+ (time(13), AbstractHolidayCalendar(rules=[
40
+ USMartinLutherKingJrAfter1998,
41
+ USPresidentsDay,
42
+ USMemorialDay,
43
+ USIndependenceDay,
44
+ USLaborDay,
45
+ USThanksgivingDay
46
+ ]))
47
+ ]
48
+
49
+ @property
50
+ def adhoc_holidays(self):
51
+ return list(chain(
52
+ USNationalDaysofMourning,
53
+ # ICE was only closed on the first day of the Hurricane Sandy
54
+ # closings (was not closed on 2012-10-30)
55
+ [Timestamp('2012-10-29', tz='UTC')]
56
+ ))
57
+
58
+ @property
59
+ def regular_holidays(self):
60
+ # https://www.theice.com/publicdocs/futures_us/exchange_notices/NewExNot2016Holidays.pdf # noqa
61
+ return AbstractHolidayCalendar(rules=[
62
+ USNewYearsDay,
63
+ GoodFriday,
64
+ Christmas
65
+ ])
@@ -0,0 +1,98 @@
1
+ from datetime import time
2
+ from itertools import chain
3
+ from .nyse import NYSEExchangeCalendar
4
+ from pandas.tseries.holiday import AbstractHolidayCalendar
5
+ from pytz import timezone
6
+
7
+ from pandas_market_calendars.holidays.nyse import (
8
+ USPresidentsDay,
9
+ GoodFriday,
10
+ USMemorialDay,
11
+ USJuneteenthAfter2022,
12
+ USIndependenceDay,
13
+ USThanksgivingDay,
14
+ ChristmasNYSE,
15
+ USMartinLutherKingJrAfter1998,
16
+
17
+ #Ad-Hoc
18
+ DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
19
+ DaysBeforeIndependenceDay1pmEarlyCloseAdhoc,
20
+ ChristmasEvesAdhoc,
21
+ )
22
+
23
+ class IEXExchangeCalendar(NYSEExchangeCalendar):
24
+ """
25
+ Exchange calendar for the Investor's Exchange (IEX).
26
+
27
+ IEX Exchange is a U.S. stock exchange focused on driving performance
28
+ for broker-dealers and investors through innovative design and technology.
29
+
30
+ Most of this class inherits from NYSEExchangeCalendar since
31
+ the holidays are the same. The only variation is (1) IEX began
32
+ operation in 2013, and (2) IEX has different hours of operation
33
+
34
+ References:
35
+ - https://exchange.iex.io/
36
+ - https://iexexchange.io/resources/trading/trading-hours-holidays/index.html
37
+ """
38
+
39
+ regular_market_times = {
40
+ "pre": (('2013-03-25', time(8)),),
41
+ "market_open": ((None, time(9, 30)),),
42
+ "market_close":((None, time(16)),),
43
+ "post": ((None, time(17)),)
44
+ }
45
+
46
+ aliases = ['IEX', 'Investors_Exchange']
47
+
48
+ @property
49
+ def name(self):
50
+ return "IEX"
51
+
52
+ @property
53
+ def weekmask(self):
54
+ return "Mon Tue Wed Thu Fri"
55
+
56
+ @property
57
+ def regular_holidays(self):
58
+ return AbstractHolidayCalendar(rules=[
59
+ USPresidentsDay,
60
+ GoodFriday,
61
+ USMemorialDay,
62
+ USJuneteenthAfter2022,
63
+ USIndependenceDay,
64
+ USThanksgivingDay,
65
+ ChristmasNYSE,
66
+ USMartinLutherKingJrAfter1998
67
+ ])
68
+
69
+ @property
70
+ def adhoc_holidays(self):
71
+ return list(chain(
72
+ ChristmasEvesAdhoc,
73
+ ))
74
+
75
+ @property
76
+ def special_closes(self):
77
+ return [
78
+ (time(hour=13, tzinfo=timezone('America/New_York')), AbstractHolidayCalendar(rules=[
79
+ DayAfterThanksgiving1pmEarlyCloseInOrAfter1993,
80
+ ]))
81
+ ]
82
+
83
+ """Override NYSE calendar special cases"""
84
+
85
+ @property
86
+ def special_closes_adhoc(self):
87
+ return [
88
+ (time(13, tzinfo=timezone('America/New_York')),
89
+ DaysBeforeIndependenceDay1pmEarlyCloseAdhoc)
90
+ ]
91
+
92
+ @property
93
+ def special_opens(self):
94
+ return []
95
+
96
+ def valid_days(self, start_date, end_date, tz='UTC'):
97
+ trading_days = super().valid_days(start_date, end_date, tz=tz) #all NYSE valid days
98
+ return trading_days[~(trading_days <= '2013-08-25')]
@@ -0,0 +1,103 @@
1
+ from datetime import time
2
+ from itertools import chain
3
+
4
+ from pandas.tseries.holiday import AbstractHolidayCalendar
5
+ from pytz import timezone
6
+
7
+ from pandas_market_calendars.holidays.jp import *
8
+ from pandas_market_calendars.holidays.us import USNewYearsDay
9
+ from pandas_market_calendars.market_calendar import MarketCalendar
10
+
11
+
12
+ # TODO:
13
+ # From 1949 to 1972 the TSE was open on all non-holiday Saturdays for a half day
14
+ # From 1973 to 1984 the TSE was open on all non-holiday Saturdays except the third Saturday of the month
15
+ # need to add support for weekmask to make this work properly
16
+
17
+ class JPXExchangeCalendar(MarketCalendar):
18
+ """
19
+ Exchange calendar for JPX
20
+
21
+ Open Time: 9:31 AM, Asia/Tokyo
22
+ LUNCH BREAK :facepalm: : 11:30 AM - 12:30 PM Asia/Tokyo
23
+ Close Time: 4:00 PM, Asia/Tokyo
24
+ """
25
+ aliases = ['JPX']
26
+ regular_market_times = {
27
+ "market_open": ((None, time(9)),),
28
+ "market_close": ((None, time(15)),),
29
+ "break_start": ((None, time(11, 30)),),
30
+ "break_end": ((None, time(12,30)),)
31
+ }
32
+ regular_early_close = time(13)
33
+
34
+ @property
35
+ def name(self):
36
+ return "JPX"
37
+
38
+ @property
39
+ def tz(self):
40
+ return timezone('Asia/Tokyo')
41
+
42
+ @property
43
+ def adhoc_holidays(self):
44
+ return list(chain(
45
+ AscensionDays,
46
+ MarriageDays,
47
+ FuneralShowa,
48
+ EnthronementDays,
49
+ AutumnalCitizenDates,
50
+ NoN225IndexPrices,
51
+ EquityTradingSystemFailure
52
+ ))
53
+
54
+ @property
55
+ def regular_holidays(self):
56
+ return AbstractHolidayCalendar(rules=[
57
+ USNewYearsDay,
58
+ JapanNewYearsDay2,
59
+ JapanNewYearsDay3,
60
+ JapanComingOfAgeDay1951To1973,
61
+ JapanComingOfAgeDay1974To1999,
62
+ JapanComingOfAgeDay,
63
+ JapanNationalFoundationDay1969To1973,
64
+ JapanNationalFoundationDay,
65
+ JapanEmperorsBirthday,
66
+ JapanVernalEquinox,
67
+ JapanShowaDayUntil1972,
68
+ JapanShowaDay,
69
+ JapanConstitutionMemorialDayUntil1972,
70
+ JapanConstitutionMemorialDay,
71
+ JapanGreeneryDay,
72
+ JapanChildrensDayUntil1972,
73
+ JapanChildrensDay,
74
+ JapanGoldenWeekBonusDay,
75
+ JapanMarineDay1996To2002,
76
+ JapanMarineDay2003To2019,
77
+ JapanMarineDay2020,
78
+ JapanMarineDay2021,
79
+ JapanMarineDay,
80
+ JapanMountainDay2016to2019,
81
+ JapanMountainDay2020,
82
+ JapanMountainDay2021,
83
+ JapanMountainDay2021NextDay,
84
+ JapanMountainDay,
85
+ JapanRespectForTheAgedDay1966To1972,
86
+ JapanRespectForTheAgedDay1973To2002,
87
+ JapanRespectForTheAgedDay,
88
+ JapanAutumnalEquinox,
89
+ JapanHealthAndSportsDay1966To1972,
90
+ JapanHealthAndSportsDay1973To1999,
91
+ JapanHealthAndSportsDay2000To2019,
92
+ JapanSportsDay2020,
93
+ JapanSportsDay2021,
94
+ JapanSportsDay,
95
+ JapanCultureDayUntil1972,
96
+ JapanCultureDay,
97
+ JapanLaborThanksgivingDayUntil1972,
98
+ JapanLaborThanksgivingDay,
99
+ JapanEmperorAkahitosBirthday,
100
+ JapanDecember29Until1988,
101
+ JapanDecember30Until1988,
102
+ JapanBeforeNewYearsDay,
103
+ ])