interpolate_rfr: Calculate risk-free-rates through cubic-spline interpolation...

interpolate_rfrR Documentation

Calculate risk-free-rates through cubic-spline interpolation using constant maturity treasury (CMT) rates data.

Description

According to the 2019 VIX whitepaper, "the risk-free interest rates, R1 and R2, are yields based on U.S. Treasury yield curve rates (commonly referred to as "Constant Maturity Treasury", rates or CMTs), to which a cubic spline is applied to derive yields on the expiration dates of relevant SPX options. As such, the VIX Index calculation may use different risk-free interest rates for near- and next-term options. Note in this example, T2 uses a value of 900 for Settlement day, which reflects the 4:00 p.m. ET expiration time of the next-term SPX Weeklys options."

Usage

interpolate_rfr(cmt_data = NULL, date, exp, ret_table = F)

Arguments

cmt_data

A data.table containing CMT quotes. See cmt_dataset for an example and scrape_cmt_data for a way to obtain it.

date

A date vector of starting dates.

exp

A date vector of expiration dates.

ret_table

Logical scalar, indicating whether to return only the risk free rate(s) or a table with the original date, exp and the corresponding risk-free-rates

Value

Returns either a numeric vector of risk free rates or a data.table containing:

  • date(date) - the provided starting dates

  • exp (date) - the provided expiration dates

  • R (numeric) - the corresponding risk-free interest rates in decimal

Examples


## Using internal package data
library(lubridate)

## Single values
interpolate_rfr(date = ymd("2020-01-02"), exp = date("2020-03-02"))


## Multiple values
dates <- ymd("2020-01-06") + days(1:4)
exps <-  ymd("2020-03-02") + days(1:4)

interpolate_rfr(date = dates, exp = exps)

## With output table
interpolate_rfr(date = dates, exp = exps, ret_table = TRUE)


m-g-h/R.MFIV documentation built on July 4, 2022, 3:35 a.m.