The packages RQuantLib and timeDate (Rmetrics) have functions to compute business days between 2 dates according to a predefined calendar. bizdays creates calendars based on these functions.

load_quantlib_calendars(ql_calendars = NULL, from, to, financial = TRUE)

load_rmetrics_calendars(year, financial = TRUE)

Arguments

ql_calendars

(QuantLib only) A character vector with the names of QuantLib's calendars. This parameter defaults to NULL, which loads all calendars.

from

(QuantLib only) the start date

to

(QuantLib only) the end date

financial

is a logical argument that defaults to TRUE.

year

(timeDate Rmetrics only) a vector with years to create the calendars.

Details

To load QuantLib's calendars use load_quantlib_calendars defining which calendar has to be loaded by its name and the range of dates the calendar has to handle. All QuantLib calendars have the QuantLib prefix.

To load Rmetrics' calendars use load_rmetrics_calendars defining the years the calendar has to handle. All Rmetrics calendars have the Rmetrics prefix.

Financial calendars

This argument defines the calendar as a financial or a non financial calendar. Financial calendars don't consider the ending business day when counting working days in bizdays. In QuantLib, Financial calendars are those that includeLast is set to FALSE.

List of calendars

QuantLib Calendars:

  • QuantLib/TARGET

  • QuantLib/Argentina

  • QuantLib/Australia

  • QuantLib/Brazil

  • QuantLib/Canada

  • QuantLib/Canada/Settlement

  • QuantLib/Canada/TSX

  • QuantLib/China

  • QuantLib/CzechRepublic

  • QuantLib/Denmark

  • QuantLib/Finland

  • QuantLib/Germany

  • QuantLib/Germany/FrankfurtStockExchange

  • QuantLib/Germany/Settlement

  • QuantLib/Germany/Xetra

  • QuantLib/Germany/Eurex

  • QuantLib/HongKong

  • QuantLib/Hungary

  • QuantLib/Iceland

  • QuantLib/India

  • QuantLib/Indonesia

  • QuantLib/Italy

  • QuantLib/Italy/Settlement

  • QuantLib/Italy/Exchange

  • QuantLib/Japan

  • QuantLib/Mexico

  • QuantLib/NewZealand

  • QuantLib/Norway

  • QuantLib/Poland

  • QuantLib/Russia

  • QuantLib/SaudiArabia

  • QuantLib/Singapore

  • QuantLib/Slovakia

  • QuantLib/SouthAfrica

  • QuantLib/SouthKorea

  • QuantLib/SouthKorea/KRX

  • QuantLib/Sweden

  • QuantLib/Switzerland

  • QuantLib/Taiwan

  • QuantLib/Turkey

  • QuantLib/Ukraine

  • QuantLib/UnitedKingdom

  • QuantLib/UnitedKingdom/Settlement

  • QuantLib/UnitedKingdom/Exchange

  • QuantLib/UnitedKingdom/Metals

  • QuantLib/UnitedStates

  • QuantLib/UnitedStates/Settlement

  • QuantLib/UnitedStates/NYSE

  • QuantLib/UnitedStates/GovernmentBond

  • QuantLib/UnitedStates/NERC

Rmetrics Calendars:

  • Calendar Rmetrics/LONDON

  • Calendar Rmetrics/NERC

  • Calendar Rmetrics/NYSE

  • Calendar Rmetrics/TSX

  • Calendar Rmetrics/ZURICH

Examples

if (require("RQuantLib")) {
  # loading Argentina calendar
  load_quantlib_calendars("Argentina",
    from = "2016-01-01",
    to = "2016-12-31"
  )
  bizdays("2016-01-01", "2016-03-14", "QuantLib/Argentina")
  # loading 2 calendars
  load_quantlib_calendars(c("UnitedStates/NYSE", "UnitedKingdom/Settlement"),
    from = "2016-01-01", to = "2016-12-31"
  )
  bizdays("2016-01-01", "2016-03-14", "QuantLib/UnitedStates/NYSE")
  # loading all QuantLib's 50 calendars
  load_quantlib_calendars(from = "2016-01-01", to = "2016-12-31")
  bizdays("2016-01-01", "2016-03-14", "QuantLib/Brazil")
}
#> Loading required package: RQuantLib
#> Calendar QuantLib/Argentina loaded
#> Calendar QuantLib/UnitedStates/NYSE loaded
#> Calendar QuantLib/UnitedKingdom/Settlement loaded
#> Calendar QuantLib/TARGET loaded
#> Calendar QuantLib/Argentina loaded
#> Calendar QuantLib/Australia loaded
#> Calendar QuantLib/Brazil loaded
#> Calendar QuantLib/Canada loaded
#> Calendar QuantLib/Canada/Settlement loaded
#> Calendar QuantLib/Canada/TSX loaded
#> Calendar QuantLib/China loaded
#> Calendar QuantLib/CzechRepublic loaded
#> Calendar QuantLib/Denmark loaded
#> Calendar QuantLib/Finland loaded
#> Calendar QuantLib/Germany loaded
#> Calendar QuantLib/Germany/FrankfurtStockExchange loaded
#> Calendar QuantLib/Germany/Settlement loaded
#> Calendar QuantLib/Germany/Xetra loaded
#> Calendar QuantLib/Germany/Eurex loaded
#> Calendar QuantLib/HongKong loaded
#> Calendar QuantLib/Hungary loaded
#> Calendar QuantLib/Iceland loaded
#> Calendar QuantLib/India loaded
#> Calendar QuantLib/Indonesia loaded
#> Calendar QuantLib/Italy loaded
#> Calendar QuantLib/Italy/Settlement loaded
#> Calendar QuantLib/Italy/Exchange loaded
#> Calendar QuantLib/Japan loaded
#> Calendar QuantLib/Mexico loaded
#> Calendar QuantLib/NewZealand loaded
#> Calendar QuantLib/Norway loaded
#> Calendar QuantLib/Poland loaded
#> Calendar QuantLib/Russia loaded
#> Calendar QuantLib/SaudiArabia loaded
#> Calendar QuantLib/Singapore loaded
#> Calendar QuantLib/Slovakia loaded
#> Calendar QuantLib/SouthAfrica loaded
#> Calendar QuantLib/SouthKorea loaded
#> Calendar QuantLib/SouthKorea/KRX loaded
#> Calendar QuantLib/Sweden loaded
#> Calendar QuantLib/Switzerland loaded
#> Calendar QuantLib/Taiwan loaded
#> Calendar QuantLib/Turkey loaded
#> Calendar QuantLib/Ukraine loaded
#> Calendar QuantLib/UnitedKingdom loaded
#> Calendar QuantLib/UnitedKingdom/Settlement loaded
#> Calendar QuantLib/UnitedKingdom/Exchange loaded
#> Calendar QuantLib/UnitedKingdom/Metals loaded
#> Calendar QuantLib/UnitedStates loaded
#> Calendar QuantLib/UnitedStates/Settlement loaded
#> Calendar QuantLib/UnitedStates/NYSE loaded
#> Calendar QuantLib/UnitedStates/GovernmentBond loaded
#> Calendar QuantLib/UnitedStates/NERC loaded
#> [1] 48

if (require("timeDate")) {
  # loading all Rmetrics calendar
  load_rmetrics_calendars(2016)
  bizdays("2016-01-01", "2016-03-14", "Rmetrics/NERC")
  bizdays("2016-01-01", "2016-03-14", "Rmetrics/NYSE")
}
#> Loading required package: timeDate
#> 
#> Attaching package: ‘timeDate’
#> The following objects are masked from ‘package:RQuantLib’:
#> 
#>     isHoliday, isWeekend
#> Calendar Rmetrics/LONDON loaded
#> Calendar Rmetrics/NERC loaded
#> Calendar Rmetrics/NYSE loaded
#> Calendar Rmetrics/TSX loaded
#> Calendar Rmetrics/ZURICH loaded
#> [1] 48