daycount_frac: Differences Between Dates as Year Fractions / Accrual Factors

View source: R/business.R

daycount_fracR Documentation

Differences Between Dates as Year Fractions / Accrual Factors

Description

This function computes difference between two dates as year fraction given day count convention.

Usage

daycount_frac(d1, d2, convention)

Arguments

d1

an object of tind class representing start date(s) or an R object coercible to it.

d2

an object of tind class representing end date(s) or an R object coercible to it.

convention

a chacter string determining day count convention to be used, see Details.

Details

Currently, the following day count conventions are supported:

30/360

also known as 30/360 Bond Basis or 360/360, described in ISDA 2006 Section 4.16(f). The formula is as follows:

\frac{360(y_2-y_1) + 30(m_2-m_1) + (d_2-d_1)}{360},

where y denotes year, m month, d day of month. Dates are adjusted accoring to the following rules: if d_1 is 31, it is changed to 30, if d_2 is 31 and d_1 is 30 or 31, d_2 is changed to 30.

30E/360

also known as Eurobond basis, 30/360 ICMA or 30/360 ISMA, described in ICMA Rule 251.1(ii), 251.2 and ISDA 2006 Section 4.16(g). The formula used is the same as above but the adjustment of dates is different: if d_1 or d_2 is 31, it is changed to 30.

ACT/ACT

also known as Actual/Actual and Actual/Actual ISDA, described in ISDA 2006 Section 4.16(b). Days between the dates (start included, end excluded) are divided into two groups: falling in leap and non-leap years. The number of days in leap years is divided by 366, the number of days in non-leap years is divided by 365. Finally, the two fractions are added.

ACT/365F

also known as Actual/365 Fixed, described in ISDA 2006 Section 4.16(d). Difference in days between dates divided by 365.

ACT/360

also known as Actual/360, described in ISDA 2006 Section 4.16(e). Difference in days between dates divided by 360.

Value

A numeric vector.

References

International Swaps and Derivatives Association, Inc., 2006 ISDA Definitions, New York, 2006.

See Also

year_frac, bizday.

Examples

daycount_frac("2023-01-29", "2023-03-31", "30/360")
1/6 + 2/360
daycount_frac("2023-01-29", "2023-03-31", "30E/360")
1/6 + 1/360
daycount_frac("2023-01-29", "2023-03-31", "ACT/ACT")
61 / 365
daycount_frac("2024-01-29", "2024-03-31", "ACT/ACT")
62 / 366
daycount_frac("2023-01-29", "2023-03-31", "ACT/365F")
61 / 365
daycount_frac("2024-01-29", "2024-03-31", "ACT/365F")
62 / 365
daycount_frac("2023-01-29", "2023-03-31", "ACT/360")
61 / 360
daycount_frac("2024-01-29", "2024-03-31", "ACT/360")
62 / 360


tind documentation built on Dec. 28, 2025, 1:06 a.m.