50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

RQuantLib (version 0.3.2)

FixedRateBond: Fixed rate bond evaluation using discount curve solution

Description

The FixedRateBond function evaluates a fixed 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

Usage

## S3 method for class 'default':
FixedRateBond(bond, rates, discountCurve, dateparams )
## S3 method for class 'Bond':
plotundefined
## S3 method for class 'Bond':
printundefined
## S3 method for class 'Bond':
summaryundefined

Arguments

bond
bond parameters: ll{ faceAmount a double, face amount of the bond issueDate a Date, the bond's issue date maturityDate a Date, the bond's maturity date redemption
rates
a double vector of rates
discountCurve
Can be on of the following: l{ a DiscountCurve object A list that specifies a flat curve in two values "todayDate" and "rate" A list that specified 3 values to construct a DiscountCurve object, "pa
dateparams
QuantLib's date parameters of the bond. ll{ settlementDays a double, settlement days. calendar a string, either 'us' or 'uk' corresponding to US Goverment Bond calendar and UK Exchange calendar.

Value

  • The FixedRateBond function returns an object of class FixedRateBond (which inherits from class Bond). It contains a list with the following components:
  • NPVnet present value of the bond
  • cleanPriceprice price of the bond
  • dirtyPricedirty price of the bond
  • accruedAmountaccrued amount of the bond
  • yieldyield of the bond
  • cashFlowscash flows of the bond

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
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 = 1, period=3, 
                   businessDayConvention = 4, terminationDateConvention=4,
                   dateGeneration=1, endOfMonth=1)
curve <- list(todayDate=as.Date("2004-11-04"), riskFreeRate=0.03)
rates <- c(0.02875)
                       
FixedRateBond(bond, rates, curve, 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)
curve <- list(params, tsQuotes, times)
FixedRateBond(bond, rates, curve, dateparams)

curve <- DiscountCurve(params, tsQuotes, times)
dateparams <- list(settlementDays=1, calendar="us", dayCounter = "Thirty360", 
                   period="Annual", businessDayConvention = "Preceding", 
                   terminationDateConvention="Preceding",
                   dateGeneration="Forward", endOfMonth=1)
FixedRateBond(bond, rates, curve, dateparams)

Run the code above in your browser using DataLab