Skip to content

Commit

Permalink
BUG: Fix christmas early closes to work around 1945/1956 Christmas cl…
Browse files Browse the repository at this point in the history
…osings
  • Loading branch information
Gerry Manoim committed Dec 23, 2020
1 parent 875de03 commit 6f06484
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
8 changes: 6 additions & 2 deletions trading_calendars/exchange_calendar_cmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
from .us_holidays import (
USNewYearsDay,
Christmas,
ChristmasEveBefore1993,
ChristmasEveBefore1945,
ChristmasEveBefore1946To1955,
ChristmasEveAfter1957Before1993,
ChristmasEveInOrAfter1993,
USBlackFridayInOrAfter1993,
USNationalDaysofMourning,
Expand Down Expand Up @@ -102,7 +104,9 @@ def special_closes(self):
USIndependenceDay,
USThanksgivingDay,
USBlackFridayInOrAfter1993,
ChristmasEveBefore1993,
ChristmasEveBefore1945,
ChristmasEveBefore1946To1955,
ChristmasEveAfter1957Before1993,
ChristmasEveInOrAfter1993,
])
)]
13 changes: 10 additions & 3 deletions trading_calendars/exchange_calendar_xnys.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
August45VictoryOverJapan,
Christmas,
ChristmasBefore1954,
ChristmasEveBefore1993,
ChristmasEveBefore1945,
ChristmasEveBefore1946To1955,
ChristmasEveAfter1957Before1993,
ChristmasEveInOrAfter1993,
ChristmasEvesAdhoc,
DayAfterChristmasAdhoc,
Expand Down Expand Up @@ -235,7 +237,12 @@ def special_closes(self):
(
time(14),
HolidayCalendar(
[ChristmasEveBefore1993, USBlackFridayBefore1993, ]
[
ChristmasEveBefore1945,
ChristmasEveBefore1946To1955,
ChristmasEveAfter1957Before1993,
USBlackFridayBefore1993,
]
),
),
]
Expand All @@ -246,7 +253,7 @@ def special_closes_adhoc(self):
(
self.regular_early_close,
DatetimeIndex(
["1997-12-26", "1999-12-31", "2003-12-26", ], tz=UTC,
["1997-12-26", "1999-12-31", "2003-12-26"], tz=UTC,
),
)
]
22 changes: 20 additions & 2 deletions trading_calendars/us_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,29 @@ def following_tuesday_every_four_years_observance(dt):

# These have the same definition, but are used in different places because the
# NYSE closed at 2:00 PM on Christmas Eve until 1993.
ChristmasEveBefore1993 = Holiday(
ChristmasEveBefore1945 = Holiday(
"Christmas Eve",
month=12,
day=24,
end_date=Timestamp("1993-01-01"),
end_date=Timestamp("1945-12-01"),
# When Christmas is a Saturday, the 24th is a full holiday.
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY),
)
ChristmasEveBefore1946To1955 = Holiday(
"Christmas Eve",
month=12,
day=24,
start_date=Timestamp("1946-01-01"),
end_date=Timestamp("1956-01-01"),
# When Christmas is a Saturday, the 24th is a full holiday.
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY),
)
ChristmasEveAfter1957Before1993 = Holiday(
"Christmas Eve",
month=12,
day=24,
start_date=Timestamp("1957-01-01"),
end_date=Timestamp("1992-12-31"),
# When Christmas is a Saturday, the 24th is a full holiday.
days_of_week=(MONDAY, TUESDAY, WEDNESDAY, THURSDAY),
)
Expand Down

1 comment on commit 6f06484

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 6f06484 Previous: b25c4f9 Ratio
etc/bench.py::test_calendar_construction 0.04599716412285718 iter/sec (stddev: 0.09672810454311268) 0.0571218580856847 iter/sec (stddev: 0.026720020782416438) 1.24
etc/bench.py::test_is_open_on_minute 23020.083960545846 iter/sec (stddev: 0.00006283216277322443) 26713.671115999237 iter/sec (stddev: 0.0000030959317537669576) 1.16

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.