You can coerce objects to the InterestRate
class using this method.
as_InterestRate(x, ...) # S3 method for DiscountFactor as_InterestRate(x, compounding, day_basis, ...) # S3 method for InterestRate as_InterestRate(x, compounding = NULL, day_basis = NULL, ...)
x | object to coerce |
---|---|
... | other parameters passed to methods |
compounding | a numeric vector representing the compounding frequency. |
day_basis | a character vector representing the day basis associated
with the interest rate (see |
an InterestRate
object
library("lubridate") as_InterestRate(DiscountFactor(0.95, ymd(20130101), ymd(20140101)), compounding = 2, day_basis = "act/365")#> <InterestRate> 5.19567%, SEMI-ANNUAL, ACT/365as_InterestRate(InterestRate(c(0.04, 0.05), c(2, 4), 'act/365'), compounding = 4, day_basis = 'act/365')#> <InterestRate> 3.980198%, QUARTERLY, ACT/365 #> <InterestRate> 5.000000%, QUARTERLY, ACT/365