inst/examples/allUScalendars.R

suppressMessages({
    library(qlcal) 		# holiday calculation
    library(xts)        # to glue day-indexed time series via cbind
})

## returns an xts series for given (US) holiday in current year
makeHol <- function(cal) {
    setCalendar(paste0("UnitedStates/", cal))
    hols <- getHolidays(as.Date(format(Sys.Date(), "%Y-01-01")),
                        as.Date(format(Sys.Date(), "%Y-12-31")))
    x <- xts(rep(TRUE, length(hols)), order.by=hols)
    colnames(x) <- cal
    x
}

## see R/calendars.R in qlcal, we prepend 'UnitedStates/' in makeHol()
cals <- c("LiborImpact", "NYSE", "GovernmentBond", "NERC", "FederalReserve", "SOFR")
print(Reduce(cbind, Map(makeHol, cals)))

Try the qlcal package in your browser

Any scripts or data that you put into this service are public.

qlcal documentation built on June 8, 2025, 1:48 p.m.