| daycount_frac | R Documentation |
This function computes difference between two dates as year fraction given day count convention.
daycount_frac(d1, d2, convention)
d1 |
an object of |
d2 |
an object of |
convention |
a chacter string determining day count convention to be used, see Details. |
Currently, the following day count conventions are supported:
30/360also 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/360also 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/ACTalso 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/365Falso known as Actual/365 Fixed, described in ISDA 2006 Section 4.16(d). Difference in days between dates divided by 365.
ACT/360also known as Actual/360, described in ISDA 2006 Section 4.16(e). Difference in days between dates divided by 360.
A numeric vector.
International Swaps and Derivatives Association, Inc., 2006 ISDA Definitions, New York, 2006.
year_frac, bizday.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.