fmbasics (version 0.3.0)

as_InterestRate: Coerce to InterestRate

Description

You can coerce objects to the InterestRate class using this method.

Usage

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, ...)

Arguments

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 fmdates::year_frac())

Value

an InterestRate object

Examples

Run this code
# NOT RUN {
library("lubridate")
as_InterestRate(DiscountFactor(0.95, ymd(20130101), ymd(20140101)),
  compounding = 2, day_basis = "act/365")
as_InterestRate(InterestRate(c(0.04, 0.05), c(2, 4), 'act/365'),
  compounding = 4, day_basis = 'act/365')
# }

Run the code above in your browser using DataCamp Workspace