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] "2024-12-04"
AddBusinessDays(date = '2020-10-03',numDate = 15,loc = 'NY')
#> [1] "2020-10-23"
AddBusinessDays(date = Sys.Date(),numDate = 15,loc = 'BOG')
#> [1] "2024-12-03"
AddBusinessDays(date = Sys.Date(),numDate = 15,loc = 'LDN')
#> [1] "2024-12-03"
BusinessDays(loc='BOG')[2500:2520]
#> [1] "2000-03-15" "2000-03-16" "2000-03-17" "2000-03-21" "2000-03-22"
#> [6] "2000-03-23" "2000-03-24" "2000-03-27" "2000-03-28" "2000-03-29"
#> [11] "2000-03-30" "2000-03-31" "2000-04-03" "2000-04-04" "2000-04-05"
#> [16] "2000-04-06" "2000-04-07" "2000-04-10" "2000-04-11" "2000-04-12"
#> [21] "2000-04-13"
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