ZeroCouponBond {RQuantLib} | R Documentation |
The ZeroCouponBond
function evaluates a zero-coupon plainly 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
## Default S3 method: ZeroCouponBond(bond, discountCurve, dateparams) ## S3 method for class 'Bond': plot ## S3 method for class 'Bond': print ## S3 method for class 'Bond': summary
bond |
bond parameters:
| ||||||||
discountCurve |
Can be on of the following:
| ||||||||
dateparams |
QuantLib's date parameters of the bond.
|
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 ZeroCouponBond
function returns an object of class
ZeroCouponBond
(which inherits from class
Bond
). It contains a list with the following
components:
NPV |
net present value of the bond |
cleanPrice |
price 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.umb.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
.
# simple call with unnamed parameters bond <- list(faceAmount=100, issueDate=as.Date("2004-11-30"), maturityDate=as.Date("2008-11-30"), redemption=100 ) dateparams <-list(settlementDays=1, calendar="us", businessDayConvention=4) discountCurve <- list(todayDate=as.Date("2004-11-04"), riskFreeRate=0.03) ZeroCouponBond(bond, discountCurve, dateparams) params <- list(tradeDate=as.Date('2002-2-15'), settleDate=as.Date('2002-2-19'), 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) discountCurve <- list(params, tsQuotes, times) # depreciated ZeroCouponBond(bond, discountCurve, dateparams) # construct a curve curves <- DiscountCurve(params, tsQuotes, times) ZeroCouponBond(bond, curves, dateparams) #construct a flat curve flatquote <- list(flat=0.04) flatCurve <- DiscountCurve(params, flatquote, times) dateparams <-list(settlementDays=1, calendar="us", businessDayConvention="Following") ZeroCouponBond(bond, flatCurve, dateparams)