DiscountCurve
constructs the spot term structure of interest
rates based on input market data including the settlement date,
deposit rates, futures prices, FRA rates, or swap rates, in various
combinations. It returns the corresponding discount factors, zero
rates, and forward rates for a vector of times that is specified
as input.DiscountCurve(params, tsQuotes, times)
tradeDate
(month/day/year),
settleDate
, forward rate
time span dt
, and two curve
construction options: interpWhat
(with possible values
discount
,
flat
rate for a flat yield curve
d1w
dt
does not exceed the longest
maturity of the instruments used for calibration (no DiscountCurve
returns a list containing:dt
QuantLib
Version 0.3.10. It
introduces support for fixed-income instruments in RQuantLib
.
Forward rates and zero rates are computed assuming continuous
compounding, so the forward rate $f$ over the
period from $t_1$ to $t_2$ is determined by the
relation
Curve construction can be a delicate problem and the algorithms may
fail for some input data sets and/or some combinations of the
values for interpWhat
and interpHow
.
Fortunately, the C++ exception mechanism seems to work well with the R
interface, and QuantLib
exceptions are propagated back to the
R user, usually with a message that indicates what went wrong. (The
first part of the message contains technical information about the
precise location of the problem in the QuantLib
code. Scroll to
the end to find information that is meaningful to the R user.)
For information about QuantLib
see
For information about RQuantLib
see
BermudanSwaption
savepar <- par(mfrow=c(3,3))
# This data is taken from sample code shipped with QuantLib 0.3.10.
params <- list(tradeDate=c(2, 15, 2002),
settleDate=c(2, 19, 2002),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
tsQuotes <- list(d1w =0.0382,
d1m =0.0372,
fut1=96.2875,
fut2=96.7875,
fut3=96.9875,
fut4=96.6875,
fut5=96.4875,
fut6=96.3875,
fut7=96.2875,
fut8=96.0875,
s3y =0.0398,
s5y =0.0443,
s10y =0.05165,
s15y =0.055175)
times <- seq(0,10,.1)
# Loglinear interpolation of discount factors
curves <- DiscountCurve(params, tsQuotes, times)
plot(curves,setpar=FALSE)
# Linear interpolation of discount factors
params$interpHow="linear"
curves <- DiscountCurve(params, tsQuotes, times)
plot(curves,setpar=FALSE)
# Spline interpolation of discount factors
params$interpHow="spline"
curves <- DiscountCurve(params, tsQuotes, times)
plot(curves,setpar=FALSE)
par(savepar)
Run the code above in your browser using DataLab