
Interpolate a zero rate for a given maturity (or merge rates into a surface)
Source:R/qmoms_utils.R
get_rate_for_maturity.Rd
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
).
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