This package is a R library that provides the user to work with dates and days count for financial analysis. It works with business days from New York (US), London (UK) and Bogota (CO). It also implements day counting using common financial conventions such as ACT/360, ACT/365, ACT/ACT and 30/360, among others.
This part implement functions for dates manipulation such as add days (business days) to a date, transform dates between various formats and obtain business days for a given city calendar.
AddBusinessDays(date = Sys.Date(),numDate = 15,loc = 'NY')
#> [1] "2020-06-26"
AddBusinessDays(date = '2020-10-03',numDate = 15,loc = 'NY')
#> [1] "2020-10-26"
AddBusinessDays(date = Sys.Date(),numDate = 15,loc = 'BOG')
#> [1] "2020-07-01"
AddBusinessDays(date = Sys.Date(),numDate = 15,loc = 'LDN')
#> [1] "2020-06-26"
BusinessDays(loc='BOG')[2500:2520]
#> [1] "2021-03-26" "2021-03-29" "2021-03-30" "2021-03-31" "2021-04-05"
#> [6] "2021-04-06" "2021-04-07" "2021-04-08" "2021-04-09" "2021-04-12"
#> [11] "2021-04-13" "2021-04-14" "2021-04-15" "2021-04-16" "2021-04-19"
#> [16] "2021-04-20" "2021-04-21" "2021-04-22" "2021-04-23" "2021-04-26"
#> [21] "2021-04-27"
BusinessDays(loc='BOG', from='2020-10-10', to='2020-11-10')
#> [1] "2020-10-13" "2020-10-14" "2020-10-15" "2020-10-16" "2020-10-19"
#> [6] "2020-10-20" "2020-10-21" "2020-10-22" "2020-10-23" "2020-10-26"
#> [11] "2020-10-27" "2020-10-28" "2020-10-29" "2020-10-30" "2020-11-03"
#> [16] "2020-11-04" "2020-11-05" "2020-11-06" "2020-11-09" "2020-11-10"
This section shows the usage of day count functions.
difftime_leap_year(tfinal='2023-03-05',tinitial='2019-02-28',leapDatesIn=TRUE)
#> [1] 1466
difftime_leap_year(tfinal=as.Date('2023-03-05'),tinitial=as.Date('2019-02-28'),leapDatesIn=TRUE)
#> [1] 1466
difftime_leap_year(tfinal='2023-03-05',tinitial='2019-02-28',leapDatesIn=FALSE)
#> [1] 1465
difftime_leap_year(tfinal='2023-03-05',tinitial=as.Date('2019-02-28'),leapDatesIn=FALSE)
#> [1] 1465
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/365')
#> [1] 4.024658
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/360')
#> [1] 4.080556
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='30/360')
#> [1] 4.027778
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='NL/365')
#> [1] 4.021918
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/ACT-ISDA')
#> [1] 4.024658
day_count(tfinal='2023-03-08',tinitial='2019-02-28',convention='ACT/ACT-AFB')
#> [1] 4.019178