| Title: | Yield Curve Fitting, Analysis, and Decomposition |
|---|---|
| Description: | Fits yield curves using Nelson-Siegel (1987) <doi:10.1086/296409>, Svensson (1994) <doi:10.3386/w4871>, and cubic spline methods. Extracts forward rates, discount factors, and par rates from fitted curves. Computes duration and convexity risk measures. Computes Z-spread and key rate durations. Provides principal component decomposition following Litterman and Scheinkman (1991) <doi:10.3905/jfi.1991.692347>, carry and roll-down analysis, and slope measures. All methods are pure computation with no external dependencies beyond base R; works with yield data from any source. |
| Authors: | Charles Coverdale [aut, cre] |
| Maintainer: | Charles Coverdale <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-30 15:06:52 UTC |
| Source: | https://github.com/charlescoverdale/yieldcurves |
Plot Method for Yield Curve Objects
## S3 method for class 'yc_curve' plot(x, ...)## S3 method for class 'yc_curve' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
The input object, invisibly.
Plots the factor loadings for each principal component across tenors.
## S3 method for class 'yc_pca' plot(x, ...)## S3 method for class 'yc_pca' plot(x, ...)
x |
A |
... |
Additional arguments passed to |
The input object, invisibly.
Print Method for Yield Curve Objects
## S3 method for class 'yc_curve' print(x, ...)## S3 method for class 'yc_curve' print(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
The input object, invisibly.
Print Method for Yield Curve PCA Objects
## S3 method for class 'yc_pca' print(x, ...)## S3 method for class 'yc_pca' print(x, ...)
x |
A |
... |
Additional arguments (currently unused). |
The input object, invisibly.
Summary Method for Yield Curve Objects
## S3 method for class 'yc_curve' summary(object, ...)## S3 method for class 'yc_curve' summary(object, ...)
object |
A |
... |
Additional arguments (currently unused). |
The input object, invisibly.
Summary Method for Yield Curve PCA Objects
## S3 method for class 'yc_pca' summary(object, ...)## S3 method for class 'yc_pca' summary(object, ...)
object |
A |
... |
Additional arguments (currently unused). |
The input object, invisibly.
Compute Macaulay duration, modified duration, and convexity for a coupon-bearing bond.
yc_bond_duration( face = 100, coupon_rate, maturity, yield, frequency = 2, compounding = c("semi_annual", "annual", "continuous") )yc_bond_duration( face = 100, coupon_rate, maturity, yield, frequency = 2, compounding = c("semi_annual", "annual", "continuous") )
face |
Numeric. Face (par) value of the bond. Default is 100. |
coupon_rate |
Numeric. Annual coupon rate as a decimal (e.g., 0.05 for 5 percent). |
maturity |
Numeric. Time to maturity in years. |
yield |
Numeric. Yield to maturity as a decimal. |
frequency |
Integer. Coupon frequency per year: 1 for annual or 2 for semi-annual (default). |
compounding |
Character. Compounding convention: |
A list with components macaulay_duration, modified_duration,
convexity, and price.
# 2-year 5% bond at 4% yield, semi-annual coupons yc_bond_duration(face = 100, coupon_rate = 0.05, maturity = 2, yield = 0.04, frequency = 2)# 2-year 5% bond at 4% yield, semi-annual coupons yc_bond_duration(face = 100, coupon_rate = 0.05, maturity = 2, yield = 0.04, frequency = 2)
Decompose expected return from holding a bond into carry (yield income minus financing cost) and roll-down (capital gain from sliding down the curve).
yc_carry(curve, maturities = NULL, horizon = 1/12, funding_rate = NULL)yc_carry(curve, maturities = NULL, horizon = 1/12, funding_rate = NULL)
curve |
A |
maturities |
Numeric vector of bond maturities to analyse. If NULL, uses the curve's own maturities (excluding the shortest). |
horizon |
Numeric. Holding period in years. Default is |
funding_rate |
Optional numeric. Overnight funding rate as a decimal. If NULL, uses the shortest rate on the curve. |
A data frame with columns maturity, carry, rolldown, and
total.
maturities <- c(0.25, 1, 2, 5, 10, 30) rates <- c(0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_carry(fit)maturities <- c(0.25, 1, 2, 5, 10, 30) rates <- c(0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_carry(fit)
Fit a yield curve using cubic spline interpolation. Provides an exact fit through all observed data points with smooth interpolation between them.
yc_cubic_spline( maturities, rates, method = c("natural", "fmm"), type = c("zero", "par", "forward"), date = NULL )yc_cubic_spline( maturities, rates, method = c("natural", "fmm"), type = c("zero", "par", "forward"), date = NULL )
maturities |
Numeric vector of maturities in years. |
rates |
Numeric vector of observed yields as decimals. |
method |
Character. Spline method: |
type |
Character. Rate type: |
date |
Optional Date for the curve. |
A yc_curve object with method = "cubic_spline".
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_cubic_spline(maturities, rates) fitmaturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_cubic_spline(maturities, rates) fit
Construct a yc_curve object from observed maturity-rate pairs. This is
the core data structure used throughout the package.
yc_curve(maturities, rates, type = c("zero", "par", "forward"), date = NULL)yc_curve(maturities, rates, type = c("zero", "par", "forward"), date = NULL)
maturities |
Numeric vector of maturities in years (e.g., 0.25 for 3 months, 2 for 2 years). |
rates |
Numeric vector of yields as decimals (e.g., 0.05 for 5\
Must be the same length as |
type |
Character. The type of rate: |
date |
Optional Date for the curve observation. |
A yc_curve object (S3 class) with components:
Numeric vector of maturities in years.
Numeric vector of rates as decimals.
Character string indicating rate type.
Character string indicating fitting method.
List of model parameters (empty for observed curves).
Numeric vector of fitted rates (NULL for observed curves).
Numeric vector of residuals (NULL for observed curves).
Date of the curve observation.
Integer count of maturity points.
# US Treasury yields (2Y, 5Y, 10Y, 30Y) maturities <- c(2, 5, 10, 30) rates <- c(0.045, 0.042, 0.040, 0.043) curve <- yc_curve(maturities, rates) curve# US Treasury yields (2Y, 5Y, 10Y, 30Y) maturities <- c(2, 5, 10, 30) rates <- c(0.045, 0.042, 0.040, 0.043) curve <- yc_curve(maturities, rates) curve
Calculate discount factors from a yield curve assuming continuous compounding.
yc_discount( curve, maturities = NULL, compounding = c("continuous", "annual", "semi_annual") )yc_discount( curve, maturities = NULL, compounding = c("continuous", "annual", "semi_annual") )
curve |
A |
maturities |
Optional numeric vector of maturities. If NULL, uses the curve's own maturities. |
compounding |
Character. Compounding convention: |
A data frame with columns maturity and discount_factor.
maturities <- c(1, 2, 5, 10) rates <- c(0.045, 0.043, 0.042, 0.040) curve <- yc_curve(maturities, rates) yc_discount(curve) yc_discount(curve, compounding = "annual")maturities <- c(1, 2, 5, 10) rates <- c(0.045, 0.043, 0.042, 0.040) curve <- yc_curve(maturities, rates) yc_discount(curve) yc_discount(curve, compounding = "annual")
Compute Macaulay duration, modified duration, and convexity for zero-coupon bonds at each maturity on the curve.
yc_duration( curve, maturities = NULL, compounding = c("continuous", "annual", "semi_annual") )yc_duration( curve, maturities = NULL, compounding = c("continuous", "annual", "semi_annual") )
curve |
A |
maturities |
Optional numeric vector of maturities. If NULL, uses the curve's own maturities. |
compounding |
Character. Compounding convention: |
A data frame with columns maturity, macaulay_duration,
modified_duration, and convexity.
maturities <- c(0.25, 1, 2, 5, 10, 30) rates <- c(0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_duration(fit)maturities <- c(0.25, 1, 2, 5, 10, 30) rates <- c(0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_duration(fit)
Unified interface for fitting a yield curve using different methods.
Dispatches to yc_nelson_siegel(), yc_svensson(), or
yc_cubic_spline().
yc_fit( maturities, rates, method = c("nelson_siegel", "svensson", "cubic_spline"), type = c("zero", "par", "forward"), date = NULL, ... )yc_fit( maturities, rates, method = c("nelson_siegel", "svensson", "cubic_spline"), type = c("zero", "par", "forward"), date = NULL, ... )
maturities |
Numeric vector of maturities in years. |
rates |
Numeric vector of observed yields as decimals. |
method |
Character. Fitting method: |
type |
Character. Rate type: |
date |
Optional Date for the curve. |
... |
Additional arguments passed to the fitting function. |
A yc_curve object.
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_fit(maturities, rates, method = "nelson_siegel") fitmaturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_fit(maturities, rates, method = "nelson_siegel") fit
Compute forward rates from a yield curve. Can compute either instantaneous forward rates or forward-forward rates between two tenors.
yc_forward(curve, maturities = NULL, horizon = NULL)yc_forward(curve, maturities = NULL, horizon = NULL)
curve |
A |
maturities |
Optional numeric vector of maturities at which to compute forward rates. If NULL, uses the curve's own maturities. |
horizon |
Optional numeric. If provided, computes the forward rate from each maturity to maturity + horizon (forward-forward rate). |
The instantaneous forward rate is derived as:
A data frame with columns maturity and forward_rate.
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_forward(fit) yc_forward(fit, maturities = c(1, 5, 10), horizon = 1)maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_forward(fit) yc_forward(fit, maturities = c(1, 5, 10), horizon = 1)
Interpolate rates at arbitrary maturities from an observed or fitted yield curve.
yc_interpolate(curve, maturities, method = c("linear", "log_linear", "cubic"))yc_interpolate(curve, maturities, method = c("linear", "log_linear", "cubic"))
curve |
A |
maturities |
Numeric vector of maturities at which to interpolate. |
method |
Character. Interpolation method: |
A data frame with columns maturity and rate.
maturities <- c(1, 2, 5, 10, 30) rates <- c(0.045, 0.043, 0.042, 0.040, 0.043) curve <- yc_curve(maturities, rates) yc_interpolate(curve, c(3, 7, 15, 20))maturities <- c(1, 2, 5, 10, 30) rates <- c(0.045, 0.043, 0.042, 0.040, 0.043) curve <- yc_curve(maturities, rates) yc_interpolate(curve, c(3, 7, 15, 20))
Compute key rate durations by bumping the yield curve at specific tenors. Each bump is triangular: the full shift is applied at the key rate tenor and linearly interpolated to zero at adjacent key rate tenors.
yc_key_rate_duration( coupon_rate, maturity, curve, key_rates = c(1, 2, 5, 10, 30), shift = 1e-04, face = 100, frequency = 2 )yc_key_rate_duration( coupon_rate, maturity, curve, key_rates = c(1, 2, 5, 10, 30), shift = 1e-04, face = 100, frequency = 2 )
coupon_rate |
Numeric. Annual coupon rate as a decimal. |
maturity |
Numeric. Time to maturity in years. |
curve |
Either a |
key_rates |
Numeric vector of key rate tenors in years.
Default is |
shift |
Numeric. Size of the rate bump in decimal (default 0.0001, i.e. 1 basis point). |
face |
Numeric. Face value. Default is 100. |
frequency |
Integer. Coupon frequency: 1 (annual) or 2 (semi-annual, default). |
A data frame with columns tenor and key_rate_duration.
curve <- yc_curve(c(1, 2, 5, 10, 30), c(0.03, 0.035, 0.04, 0.042, 0.045)) yc_key_rate_duration(coupon_rate = 0.04, maturity = 10, curve = curve, key_rates = c(1, 2, 5, 10, 30))curve <- yc_curve(c(1, 2, 5, 10, 30), c(0.03, 0.035, 0.04, 0.042, 0.045)) yc_key_rate_duration(coupon_rate = 0.04, maturity = 10, curve = curve, key_rates = c(1, 2, 5, 10, 30))
For Nelson-Siegel or Svensson curves, extracts the estimated factors directly from the model parameters. For other curves, computes empirical measures.
yc_level_slope_curvature(curve)yc_level_slope_curvature(curve)
curve |
A |
A named list with:
Long-run level (beta0 for NS/Svensson, or mean rate).
Slope factor (beta1 for NS/Svensson, or short - long rate).
Curvature factor (beta2 for NS/Svensson, or 2*mid - short - long rate).
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_level_slope_curvature(fit)maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_level_slope_curvature(fit)
Estimate a Nelson-Siegel (1987) yield curve model from observed maturity-rate pairs. The model decomposes the yield curve into three factors: level, slope, and curvature.
yc_nelson_siegel( maturities, rates, tau_init = 1, weights = NULL, type = c("zero", "par", "forward"), date = NULL )yc_nelson_siegel( maturities, rates, tau_init = 1, weights = NULL, type = c("zero", "par", "forward"), date = NULL )
maturities |
Numeric vector of maturities in years. |
rates |
Numeric vector of observed yields as decimals. |
tau_init |
Numeric. Initial value for the decay parameter tau. Default is 1. |
weights |
Optional numeric vector of weights for each observation.
Must be the same length as |
type |
Character. Rate type: |
date |
Optional Date for the curve. |
The Nelson-Siegel model is:
A yc_curve object with method = "nelson_siegel" and
params containing beta0, beta1, beta2, and tau.
Nelson, C.R. and Siegel, A.F. (1987). Parsimonious Modeling of Yield Curves. The Journal of Business, 60(4), 473–489. doi:10.1086/296409
maturities <- c(0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.043, 0.042, 0.041, 0.040, 0.042, 0.043) fit <- yc_nelson_siegel(maturities, rates) fitmaturities <- c(0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.043, 0.042, 0.041, 0.040, 0.042, 0.043) fit <- yc_nelson_siegel(maturities, rates) fit
Bootstrap zero (spot) rates from par (coupon) rates using iterative stripping.
yc_par_to_zero(maturities, par_rates, frequency = 1)yc_par_to_zero(maturities, par_rates, frequency = 1)
maturities |
Numeric vector of maturities in years (must be positive integers or half-years). |
par_rates |
Numeric vector of par rates as decimals. |
frequency |
Integer. Coupon frequency per year: 1 for annual (default) or 2 for semi-annual. |
A data frame with columns maturity and zero_rate.
maturities <- c(1, 2, 3, 5, 10) par_rates <- c(0.040, 0.042, 0.043, 0.044, 0.045) yc_par_to_zero(maturities, par_rates) # Semi-annual coupons yc_par_to_zero(c(0.5, 1, 2), c(0.04, 0.042, 0.043), frequency = 2)maturities <- c(1, 2, 3, 5, 10) par_rates <- c(0.040, 0.042, 0.043, 0.044, 0.045) yc_par_to_zero(maturities, par_rates) # Semi-annual coupons yc_par_to_zero(c(0.5, 1, 2), c(0.04, 0.042, 0.043), frequency = 2)
Perform PCA on a time series of yield curves to extract the dominant factors (level, slope, curvature) following Litterman and Scheinkman (1991).
yc_pca(curves_matrix, n_components = 3, scale = FALSE)yc_pca(curves_matrix, n_components = 3, scale = FALSE)
curves_matrix |
Numeric matrix where each row is a yield curve observation (e.g., daily curves) and each column is a tenor. Column names should be maturity labels. |
n_components |
Integer. Number of principal components to retain. Default is 3 (level, slope, curvature). |
scale |
Logical. Whether to scale variables before PCA. Default
is |
A yc_pca object (S3 class) with components:
Matrix of factor loadings (tenors x components).
Matrix of factor scores (observations x components).
Numeric vector of proportion of variance explained by each component.
Numeric vector of cumulative variance explained.
Standard deviations of each component.
Number of components retained.
Column names from the input matrix.
Litterman, R. and Scheinkman, J. (1991). Common Factors Affecting Bond Returns. The Journal of Fixed Income, 1(1), 54–61. doi:10.3905/jfi.1991.692347
# Simulate 100 days of yield curves at 5 tenors set.seed(42) n_days <- 100 tenors <- c(1, 2, 5, 10, 30) base_rates <- c(0.045, 0.043, 0.042, 0.040, 0.043) curves <- matrix(NA, n_days, length(tenors)) colnames(curves) <- paste0(tenors, "Y") level <- cumsum(rnorm(n_days, 0, 0.001)) slope <- cumsum(rnorm(n_days, 0, 0.0005)) for (i in seq_len(n_days)) { curves[i, ] <- base_rates + level[i] + slope[i] * (tenors - mean(tenors)) / 30 } pca_result <- yc_pca(curves) pca_result# Simulate 100 days of yield curves at 5 tenors set.seed(42) n_days <- 100 tenors <- c(1, 2, 5, 10, 30) base_rates <- c(0.045, 0.043, 0.042, 0.040, 0.043) curves <- matrix(NA, n_days, length(tenors)) colnames(curves) <- paste0(tenors, "Y") level <- cumsum(rnorm(n_days, 0, 0.001)) slope <- cumsum(rnorm(n_days, 0, 0.0005)) for (i in seq_len(n_days)) { curves[i, ] <- base_rates + level[i] + slope[i] * (tenors - mean(tenors)) / 30 } pca_result <- yc_pca(curves) pca_result
Evaluate a fitted yield curve at new maturities.
yc_predict(curve, maturities)yc_predict(curve, maturities)
curve |
A |
maturities |
Numeric vector of maturities at which to predict rates. |
A data frame with columns maturity and rate.
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_predict(fit, c(3, 7, 15, 20))maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_predict(fit, c(3, 7, 15, 20))
Compute common slope and curvature measures from a yield curve.
yc_slope(curve)yc_slope(curve)
curve |
A |
A named list with slope measures:
10-year minus 2-year rate (the most common slope measure).
30-year minus 2-year rate.
30-year minus 5-year rate.
10-year minus 3-month rate (term premium proxy).
2 * 5-year minus 2-year minus 10-year (curvature measure).
Returns NA for any measure whose required tenors fall outside the curve range.
maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_slope(fit)maturities <- c(0.25, 0.5, 1, 2, 5, 10, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.042, 0.040, 0.043) fit <- yc_nelson_siegel(maturities, rates) yc_slope(fit)
Estimate a Svensson (1994) yield curve model from observed maturity-rate pairs. Extends Nelson-Siegel by adding a second curvature term with its own decay parameter, providing greater flexibility for curves with two humps.
yc_svensson( maturities, rates, tau1_init = 1, tau2_init = 5, weights = NULL, type = c("zero", "par", "forward"), date = NULL )yc_svensson( maturities, rates, tau1_init = 1, tau2_init = 5, weights = NULL, type = c("zero", "par", "forward"), date = NULL )
maturities |
Numeric vector of maturities in years. |
rates |
Numeric vector of observed yields as decimals. |
tau1_init |
Numeric. Initial value for the first decay parameter. Default is 1. |
tau2_init |
Numeric. Initial value for the second decay parameter. Default is 5. |
weights |
Optional numeric vector of weights for each observation.
Must be the same length as |
type |
Character. Rate type: |
date |
Optional Date for the curve. |
A yc_curve object with method = "svensson" and params
containing beta0, beta1, beta2, beta3, tau1, and tau2.
Svensson, L.E.O. (1994). Estimating and Interpreting Forward Interest Rates: Sweden 1992–1994. NBER Working Paper, 4871. doi:10.3386/w4871
maturities <- c(0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.043, 0.042, 0.041, 0.040, 0.042, 0.043) fit <- yc_svensson(maturities, rates) fitmaturities <- c(0.25, 0.5, 1, 2, 3, 5, 7, 10, 20, 30) rates <- c(0.052, 0.050, 0.048, 0.045, 0.043, 0.042, 0.041, 0.040, 0.042, 0.043) fit <- yc_svensson(maturities, rates) fit
Compute par (coupon) rates from zero (spot) rates. The par rate for maturity T is the coupon rate that makes a bond price equal to par.
yc_zero_to_par(maturities, zero_rates, frequency = 1)yc_zero_to_par(maturities, zero_rates, frequency = 1)
maturities |
Numeric vector of maturities in years. |
zero_rates |
Numeric vector of zero rates as decimals. |
frequency |
Integer. Coupon frequency per year: 1 for annual (default) or 2 for semi-annual. |
A data frame with columns maturity and par_rate.
maturities <- c(1, 2, 3, 5, 10) zero_rates <- c(0.040, 0.042, 0.043, 0.044, 0.045) yc_zero_to_par(maturities, zero_rates) # Semi-annual coupons yc_zero_to_par(c(0.5, 1, 2), c(0.04, 0.042, 0.043), frequency = 2)maturities <- c(1, 2, 3, 5, 10) zero_rates <- c(0.040, 0.042, 0.043, 0.044, 0.045) yc_zero_to_par(maturities, zero_rates) # Semi-annual coupons yc_zero_to_par(c(0.5, 1, 2), c(0.04, 0.042, 0.043), frequency = 2)
Compute the Z-spread (zero-volatility spread) for a bond. The Z-spread is the constant spread added to each zero rate on the benchmark curve that makes the discounted cash flows equal the market price.
yc_zspread(price, coupon_rate, maturity, curve, face = 100, frequency = 2)yc_zspread(price, coupon_rate, maturity, curve, face = 100, frequency = 2)
price |
Numeric. Market price of the bond. |
coupon_rate |
Numeric. Annual coupon rate as a decimal. |
maturity |
Numeric. Time to maturity in years. |
curve |
Either a |
face |
Numeric. Face value of the bond. Default is 100. |
frequency |
Integer. Coupon frequency per year: 1 for annual or 2 for semi-annual (default). |
A list with components zspread (the Z-spread as a decimal),
price (the input price), and model_price (the price implied by the
curve with the Z-spread applied).
# Create a benchmark curve curve <- yc_curve(c(0.5, 1, 2, 5, 10), c(0.03, 0.035, 0.04, 0.042, 0.045)) # A bond priced below par (positive Z-spread) yc_zspread(price = 95, coupon_rate = 0.04, maturity = 5, curve = curve, frequency = 2)# Create a benchmark curve curve <- yc_curve(c(0.5, 1, 2, 5, 10), c(0.03, 0.035, 0.04, 0.042, 0.045)) # A bond priced below par (positive Z-spread) yc_zspread(price = 95, coupon_rate = 0.04, maturity = 5, curve = curve, frequency = 2)