Skip to content

Commit

Permalink
fixes USGovernmentBond calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
felipenoris committed Mar 8, 2023
1 parent 63c6c9d commit 69da78a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/calendars/us.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function isholiday(::USGovernmentBond , dt::Dates.Date)
adjustweekendholidayUS(findweekday(Dates.Monday, yy, 2, 3, true)) == dt
||
# Good Friday
dt_rata == ( e_rata - 2 )
yy != 2023 && dt_rata == ( e_rata - 2 )
||
# Memorial Day
adjustweekendholidayUS(findweekday(Dates.Monday, yy, 5, 1, false)) == dt
Expand All @@ -220,7 +220,7 @@ function isholiday(::USGovernmentBond , dt::Dates.Date)
adjustweekendholidayUS(findweekday(Dates.Monday, yy, 10, 2, true)) == dt
||
# Veterans Day
adjustweekendholidayUS(Dates.Date(yy, 11, 11)) == dt
yy != 2023 && adjustweekendholidayUS(Dates.Date(yy, 11, 11)) == dt
||
# Thanksgiving Day
adjustweekendholidayUS(findweekday(Dates.Thursday, yy, 11, 4, true)) == dt
Expand Down
54 changes: 54 additions & 0 deletions test/calendar_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,60 @@ test_bdays(:WeekendsOnly, (2019, 8, 23), (2019, 8, 24), 1)
@test isbday(hc_usgovbond, Dates.Date(2013, 03, 29)) == false # good friday
@test isbday(hc_usgovbond, Dates.Date(2013, 03, 30)) == false # saturday

# 2022

@test BusinessDays.listholidays(BusinessDays.USGovernmentBond(), Dates.Date(2022, 1, 1), Dates.Date(2023, 1, 1)) == Dates.Date.([
"2022-01-17", # Martin Luther King Day
"2022-02-21", # Presidents Day
"2022-04-15", # Good Friday
"2022-05-30", # Memorial Day
"2022-06-20", # Juneteenth
"2022-07-04", # U.S. Independence Day
"2022-09-05", # Labor Day
"2022-10-10", # Columbus Day
"2022-11-11", # Veterans Day
"2022-11-24", # Thanksgiving Day
"2022-12-26", # Christmas Day
])

# 2023

@test BusinessDays.listholidays(BusinessDays.USGovernmentBond(), Dates.Date(2023, 1, 1), Dates.Date(2023, 12, 31)) == Dates.Date.([
"2023-01-02", # New Year's Day 2022/2023
"2023-01-16", # Martin Luther King Day
"2023-02-20", # Presidents Day
"2023-05-29", # Memorial Day
"2023-06-19", # Juneteenth
"2023-07-04", # U.S. Independence Day
"2023-09-04", # Labor Day
"2023-10-09", # Columbus Day
"2023-11-23", # Thanksgiving Day
"2023-12-25", # Christmas Day
])

@test isbday(hc_usgovbond, Dates.Date(2023, 4, 7)) # Early Close is recommended rather than a close to accommodate the release of US employment data

# 2024

@test BusinessDays.listholidays(BusinessDays.USGovernmentBond(), Dates.Date(2024, 1, 1), Dates.Date(2024, 12, 31)) == Dates.Date.([
"2024-01-01", # New Year’s
"2024-01-15", # Martin Luther King Day
"2024-02-19", # Presidents Day
"2024-03-29", # Good Friday
"2024-05-27", # Memorial Day
"2024-06-19", # Juneteenth
"2024-07-04", # U.S. Independence Day
"2024-09-02", # Labor Day
"2024-10-14", # Columbus Day
"2024-11-11", # Veterans Day
"2024-11-28", # Thanksgiving Day
"2024-12-25", # Christmas Day
])

# 2025

@test !isbday(hc_usgovbond, Dates.Date(2025, 01, 1)) # New Year's Day

# Symbol
@test isbday(:USGovernmentBond, Dates.Date(2015, 12, 24)) == true
@test isbday(:USGovernmentBond, Dates.Date(2015, 12, 25)) == false # Christmas - Friday
Expand Down

0 comments on commit 69da78a

Please sign in to comment.