curve.calculation {QuantBondCurves} | R Documentation |
Curve calculation
Description
Function that calculates zero coupon or instantaneous forward curves for multiple analysis dates, according to historical data of internal rates of return (IRR) and coupon rates of assets. Extends previous market rate curves by minimizing Mean Absolute Errors (MAE) following a bootstrapping recursive method. Alternatively, methodology of residual sum of squares (RSS) can be employed.
Usage
curve.calculation(
serie,
market.assets = NULL,
noSpots = 1,
previous.curve = NULL,
asset.type = "TES",
freq = 1,
rate.type = 1,
daycount = NULL,
fwd = 0,
npieces = NULL,
obj = "Price",
Weights = NULL,
nsimul = 1,
piece.term = NULL,
nodes = seq(0, 10, 0.001),
approximation = "constant"
)
Arguments
serie |
A time series matrix that encompasses a sequence of IRR's emitted on distinct dates. The columns correspond to different maturity periods, expressed in years, while the row names indicate the precise dates when the rates were emitted. |
market.assets |
A matrix containing market assets data, where the first column represents the coupon rates of the assets and the second column represents their corresponding maturities as dates. This input is required only if the IRR's of assets differs from their coupon rates. |
noSpots |
Number of spot interest rates introduced in the |
previous.curve |
A matrix that stores historical curve values up to the earliest calibration date
on |
asset.type |
String that determines the asset type to value. See also 'Details'. |
freq |
Frequency of payments of a given asset in a year. For LIBOR and IBR the default frequency is four (quarterly payments). TES has a default frequency of one (annual payments). |
rate.type |
(1) for annual compounded discount rates and (0) for continuosly compounded discount rates. By default, rates are assumed to be the former. |
daycount |
Day count convention. See also 'Details'. |
fwd |
Numeric value that determines if the desired output curve is a
forward or a spot curve. Set |
npieces |
Number of constant or linear segments for the curve to incorporate. By
default |
obj |
String related to the definition of the error in the RSS methodology.
Set |
Weights |
Vector of weights used to dot product with residual squares in order to calculate residual sum of squares. By default, each residual is assigned the same weight. |
nsimul |
Number of simulations for the terms of the pieces. The more simulations,
the more likely to find a better local solution. By default |
piece.term |
Vector that establishes a unique term structure for optimization to take place.
Each piece or segment must have a unique maturity, as numeric value in years,
that signifies the end of the segment. Last segment maturity must not be introduced, it is assumed to be equivalent to
the last term introduced on analysis date. Therefore, the |
nodes |
Desired output nodes of the curve. |
approximation |
String that establish the approximation. Set
|
Details
asset.type
makes reference to the following type of assets:
"TES" for Colombian Treasury Bonds (default).
"IBRSwaps" for swaps indexed to IBR rate.
"LIBORSwaps" for Interest Rate Swaps (IRS) indexed to 3M LIBOR.
"FixedIncome" for assets that are indexed to a fixed income with different frequency of payments.
If npieces = NULL
uses a recursive iteration process based in
bootstrapping where the curve is constructed through a minimization of the MAE
between the dirty price of historical assets and an approximation of the theoretical
price of assets of same maturity. Uses the "L-BFGS-B" optimization method
to minimize the expected MAE. Otherwise, curve is constructed through minimization
of RSS where the error can be defined via price or rate.
Value
Zero Coupon curves for the corresponding analysis dates.
If fwd = 1
, returns forward curves.
Examples
# Previous curve input
previous.curve <- matrix(0.04,nrow = 2,ncol = 8)
rownames(previous.curve) <- c("2014-01-01","2015-01-01")
colnames(previous.curve) <- c(0, 0.25, 0.5, 1:5)
# IRR's input
serie <- matrix(NA,nrow = 4,ncol = 6)
rownames(serie) <- c("2014-01-01","2015-01-01","2016-01-01","2017-01-01")
colnames(serie) <- c(0, 0.08333, 0.25, 0.5, 1, 2)
serie[1,1] <- 0.040; serie[1,2] <- 0.050; serie[1,3] <- 0.060; serie[1,4] <- 0.065
serie[1,5] <- 0.070; serie[1,6] <- 0.075
serie[2,1] <- 0.030; serie[2,2] <- 0.040; serie[2,3] <- 0.050; serie[2,4] <- 0.063
serie[2,5] <- 0.074; serie[2,6] <- 0.080
serie[3,1] <- 0.060; serie[3,2] <- 0.065; serie[3,3] <- 0.070; serie[3,4] <- 0.080
serie[3,5] <- 0.084; serie[3,6] <- 0.090
serie[4,1] <- 0.020; serie[4,2] <- 0.030; serie[4,3] <- 0.040; serie[4,4] <- 0.042
serie[4,5] <- 0.045; serie[4,6] <- 0.050
# Market Assets input
market.assets <- matrix(NA,nrow = 10,ncol = 2)
market.assets[1,1] <- 0.040 ; market.assets[2,1] <- 0.05
market.assets[3,1] <- 0.060 ; market.assets[4,1] <- 0.07
market.assets[5,1] <- 0.080 ; market.assets[6,1] <- 0.09
market.assets[7,1] <- 0.060 ; market.assets[8,1] <- 0.07
market.assets[9,1] <- 0.075 ; market.assets[10,1] <- 0.07
market.assets[1,2] <- "2016-01-01" ; market.assets[2,2] <- "2016-02-01"
market.assets[3,2] <- "2016-04-01" ; market.assets[4,2] <- "2016-07-01"
market.assets[5,2] <- "2017-01-01" ; market.assets[6,2] <- "2017-02-01"
market.assets[7,2] <- "2017-04-01" ; market.assets[8,2] <- "2017-07-01"
market.assets[9,2] <- "2018-01-01" ; market.assets[10,2] <- "2019-01-01"
#Calculation
curve.calculation(serie = serie, market.assets = market.assets,
previous.curve = previous.curve, asset.type = "TES",
freq = 1, rate.type = 1, fwd = 0,
nodes = c(0, 0.25, 0.5, 1:5), approximation = "linear")