Bond Class Reference
[Financial instruments]

#include <ql/instruments/bond.hpp>

Inheritance diagram for Bond:

List of all members.


Detailed Description

Base bond class.

Derived classes must fill the unitialized data members.

Warning:
Most methods assume that the cashflows are stored sorted by date, the redemption being the last one.

Tests:
  • price/yield calculations are cross-checked for consistency.
  • price/yield calculations are checked against known good values.

Public Member Functions

 Bond (Natural settlementDays, const Calendar &calendar, Real faceAmount, const Date &maturityDate, const Date &issueDate=Null< Date >(), const Leg &leg=std::vector< boost::shared_ptr< CashFlow > >())
Real currentCoupon (Date d=Date()) const
 current coupon at a given date
Real previousCoupon (Date d=Date()) const
 previous coupon already paid at a given date
Inspectors
Natural settlementDays () const
const Calendarcalendar () const
Real faceAmount () const
const Leg & cashflows () const
const boost::shared_ptr
< CashFlow > & 
redemption () const
Date maturityDate () const
Date issueDate () const
Date settlementDate (const Date &d=Date()) const
Calculations
Real cleanPrice () const
 theoretical clean price
Real dirtyPrice () const
 theoretical dirty price
Rate yield (const DayCounter &dc, Compounding comp, Frequency freq, Real accuracy=1.0e-8, Size maxEvaluations=100) const
 theoretical bond yield
Real cleanPrice (Rate yield, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const
 clean price given a yield and settlement date
Real dirtyPrice (Rate yield, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const
 dirty price given a yield and settlement date
Rate yield (Real cleanPrice, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date(), Real accuracy=1.0e-8, Size maxEvaluations=100) const
 yield given a (clean) price and settlement date
Real cleanPriceFromZSpread (Spread zSpread, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const
 clean price given Z-spread
Real dirtyPriceFromZSpread (Spread zSpread, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const
 dirty price given Z-spread
virtual Real accruedAmount (Date d=Date()) const
 accrued amount at a given date
bool isExpired () const
 returns whether the instrument is still tradable.

Protected Member Functions

void setupArguments (PricingEngine::arguments *) const

Protected Attributes

Natural settlementDays_
Calendar calendar_
Real faceAmount_
Leg cashflows_
Date maturityDate_
Date issueDate_

Member Function Documentation

const Leg & cashflows (  )  const

Warning:
the returned vector includes the redemption as the last cash flow.

Real cleanPrice (  )  const

theoretical clean price

The default bond settlement is used for calculation.

Warning:
the theoretical price calculated from a flat term structure might differ slightly from the price calculated from the corresponding yield by means of the other overload of this function. If the price from a constant yield is desired, it is advisable to use such other overload.

Real dirtyPrice (  )  const

theoretical dirty price

The default bond settlement is used for calculation.

Warning:
the theoretical price calculated from a flat term structure might differ slightly from the price calculated from the corresponding yield by means of the other overload of this function. If the price from a constant yield is desired, it is advisable to use such other overload.

Rate yield ( const DayCounter dc,
Compounding  comp,
Frequency  freq,
Real  accuracy = 1.0e-8,
Size  maxEvaluations = 100 
) const

theoretical bond yield

The default bond settlement and theoretical price are used for calculation.

Real cleanPrice ( Rate  yield,
const DayCounter dc,
Compounding  comp,
Frequency  freq,
Date  settlementDate = Date() 
) const

clean price given a yield and settlement date

The default bond settlement is used if no date is given.

Real dirtyPrice ( Rate  yield,
const DayCounter dc,
Compounding  comp,
Frequency  freq,
Date  settlementDate = Date() 
) const

dirty price given a yield and settlement date

The default bond settlement is used if no date is given.

Rate yield ( Real  cleanPrice,
const DayCounter dc,
Compounding  comp,
Frequency  freq,
Date  settlementDate = Date(),
Real  accuracy = 1.0e-8,
Size  maxEvaluations = 100 
) const

yield given a (clean) price and settlement date

The default bond settlement is used if no date is given.

Real cleanPriceFromZSpread ( Spread  zSpread,
const DayCounter dc,
Compounding  comp,
Frequency  freq,
Date  settlementDate = Date() 
) const

clean price given Z-spread

Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given. For details on Z-spread refer to: "Credit Spreads Explained", Lehman Brothers European Fixed Income Research - March 2004, D. O'Kane

Real dirtyPriceFromZSpread ( Spread  zSpread,
const DayCounter dc,
Compounding  comp,
Frequency  freq,
Date  settlementDate = Date() 
) const

dirty price given Z-spread

Z-spread compounding, frequency, daycount are taken into account The default bond settlement is used if no date is given. For details on Z-spread refer to: "Credit Spreads Explained", Lehman Brothers European Fixed Income Research - March 2004, D. O'Kane

virtual Real accruedAmount ( Date  d = Date()  )  const [virtual]

accrued amount at a given date

The default bond settlement is used if no date is given.

Real currentCoupon ( Date  d = Date()  )  const

current coupon at a given date

The default bond settlement is used if no date is given.

Real previousCoupon ( Date  d = Date()  )  const

previous coupon already paid at a given date

The default bond settlement is used if no date is given.

void setupArguments ( PricingEngine::arguments *   )  const [protected, virtual]

When a derived argument structure is defined for an instrument, this method should be overridden to fill it. This is mandatory in case a pricing engine is used.

Reimplemented from Instrument.