Learn R Programming

RQuantLib (version 0.3.4)

adjust: Calendar functions from QuantLib

Description

The adjust function evaluates the given dates in the context of the given calendar, and returns a vector that adjusts each input dates to the appropriate near business day with respect to the given convention. .

Usage

adjust(calendar="TARGET", dates=Sys.Date(), bdc = 0)

Arguments

calendar
A string identifying one of the supported QuantLib calendars, see Details for more
dates
A vector (or scalar) of Date types.
bdc
business day convention. By default, this value is 0 and correspond to Following convention

Value

  • An named vector of dates. The element names are the dates (formatted as text in yyyy-mm-dd format).

Details

The calendars are coming from QuantLib, and the QuantLib documentation should be consulted for details.

Currently, the following strings are recognised: TARGET (a default calendar), Canada and Canada/Settlement, Canada/TSX, Germany and Germany/FrankfurtStockExchange, Germany/Settlement, Germany/Xetra, Germany/Eurex, Italy and Italy/Settlement, Italy/Exchange, Japan, UnitedKingdom and UnitedKingdom/Settlement, UnitedKingdom/Exchange, UnitedKingdom/Metals, UnitedStates and UnitedStates/Settlement, UnitedStates/NYSE, UnitedStates/GovernmentBond, UnitedStates/NERC.

(In case of multiples entries per country, the country default is listed right after the country itself. Using the shorter form is equivalent.)

References

http://quantlib.org for details on QuantLib.

Examples

Run this code
dates <- seq(from=as.Date("2009-04-07"), to=as.Date("2009-04-14"), by=1)
  adjust("UnitedStates", dates)
  adjust("UnitedStates/Settlement", dates)      ## same as previous
  adjust("UnitedStates/NYSE", dates)            ## stocks
  adjust("UnitedStates/GovernmentBond", dates)  ## bonds
  adjust("UnitedStates/NERC", dates)            ## energy

Run the code above in your browser using DataLab