From b163c64358142bb7d9cb892e69a5a242ba86c8dd Mon Sep 17 00:00:00 2001 From: Philip Tromans Date: Mon, 6 Dec 2021 21:34:43 +0000 Subject: [PATCH] Made Good Friday always a holiday in XCBF --- exchange_calendars/exchange_calendar_xcbf.py | 31 +------------------- tests/resources/xcbf.csv | 9 ------ tests/test_xcbf_calendar.py | 10 +------ 3 files changed, 2 insertions(+), 48 deletions(-) diff --git a/exchange_calendars/exchange_calendar_xcbf.py b/exchange_calendars/exchange_calendar_xcbf.py index 4fed9fd4..3bf86446 100644 --- a/exchange_calendars/exchange_calendar_xcbf.py +++ b/exchange_calendars/exchange_calendar_xcbf.py @@ -1,10 +1,8 @@ from datetime import time from itertools import chain -import pandas as pd from pandas.tseries.holiday import ( GoodFriday, - Holiday, USLaborDay, USPresidentsDay, USThanksgivingDay, @@ -25,33 +23,6 @@ ) -def good_friday_unless_christmas_nye_friday(dt): - """ - Good Friday is a valid trading day if Christmas Day or New Years Day fall - on a Friday. - """ - year_str = str(dt.year) - christmas_weekday = Christmas.observance( - pd.Timestamp(year_str + "-12-25") - ).weekday() - nyd_weekday = USNewYearsDay.observance(pd.Timestamp(year_str + "-01-01")).weekday() - if christmas_weekday != 4 and nyd_weekday != 4: - return GoodFriday._apply_rule( - pd.Timestamp(str(dt.year) + "-" + str(dt.month) + "-" + str(dt.day)) - ) - else: - # compatibility for pandas 0.18.1 - return pd.NaT - - -GoodFridayUnlessChristmasNYEFriday = Holiday( - name="Good Friday XCBF", - month=1, - day=1, - observance=good_friday_unless_christmas_nye_friday, -) - - class XCBFExchangeCalendar(ExchangeCalendar): """ Exchange calendar for the CBOE Futures Exchange (XCBF). @@ -79,7 +50,7 @@ def regular_holidays(self): USNewYearsDay, USMartinLutherKingJrAfter1998, USPresidentsDay, - GoodFridayUnlessChristmasNYEFriday, + GoodFriday, USIndependenceDay, USMemorialDay, USLaborDay, diff --git a/tests/resources/xcbf.csv b/tests/resources/xcbf.csv index f942889d..c34fb303 100644 --- a/tests/resources/xcbf.csv +++ b/tests/resources/xcbf.csv @@ -580,7 +580,6 @@ 1992-04-14T00:00:00Z,1992-04-14T13:30:00Z,1992-04-14T20:15:00Z,, 1992-04-15T00:00:00Z,1992-04-15T13:30:00Z,1992-04-15T20:15:00Z,, 1992-04-16T00:00:00Z,1992-04-16T13:30:00Z,1992-04-16T20:15:00Z,, -1992-04-17T00:00:00Z,1992-04-17T13:30:00Z,1992-04-17T20:15:00Z,, 1992-04-20T00:00:00Z,1992-04-20T13:30:00Z,1992-04-20T20:15:00Z,, 1992-04-21T00:00:00Z,1992-04-21T13:30:00Z,1992-04-21T20:15:00Z,, 1992-04-22T00:00:00Z,1992-04-22T13:30:00Z,1992-04-22T20:15:00Z,, @@ -828,7 +827,6 @@ 1993-04-06T00:00:00Z,1993-04-06T13:30:00Z,1993-04-06T20:15:00Z,, 1993-04-07T00:00:00Z,1993-04-07T13:30:00Z,1993-04-07T20:15:00Z,, 1993-04-08T00:00:00Z,1993-04-08T13:30:00Z,1993-04-08T20:15:00Z,, -1993-04-09T00:00:00Z,1993-04-09T13:30:00Z,1993-04-09T20:15:00Z,, 1993-04-12T00:00:00Z,1993-04-12T13:30:00Z,1993-04-12T20:15:00Z,, 1993-04-13T00:00:00Z,1993-04-13T13:30:00Z,1993-04-13T20:15:00Z,, 1993-04-14T00:00:00Z,1993-04-14T13:30:00Z,1993-04-14T20:15:00Z,, @@ -2093,7 +2091,6 @@ 1998-04-07T00:00:00Z,1998-04-07T13:30:00Z,1998-04-07T20:15:00Z,, 1998-04-08T00:00:00Z,1998-04-08T13:30:00Z,1998-04-08T20:15:00Z,, 1998-04-09T00:00:00Z,1998-04-09T13:30:00Z,1998-04-09T20:15:00Z,, -1998-04-10T00:00:00Z,1998-04-10T13:30:00Z,1998-04-10T20:15:00Z,, 1998-04-13T00:00:00Z,1998-04-13T13:30:00Z,1998-04-13T20:15:00Z,, 1998-04-14T00:00:00Z,1998-04-14T13:30:00Z,1998-04-14T20:15:00Z,, 1998-04-15T00:00:00Z,1998-04-15T13:30:00Z,1998-04-15T20:15:00Z,, @@ -2340,7 +2337,6 @@ 1999-03-30T00:00:00Z,1999-03-30T14:30:00Z,1999-03-30T21:15:00Z,, 1999-03-31T00:00:00Z,1999-03-31T14:30:00Z,1999-03-31T21:15:00Z,, 1999-04-01T00:00:00Z,1999-04-01T14:30:00Z,1999-04-01T21:15:00Z,, -1999-04-02T00:00:00Z,1999-04-02T14:30:00Z,1999-04-02T21:15:00Z,, 1999-04-05T00:00:00Z,1999-04-05T13:30:00Z,1999-04-05T20:15:00Z,, 1999-04-06T00:00:00Z,1999-04-06T13:30:00Z,1999-04-06T20:15:00Z,, 1999-04-07T00:00:00Z,1999-04-07T13:30:00Z,1999-04-07T20:15:00Z,, @@ -3607,7 +3603,6 @@ 2004-04-06T00:00:00Z,2004-04-06T13:30:00Z,2004-04-06T20:15:00Z,, 2004-04-07T00:00:00Z,2004-04-07T13:30:00Z,2004-04-07T20:15:00Z,, 2004-04-08T00:00:00Z,2004-04-08T13:30:00Z,2004-04-08T20:15:00Z,, -2004-04-09T00:00:00Z,2004-04-09T13:30:00Z,2004-04-09T20:15:00Z,, 2004-04-12T00:00:00Z,2004-04-12T13:30:00Z,2004-04-12T20:15:00Z,, 2004-04-13T00:00:00Z,2004-04-13T13:30:00Z,2004-04-13T20:15:00Z,, 2004-04-14T00:00:00Z,2004-04-14T13:30:00Z,2004-04-14T20:15:00Z,, @@ -4867,7 +4862,6 @@ 2009-04-07T00:00:00Z,2009-04-07T13:30:00Z,2009-04-07T20:15:00Z,, 2009-04-08T00:00:00Z,2009-04-08T13:30:00Z,2009-04-08T20:15:00Z,, 2009-04-09T00:00:00Z,2009-04-09T13:30:00Z,2009-04-09T20:15:00Z,, -2009-04-10T00:00:00Z,2009-04-10T13:30:00Z,2009-04-10T20:15:00Z,, 2009-04-13T00:00:00Z,2009-04-13T13:30:00Z,2009-04-13T20:15:00Z,, 2009-04-14T00:00:00Z,2009-04-14T13:30:00Z,2009-04-14T20:15:00Z,, 2009-04-15T00:00:00Z,2009-04-15T13:30:00Z,2009-04-15T20:15:00Z,, @@ -5114,7 +5108,6 @@ 2010-03-30T00:00:00Z,2010-03-30T13:30:00Z,2010-03-30T20:15:00Z,, 2010-03-31T00:00:00Z,2010-03-31T13:30:00Z,2010-03-31T20:15:00Z,, 2010-04-01T00:00:00Z,2010-04-01T13:30:00Z,2010-04-01T20:15:00Z,, -2010-04-02T00:00:00Z,2010-04-02T13:30:00Z,2010-04-02T20:15:00Z,, 2010-04-05T00:00:00Z,2010-04-05T13:30:00Z,2010-04-05T20:15:00Z,, 2010-04-06T00:00:00Z,2010-04-06T13:30:00Z,2010-04-06T20:15:00Z,, 2010-04-07T00:00:00Z,2010-04-07T13:30:00Z,2010-04-07T20:15:00Z,, @@ -6374,7 +6367,6 @@ 2015-03-31T00:00:00Z,2015-03-31T13:30:00Z,2015-03-31T20:15:00Z,, 2015-04-01T00:00:00Z,2015-04-01T13:30:00Z,2015-04-01T20:15:00Z,, 2015-04-02T00:00:00Z,2015-04-02T13:30:00Z,2015-04-02T20:15:00Z,, -2015-04-03T00:00:00Z,2015-04-03T13:30:00Z,2015-04-03T20:15:00Z,, 2015-04-06T00:00:00Z,2015-04-06T13:30:00Z,2015-04-06T20:15:00Z,, 2015-04-07T00:00:00Z,2015-04-07T13:30:00Z,2015-04-07T20:15:00Z,, 2015-04-08T00:00:00Z,2015-04-08T13:30:00Z,2015-04-08T20:15:00Z,, @@ -6621,7 +6613,6 @@ 2016-03-22T00:00:00Z,2016-03-22T13:30:00Z,2016-03-22T20:15:00Z,, 2016-03-23T00:00:00Z,2016-03-23T13:30:00Z,2016-03-23T20:15:00Z,, 2016-03-24T00:00:00Z,2016-03-24T13:30:00Z,2016-03-24T20:15:00Z,, -2016-03-25T00:00:00Z,2016-03-25T13:30:00Z,2016-03-25T20:15:00Z,, 2016-03-28T00:00:00Z,2016-03-28T13:30:00Z,2016-03-28T20:15:00Z,, 2016-03-29T00:00:00Z,2016-03-29T13:30:00Z,2016-03-29T20:15:00Z,, 2016-03-30T00:00:00Z,2016-03-30T13:30:00Z,2016-03-30T20:15:00Z,, diff --git a/tests/test_xcbf_calendar.py b/tests/test_xcbf_calendar.py index b0a5e172..1d6af7fd 100644 --- a/tests/test_xcbf_calendar.py +++ b/tests/test_xcbf_calendar.py @@ -21,6 +21,7 @@ def regular_holidays_sample(self): "2016-01-01", # new years: jan 1 "2016-01-18", # mlk: jan 18 "2016-02-15", # presidents: feb 15 + "2016-03-25", # good friday: mar 25 "2016-05-30", # mem day: may 30 "2016-07-04", # independence day: july 4 "2016-09-05", # labor day: sep 5 @@ -39,15 +40,6 @@ def adhoc_holidays_sample(self): "2012-10-30", # - jan 2 2007 ] - @pytest.fixture - def non_holidays_sample(self): - yield [ - # Good Friday is not a holiday when Christas Day or New Year's Day falls - # on a Friday. - "2015-04-03", - "2016-03-25", - ] - @pytest.fixture def early_closes_sample(self): yield ["2016-11-25"]