Learn R Programming

fixedincome (version 0.0.5)

spotratecurve: 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 numeric spotratecurve( x, terms, compounding, daycount, calendar, refdate = Sys.Date(), .copyfrom = NULL, ... )

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

Value

A SpotRateCurve object.

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.

Examples

Run this code
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]

Run the code above in your browser using DataLab