You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法使用RQuantLib与bizdays包时,计算德国特定月份工作日的替代方案求助

无法使用RQuantLib与bizdays包时,计算德国特定月份工作日的替代方案求助

我现在碰到个棘手的问题:需要计算德国特定时间段里的工作日,也就是得排除公共假期、周六和周日。

但我运行代码的环境没办法安装RQuantLib或者bizdays包,之前我是这么实现这个需求的:

#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包,但它覆盖的德国假期很少,甚至还有错误——比如把12月31日当成公共假期,但实际上不是;而且还漏掉了1月1日的假期。

对我来说最关键的是要有一个包含准确德国公共假期的可靠库,有没有合适的替代方案?

备注:内容来源于stack exchange,提问作者Chris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.20 09:09:34