Skip to contents

Interpolates the zero curve by date and days, returning either a single scalar rate (when date and days are given) or merging a rate column into a surface data frame (df_surf).

Usage

get_rate_for_maturity(df_rate, df_surf = NULL, date = NULL, days = NULL)

Arguments

df_rate

Data frame with date, days, rate (decimal p.a.).

df_surf

Optional surface with date, days. If supplied, returns df_surf with a rate column merged by date/maturity.

date

Optional single Date for scalar interpolation.

days

Optional single integer days-to-maturity for scalar interpolation.

Value

A numeric rate (if date & days are given) or a data frame with a rate column (if df_surf is given).

Examples

# scalar interpolation
one <- subset(qmoms_surface, id == qmoms_surface$id[1] & days == qmoms_surface$days[1])
get_rate_for_maturity(qmoms_zerocd, date = one$date[1], days = one$days[1])
#> [1] 5.696391

# merge into a surface
head(get_rate_for_maturity(qmoms_zerocd, df_surf = qmoms_surface))
#>         date days    id      mnes       prem impl_volatility delta     rate
#> 1 1996-01-04   30 10078 0.8434704 0.19102731        0.846721    80 5.696391
#> 2 1996-01-04   30 10078 0.8532319 0.02774165        0.777861   -20 5.696391
#> 3 1996-01-04   30 10078 0.8791257 0.16572706        0.840091    75 5.696391
#> 4 1996-01-04   30 10078 0.8856444 0.03724119        0.777003   -25 5.696391
#> 5 1996-01-04   30 10078 0.9119773 0.14416711        0.833504    70 5.696391
#> 6 1996-01-04   30 10078 0.9154844 0.04795205        0.779121   -30 5.696391