From 24ce67a7cf0a63b1e37107a1b028dca891fcd581 Mon Sep 17 00:00:00 2001 From: Maxwell Rounds Date: Sun, 26 Mar 2017 15:40:40 -0700 Subject: [PATCH] ENH: Adding CFE Adhoc Holidays The CFE was closed along with the NYSE in observation of the days of mourning in honor of the passing of presidents Gerald Ford and Ronald Reagan. The CFE also observed the closures due to Hurricane Sandy, along with NYSE. Adding those adhoc holidays to exchange_calendar_cfe and removing them from cfe.csv in tests. To fit with USNationalDaysofMourning, also removing the closure in observation of the day of mourning in honor of the passing of president Nixon in 1994, despite the fact that the exchange did not exist at that time. Signed-off-by: Maxwell Rounds --- tests/resources/calendars/cfe.csv | 5 ----- zipline/utils/calendars/exchange_calendar_cfe.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/resources/calendars/cfe.csv b/tests/resources/calendars/cfe.csv index bbf8d28e..8c3cc347 100644 --- a/tests/resources/calendars/cfe.csv +++ b/tests/resources/calendars/cfe.csv @@ -1092,7 +1092,6 @@ 1994-04-22 00:00:00+00:00,1994-04-22 13:31:00,1994-04-22 20:15:00 1994-04-25 00:00:00+00:00,1994-04-25 13:31:00,1994-04-25 20:15:00 1994-04-26 00:00:00+00:00,1994-04-26 13:31:00,1994-04-26 20:15:00 -1994-04-27 00:00:00+00:00,1994-04-27 13:31:00,1994-04-27 20:15:00 1994-04-28 00:00:00+00:00,1994-04-28 13:31:00,1994-04-28 20:15:00 1994-04-29 00:00:00+00:00,1994-04-29 13:31:00,1994-04-29 20:15:00 1994-05-02 00:00:00+00:00,1994-05-02 13:31:00,1994-05-02 20:15:00 @@ -3647,7 +3646,6 @@ 2004-06-08 00:00:00+00:00,2004-06-08 13:31:00,2004-06-08 20:15:00 2004-06-09 00:00:00+00:00,2004-06-09 13:31:00,2004-06-09 20:15:00 2004-06-10 00:00:00+00:00,2004-06-10 13:31:00,2004-06-10 20:15:00 -2004-06-11 00:00:00+00:00,2004-06-11 13:31:00,2004-06-11 20:15:00 2004-06-14 00:00:00+00:00,2004-06-14 13:31:00,2004-06-14 20:15:00 2004-06-15 00:00:00+00:00,2004-06-15 13:31:00,2004-06-15 20:15:00 2004-06-16 00:00:00+00:00,2004-06-16 13:31:00,2004-06-16 20:15:00 @@ -4292,7 +4290,6 @@ 2006-12-27 00:00:00+00:00,2006-12-27 14:31:00,2006-12-27 21:15:00 2006-12-28 00:00:00+00:00,2006-12-28 14:31:00,2006-12-28 21:15:00 2006-12-29 00:00:00+00:00,2006-12-29 14:31:00,2006-12-29 21:15:00 -2007-01-02 00:00:00+00:00,2007-01-02 14:31:00,2007-01-02 21:15:00 2007-01-03 00:00:00+00:00,2007-01-03 14:31:00,2007-01-03 21:15:00 2007-01-04 00:00:00+00:00,2007-01-04 14:31:00,2007-01-04 21:15:00 2007-01-05 00:00:00+00:00,2007-01-05 14:31:00,2007-01-05 21:15:00 @@ -5761,8 +5758,6 @@ 2012-10-24 00:00:00+00:00,2012-10-24 13:31:00,2012-10-24 20:15:00 2012-10-25 00:00:00+00:00,2012-10-25 13:31:00,2012-10-25 20:15:00 2012-10-26 00:00:00+00:00,2012-10-26 13:31:00,2012-10-26 20:15:00 -2012-10-29 00:00:00+00:00,2012-10-29 13:31:00,2012-10-29 20:15:00 -2012-10-30 00:00:00+00:00,2012-10-30 13:31:00,2012-10-30 20:15:00 2012-10-31 00:00:00+00:00,2012-10-31 13:31:00,2012-10-31 20:15:00 2012-11-01 00:00:00+00:00,2012-11-01 13:31:00,2012-11-01 20:15:00 2012-11-02 00:00:00+00:00,2012-11-02 13:31:00,2012-11-02 20:15:00 diff --git a/zipline/utils/calendars/exchange_calendar_cfe.py b/zipline/utils/calendars/exchange_calendar_cfe.py index 0c5a1897..088b84e3 100644 --- a/zipline/utils/calendars/exchange_calendar_cfe.py +++ b/zipline/utils/calendars/exchange_calendar_cfe.py @@ -1,4 +1,5 @@ from datetime import time +from itertools import chain from pandas.tseries.holiday import ( USPresidentsDay, @@ -16,7 +17,9 @@ from zipline.utils.calendars.us_holidays import ( USBlackFridayInOrAfter1993, USNewYearsDay, USIndependenceDay, - Christmas + Christmas, + HurricaneSandyClosings, + USNationalDaysofMourning, ) @@ -69,3 +72,10 @@ class CFEExchangeCalendar(TradingCalendar): USBlackFridayInOrAfter1993, ]) )] + + @property + def adhoc_holidays(self): + return list(chain( + HurricaneSandyClosings, + USNationalDaysofMourning, + ))