spotratecurve() S3 method createas a SpotRateCurve object. It is dispatched for numeric values, that represent spot rates and for SpotRate objects.

spotratecurve(x, terms, ..., refdate = Sys.Date())

# S3 method for numeric
spotratecurve(
  x,
  terms,
  compounding,
  daycount,
  calendar,
  refdate = Sys.Date(),
  .copyfrom = NULL,
  ...
)

# S3 method for SpotRate
spotratecurve(x, terms, refdate = Sys.Date(), .copyfrom = NULL, ...)

Arguments

x

a numeric representing a spot rate value or a SpotRate object.

terms

a numeric vector with positive values representing the days of the term structure.

...

additional arguments

refdate

the curve reference date.

compounding

a character with the compouning name.

daycount

a character representing the daycount.

calendar

a calendar object.

.copyfrom

a SpotRate object that is used as reference to build the SpotRateCurve object.

Value

A SpotRateCurve object.

Examples

terms <- c(1, 11, 26, 27, 28)
rates <- c(0.0719, 0.056, 0.0674, 0.0687, 0.07)

curve <- spotratecurve(rates, terms, "discrete", "actual/365", "actual")

# access the term 11 days
curve[[11]]
#>         SpotRateCurve
#> 11 days         0.056
#> discrete actual/365 actual 
#> Reference date: 2023-06-27 

# access the second element
curve[2]
#>         SpotRateCurve
#> 11 days         0.056
#> discrete actual/365 actual 
#> Reference date: 2023-06-27