I have an issue calculating business days in Germany in a specific time frame. Meaning, I want to exclude public holidays, Saturday and Sunday. I cannot use RQuantLib or bizdays packages as they cannot be installed on the instance where I run the code. Is there an alternative to this:
#Calculate workdays
load_quantlib_calendars("Germany", from="2022-01-01", to="2026-01-01")
final_df <- final_df %>%
mutate(first_day = as.Date(paste0(as.numeric(format(Sys.Date(), "%Y")), "-", `Calendar month` ,"-01")),
last_day = ceiling_date(as.Date(paste0(as.numeric(format(Sys.Date(), "%Y")), "-", `Calendar month` ,"-01")),
unit = "month",
change_on_boundary = TRUE)-1,
`Workdays month Act` = bizdays(first_day, last_day, "QuantLib/Germany"),
`Workdays month PY` = bizdays(first_day-years(1), last_day-years(1), "QuantLib/Germany"))%>%
select(-first_day, -last_day)`
timeDate package seems to cover only a few German holidays and even some of them are wrong e.g. 31st December is not public holiday and 1.1. is missing.
So important for me is that there is a proper library with the holidays.
To get holidays without a package, we can use a free API https://date.nager.at/Api (and
httr
).You can then use these dates to exclude days in your counting.