diff --git a/.github/config_new_release.yml b/.github/config_new_release.yml index 567ba4d..ecd5535 100644 --- a/.github/config_new_release.yml +++ b/.github/config_new_release.yml @@ -1,8 +1,8 @@ -new_version: '4.0.3' +new_version: '4.1.0' change_log: | - - Enabled tests that failed before PR #215 + - Added UK and Australia holidays for Queen Elizabeth II's State Funeral release_body: | diff --git a/pandas_market_calendars/exchange_calendar_asx.py b/pandas_market_calendars/exchange_calendar_asx.py index 10aa699..0ddffd0 100644 --- a/pandas_market_calendars/exchange_calendar_asx.py +++ b/pandas_market_calendars/exchange_calendar_asx.py @@ -57,3 +57,7 @@ def regular_holidays(self): GoodFriday, EasterMonday, ]) + + @property + def adhoc_holidays(self): + return UniqueCloses diff --git a/pandas_market_calendars/holidays_oz.py b/pandas_market_calendars/holidays_oz.py index d83ce83..007166d 100644 --- a/pandas_market_calendars/holidays_oz.py +++ b/pandas_market_calendars/holidays_oz.py @@ -1,6 +1,6 @@ # OZ Holidays -from pandas import DateOffset +from pandas import DateOffset, Timestamp from pandas.tseries.holiday import ( Holiday, MO, @@ -55,3 +55,11 @@ day=26, observance=next_monday_or_tuesday, ) + + +# One-off holiday additions and removals in Australia + +UniqueCloses = [] + +# National Day of Mourning for Her Majesty the Queen +UniqueCloses.append(Timestamp("2022-09-22", tz='UTC')) diff --git a/pandas_market_calendars/holidays_uk.py b/pandas_market_calendars/holidays_uk.py index c48aa22..138d61e 100644 --- a/pandas_market_calendars/holidays_uk.py +++ b/pandas_market_calendars/holidays_uk.py @@ -165,6 +165,9 @@ UniqueCloses.append(pd.Timestamp("2022-06-02", tz='UTC')) UniqueCloses.append(pd.Timestamp("2022-06-03", tz='UTC')) +# State Funeral of Queen Elizabeth II +UniqueCloses.append(pd.Timestamp("2022-09-19", tz='UTC')) + # Royal Weddings UniqueCloses.append(pd.Timestamp("1973-11-14", tz='UTC')) # Wedding Day of Princess Anne and Mark Phillips UniqueCloses.append(pd.Timestamp("1981-07-29", tz='UTC')) # Wedding Day of Prince Charles and Diana Spencer diff --git a/tests/test_asx_calendar.py b/tests/test_asx_calendar.py index 3e447f7..626d942 100644 --- a/tests/test_asx_calendar.py +++ b/tests/test_asx_calendar.py @@ -1,3 +1,5 @@ +from itertools import chain + import pytz import pandas as pd @@ -34,3 +36,30 @@ def test_2022_holidays(): good_dates = asx.valid_days('2022-01-01', '2022-12-31') for date in ["2022-01-26", "2022-12-25", "2022-12-26"]: assert pd.Timestamp(date, tz='UTC') not in good_dates + + +def test_unique_holidays(): + australia_unique_hols_names = ["QEII_DayOfMourning"] + australia_unique_hols = {i: {"closed": None, "open": None} for i in + australia_unique_hols_names} + + # One-off holiday additions and removals in Australia + + # National Day of Mourning for Her Majesty the Queen + australia_unique_hols["QEII_DayOfMourning"]["closed"] = [pd.Timestamp("2022-09-22")] + + + # Test of closed dates + asx = ASXExchangeCalendar() + # get all the closed dates + closed_days = [australia_unique_hols[k].get('closed') for k in australia_unique_hols] + good_dates = asx.valid_days('1990-01-01', '2022-12-31') + for date in chain.from_iterable(closed_days): + assert pd.Timestamp(date, tz='UTC') not in good_dates + + # Test of open dates + open_days = [australia_unique_hols[k].get('open') for k in australia_unique_hols] + open_days = [i for i in open_days if i] + good_dates = asx.valid_days('1990-01-01', '2022-12-31') + for date in chain.from_iterable(open_days): + assert pd.Timestamp(date, tz='UTC') in good_dates \ No newline at end of file diff --git a/tests/test_lse_calendar.py b/tests/test_lse_calendar.py index ee1448d..3aa86a7 100644 --- a/tests/test_lse_calendar.py +++ b/tests/test_lse_calendar.py @@ -56,6 +56,7 @@ def test_unique_holidays(): england_unique_hols_names = [ "VE_50", "VE_75", "QEII_Jubilee_25", "QEII_Jubilee_50", "QEII_Jubilee_60", + "QEII_StateFuneral", "Royal_Wedding_Anne_1973", "Royal_Wedding_Charles_1981", "Royal_Wedding_William_2011", "3rd_Millennium_Eve", ] @@ -84,6 +85,9 @@ def test_unique_holidays(): england_unique_hols["QEII_Jubilee_60"]["closed"] = [pd.Timestamp("2022-06-02"), pd.Timestamp("2022-06-03")] england_unique_hols["QEII_Jubilee_60"]["open"] = [pd.Timestamp("2022-05-31")] # Spring bank holiday removed + # State Funeral of Queen Elizabeth II + england_unique_hols["QEII_StateFuneral"]["closed"] = [pd.Timestamp("2022-09-19")] + # Royal Weddings # Wedding Day of Princess Anne and Mark Phillips england_unique_hols["Royal_Wedding_Anne_1973"]["closed"] = [pd.Timestamp("1973-11-14")]