Description Usage Arguments Details Value Author(s) Source References Examples
View source: R/CountingDates.R
Function to count the number of years between two dates according to the given convention.
1 | day_count(tfinal, tinitial, convention = "ACT/365")
|
tfinal |
Final date. |
tinitial |
Initial date. |
convention |
Character that specifies the convention. See details. |
The convention accepts the following values:
30/360.
DayCount = (360*(Y_2-Y_1)+30*(M_2-M_1) + (D_2-D_1))/360
Here the dates are in the following format
tfinal = Y_2-M_2-D_2 (YYYY-MM-DD).
tinitial = Y_1-M_1-D_1 (YYYY-MM-DD).
It is important to note that
D_1=\min(D_1,30)
If D_1=30 then D_2=\min(D_2,30)
ACT/365 (Default).
DayCount = \frac{Days(tintial, tfinal)}{365}
Also known as ACT/365 Fixed.
ACT/360.
DayCount = \frac{Days(tintial, tfinal)}{365}
ACT/365L.
DayCount = \frac{Days(tintial, tfinal)}{DiY}
If February 29 is in the range from Date1 (exclusive) to Date2 (inclusive), then DiY = 366, else DiY = 365.
NL/365.
If February 29 is not in the period then actual number of days between dates is used. Else actual number of days minus 1 is used. Day count basis = 365.
ACT/ACT-ISDA.
DayCount = \frac{Days\; not\; in\; leap\; year}{365} + \frac{Days\; in\; leap\; year}{366}
ACT/ACT-AFB.
DayCount = \frac{Days(tintial, tfinal)}{DiY}
The basic rule is that if February 29 is in the range from Date1 (inclusive) to Date2 (exclusive), then DiY = 366, else DiY = 365.
If the period from Date1 to Date2 is more than one year, the calculation is split into two parts:
The number of complete years, counted back from the last day of the period.
The remaining initial stub, calculated using the basic rule.
Number of years between the specified dates according to the convention.
Julian Chitiva
International Swaps and Derivatives Association - ISDA.
International Swaps and Derivatives Association. (2006). 2006 ISDA definitions. New York, N.Y: International Swaps and Derivatives Association.
1 2 3 4 5 6 7 | #Function accepts Dates as Dates or as characters.
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/365')
day_count(tfinal=as.Date('2023-03-08'),tinitial=as.Date('2019-02-28'),convention='ACT/360')
day_count(tfinal='2023-03-08',tinitial=as.Date('2019-02-28'),convention='30/360')
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='NL/365')
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/ACT-ISDA')
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/ACT-AFB')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.