Skip to content

Commit

Permalink
Merge pull request #226 from rsheftel/dev
Browse files Browse the repository at this point in the history
v4.1
  • Loading branch information
Stryder-Git authored Oct 8, 2022
2 parents f7a5f87 + a6b4769 commit 65bcb9a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/config_new_release.yml
Original file line number Diff line number Diff line change
@@ -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: |
Expand Down
4 changes: 4 additions & 0 deletions pandas_market_calendars/exchange_calendar_asx.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ def regular_holidays(self):
GoodFriday,
EasterMonday,
])

@property
def adhoc_holidays(self):
return UniqueCloses
10 changes: 9 additions & 1 deletion pandas_market_calendars/holidays_oz.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OZ Holidays

from pandas import DateOffset
from pandas import DateOffset, Timestamp
from pandas.tseries.holiday import (
Holiday,
MO,
Expand Down Expand Up @@ -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'))
3 changes: 3 additions & 0 deletions pandas_market_calendars/holidays_uk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions tests/test_asx_calendar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from itertools import chain

import pytz
import pandas as pd

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions tests/test_lse_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit 65bcb9a

Please sign in to comment.