spotratecurve: Create a SpotRateCurve object

View source: R/spotratecurve-class.R

spotratecurveR Documentation

Create a SpotRateCurve object

Description

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

Usage

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

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

## S3 method for class '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]]

# access the second element
curve[2]

fixedincome documentation built on July 9, 2023, 7:28 p.m.