yearfrac: Duration Between Two Dates in Fractional Year Terms

Description Usage Arguments Value Examples

Description

Evaluates the duration between date1 and date2 in fractional year terms via the provided day count convention. For the 30/360 day count convention, it is assumed that there are 30 days in a month. If the bond is EOM, which is available only for the 30/360 day count convention, in a regular year the 3 days between February 28 and March 1 is assigned to February, otherwise to March. In a leap year, only 2 days is assigned to February for EOM. If the eom parameter is set to TRUE, then two additional rules will apply to EOM February dates to achieve the aforementioned behavior.

Usage

1
yearfrac(date1, date2, conv = "Act/Act", eom = FALSE)

Arguments

date1

starting date

date2

ending date

conv

the day count convention can be either "30/360", "Act/365", or "Act/Act" (default)

eom

option to assign additional days to February for the 30/360 day count convention

Value

fractional years between date1 and date2

Examples

1
2
3
4
d1 <- as.Date(c("2004-02-25","2003-02-28")
d2 <- as.Date(c("2015-01-01","2015-08-08")
yearfrac(d1, d2, conv = "30/360")
yearfrac(d1, d2, conv = "30/360", eom = TRUE)

Tsunamical28/mdpr documentation built on May 9, 2019, 5:15 p.m.