ZeroCouponBond {RQuantLib} | R Documentation |
Zero-Coupon bond pricing
Description
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 code in the QuantLib file test-suite/bond.cpp
.
The ZeroPriceYield
function evaluates a zero-coupon clean price based on its yield.
The ZeroYield
function evaluations a zero-coupon yield based.
See also http://www.mathworks.com/access/helpdesk/help/toolbox/finfixed/zeroyield.html
Usage
## Default S3 method:
ZeroCouponBond(bond, discountCurve, dateparams)
## Default S3 method:
ZeroPriceByYield(yield, faceAmount,
issueDate, maturityDate,
dayCounter=2, frequency=2,
compound=0, businessDayConvention=4)
## Default S3 method:
ZeroYield(price, faceAmount,
issueDate, maturityDate,
dayCounter=2, frequency=2,
compound=0, businessDayConvention=4)
Arguments
bond |
bond parameters, a named list whose elements are:
| |||||||||||||||||||||
discountCurve |
Can be one of the following:
| |||||||||||||||||||||
dateparams |
(Optional) a named list, QuantLib's date parameters of the bond.
See example below. | |||||||||||||||||||||
yield |
yield of the bond | |||||||||||||||||||||
price |
price of the bond | |||||||||||||||||||||
faceAmount |
face amount of the bond | |||||||||||||||||||||
issueDate |
date the bond is issued | |||||||||||||||||||||
maturityDate |
maturity date, an R's date type | |||||||||||||||||||||
dayCounter |
day count convention. 0 = Actual360(), 1 = Actual365Fixed(), 2 = ActualActual(), 3 = Business252(), 4 = OneDayCounter(), 5 = SimpleDayCounter(), all other = Thirty360(). For more information, see QuantLib's DayCounter class | |||||||||||||||||||||
frequency |
frequency of events,0=NoFrequency, 1=Once, 2=Annual, 3=Semiannual, 4=EveryFourthMonth, 5=Quarterly, 6=Bimonthly ,7=Monthly ,8=EveryFourthWeely,9=Biweekly, 10=Weekly, 11=Daily. For more information, see QuantLib's Frequency class | |||||||||||||||||||||
compound |
compounding type. 0=Simple, 1=Compounded, 2=Continuous, all other=SimpleThenCompounded. See QuantLib's Compound class | |||||||||||||||||||||
businessDayConvention |
convention used to adjust a date in case it is not a valid business day. See quantlib for more detail. 0 = Following, 1 = ModifiedFollowing, 2 = Preceding, 3 = ModifiedPreceding, other = Unadjusted |
Details
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.
Value
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 |
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 ZeroPriceByYield
function returns an object of class
ZeroPriceByYield
(which inherits from class
Bond
). It contains a list with the following
components:
price |
price of the bond |
The ZeroYield
function returns an object of class
ZeroYield
(which inherits from class
Bond
). It contains a list with the following
components:
yield |
yield of the bond |
Note
The interface might change in future release as QuantLib
stabilises its own API.
Author(s)
Khanh Nguyen knguyen@cs.umb.edu for the inplementation; Dirk Eddelbuettel edd@debian.org for the R interface;
the QuantLib Group for QuantLib
References
https://www.quantlib.org/ for details on QuantLib
.
Examples
# Simple call with all parameter and a flat curve
bond <- list(faceAmount=100,issueDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"), redemption=100 )
dateparams <-list(settlementDays=1, calendar="UnitedStates/GovernmentBond",
businessDayConvention='Unadjusted')
discountCurve.param <- list(tradeDate=as.Date('2002-2-15'),
settleDate=as.Date('2002-2-15'),
dt=0.25,
interpWhat='discount', interpHow='loglinear')
discountCurve.flat <- DiscountCurve(discountCurve.param, list(flat=0.05))
ZeroCouponBond(bond, discountCurve.flat, dateparams)
# The same bond with a discount curve constructed from market quotes
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
discountCurve <- DiscountCurve(discountCurve.param, tsQuotes)
ZeroCouponBond(bond, discountCurve, dateparams)
#examples with default arguments
ZeroCouponBond(bond, discountCurve)
bond <- list(issueDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"))
dateparams <-list(settlementDays=1)
ZeroCouponBond(bond, discountCurve, dateparams)
ZeroPriceByYield(0.1478, 100, as.Date("1993-6-24"), as.Date("1993-11-1"))
ZeroYield(90, 100, as.Date("1993-6-24"), as.Date("1993-11-1"))