Description Usage Arguments Details Value Note Author(s) References Examples
The FloatingRateBond
function evaluates a floating rate bond using discount curve.
More specificly, the calculation is done by DiscountingBondEngine from QuantLib.
The NPV, clean price, dirty price, accrued interest, yield and cash flows of the bond is returned.
For more detail, see the source codes in quantlib's test-suite. test-suite/bond.cpp
1 2 3 4 | ## Default S3 method:
FloatingRateBond(bond, gearings, spreads,
caps, floors, index,
curve, dateparams )
|
bond |
bond parameters, a named list whose elements are:
| |||||||||||||||||||||||||||||||||||||||||||||
gearings |
(Optional) a numeric vector, bond's gearings. See quantlib's doc on FloatingRateBond for more detail. Default value is an empty vector c(). | |||||||||||||||||||||||||||||||||||||||||||||
spreads |
(Optional) a numeric vector, bond's spreads. See quantlib's doc on FloatingRateBond for more detail.Default value is an empty vector c() | |||||||||||||||||||||||||||||||||||||||||||||
caps |
(Optional) a numeric vector, bond's caps. See quantlib's doc on FloatingRateBond for more detail. Default value is an empty vector c() | |||||||||||||||||||||||||||||||||||||||||||||
floors |
(Optional) a numeric vector, bond's floors. See quantlib's doc on FloatingRateBond for more detail. Default value is an empty vector c() | |||||||||||||||||||||||||||||||||||||||||||||
curve |
Can be one of the following:
| |||||||||||||||||||||||||||||||||||||||||||||
index |
a named list whose elements are parameters of an IborIndex term structure.
| |||||||||||||||||||||||||||||||||||||||||||||
dateparams |
(Optional) a named list, QuantLib's date parameters of the bond.
See example below. |
A discount curve is built to calculate the bond value.
Please see any decent Finance textbook for background reading, and the
QuantLib
documentation for details on the QuantLib
implementation.
The FloatingRateBond
function returns an object of class
FloatingRateBond
(which inherits from class
Bond
). It contains a list with the following
components:
NPV |
net present value of the bond |
cleanPrice |
clean price of the bond |
dirtyPrice |
dirty price of the bond |
accruedAmount |
accrued amount of the bond |
yield |
yield of the bond |
cashFlows |
cash flows of the bond |
The interface might change in future release as QuantLib
stabilises its own API.
Khanh Nguyen knguyen@cs.umbno.edu for the inplementation; Dirk Eddelbuettel edd@debian.org for the R interface;
the QuantLib Group for QuantLib
http://quantlib.org for details on QuantLib
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | bond <- list(faceAmount=100, issueDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"), redemption=100,
effectiveDate=as.Date("2004-11-30"))
dateparams <- list(settlementDays=1, calendar="us",
dayCounter = 'ActualActual', period=2,
businessDayConvention = 1, terminationDateConvention=1,
dateGeneration=0, endOfMonth=0, fixingDays = 1)
gearings <- c()
spreads <- c()
caps <- c()
floors <- c()
params <- list(tradeDate=as.Date('2002-2-15'),
settleDate=as.Date('2002-2-19'),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
setEvaluationDate(as.Date("2004-11-22"))
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)
tsQuotes <- list("flat" = 0.02) ## While discount curve code is buggy
## when both discount and libor curves are flat.
discountCurve.flat <- DiscountCurve(params, list(flat=0.05))
termstructure <- DiscountCurve(params, list(flat=0.03))
iborIndex.params <- list(type="USDLibor", length=6,
inTermOf="Month", term=termstructure)
FloatingRateBond(bond, gearings, spreads, caps, floors,
iborIndex.params, discountCurve.flat, dateparams)
## discount curve is constructed from market quotes
## and a flat libor curve
discountCurve <- DiscountCurve(params, tsQuotes)
termstructure <- DiscountCurve(params, list(flat=0.03))
iborIndex.params <- list(type="USDLibor", length=6,
inTermOf="Month", term = termstructure)
FloatingRateBond(bond, gearings, spreads, caps, floors,
iborIndex.params, discountCurve, dateparams)
#example using default values
FloatingRateBond(bond=bond, index=iborIndex.params, curve=discountCurve)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.