RQuantLib (version 0.4.3)

ZeroCouponBond: 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

"ZeroCouponBond"(bond, discountCurve, dateparams)
"ZeroPriceByYield"(yield, faceAmount, issueDate, maturityDate, dayCounter=2, frequency=2, compound=0, businessDayConvention=4)
"ZeroYield"(price, faceAmount, issueDate, maturityDate, dayCounter=2, frequency=2, compound=0, businessDayConvention=4)

Arguments

bond
bond parameters, a named list whose elements are:
issueDate
a Date, the bond's issue date
maturityDate
a Date, the bond's maturity date
faceAmount
(Optional) a double, face amount of the bond.
Default value is 100.
redemption
(Optional) a double, percentage of the initial
face amount that will be returned at maturity
date. Default value is 100.
discountCurve
Can be one of the following:
a DiscountCurve
a object of DiscountCurve class
For more detail, see example or
the discountCurve function
A 2 items list
specifies a flat curve in two
values "todayDate" and "rate"
A 3 items list
specifies three values to construct a
DiscountCurve object, "params" ,
"tsQuotes", "times".
For more detail, see example or
the discountCurve function
dateparams
(Optional) a named list, QuantLib's date parameters of the bond.
settlementDays
(Optional) a double, settlement days.
Default value is 1.
calendar
(Optional) a string, either 'us' or 'uk'
corresponding to US Goverment Bond
calendar and UK Exchange calendar.
Default value is 'us'.
businessDayConvention
(Optional) a number or string,
business day convention.
See Enum. Default value is 'Following'.
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

Value

The ZeroCouponBond function returns an object of class ZeroCouponBond (which inherits from class Bond). It contains a list with the following components:The ZeroPriceByYield function returns an object of class ZeroPriceByYield (which inherits from class Bond). It contains a list with the following components:The ZeroYield function returns an object of class ZeroYield (which inherits from class Bond). It contains a list with the following components:

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.

References

http://quantlib.org for details on QuantLib.

Examples

Run this code
# 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"))

Run the code above in your browser using DataCamp Workspace