Learn R Programming

RQuantLib (version 0.3.4)

yearFraction: DayCounter functions from QuantLib

Description

The yearFraction function returns year fraction between two dates given a day counter Enum

Usage

yearFraction(startDates, endDates, dayCounters)

Arguments

startDates
A vector of Date type.
endDates
A vector of Date type.
dayCounters
A vector of numeric type. See Enum

Value

  • A numeric vector contains year fractions between two dates from the input.

Details

The day counters are coming from QuantLib, and the QuantLib documentation should be consulted for details. See Enum and http://quantlib.org/reference/class_quant_lib_1_1_day_counter.html

References

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

Examples

Run this code
startDates <- seq(from=as.Date("2009-04-07"), to=as.Date("2009-04-14"),
by=1)
endDates <- seq(from=as.Date("2009-11-07"), to=as.Date("2009-11-14"), by=1)
dayCounters <- c(0,1,2,3,4,5,6,1)
yearFraction(startDates, endDates, dayCounters)

Run the code above in your browser using DataLab