Bond Class Reference
[Financial instruments]

#include <ql/instruments/bond.hpp>

Inheritance diagram for Bond:

Inheritance graph
[legend]
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

Inspectors
Date settlementDate (const Date &d=Date()) const
Date issueDate () const
Date maturityDate () const
Date interestAccrualDate () const
const Leg & cashflows () const
const boost::shared_ptr< CashFlow > & redemption () const
const Calendarcalendar () const
BusinessDayConvention paymentConvention () const
Real faceAmount () const
const DayCounterdayCounter () const
Frequency frequency () const
Handle< YieldTermStructurediscountCurve () const
Calculations
Real cleanPrice () const
 theoretical clean price
Real dirtyPrice () const
 theoretical dirty price
Rate yield (Compounding compounding, Real accuracy=1.0e-8, Size maxEvaluations=100) const
 theoretical bond yield
Real cleanPrice (Rate yield, Compounding compounding, Date settlementDate=Date()) const
 clean price given a yield and settlement date
Real dirtyPrice (Rate yield, Compounding compounding, Date settlementDate=Date()) const
 dirty price given a yield and settlement date
Rate yield (Real cleanPrice, Compounding compounding, Date settlementDate=Date(), Real accuracy=1.0e-8, Size maxEvaluations=100) const
 yield given a (clean) price and settlement date
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

 Bond (Natural settlementDays, Real faceAmount, const Calendar &calendar, const DayCounter &paymentDayCounter, BusinessDayConvention paymentConvention, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >())
void performCalculations () const
void setupArguments (PricingEngine::arguments *) const

Protected Attributes

Natural settlementDays_
Real faceAmount_
Calendar calendar_
DayCounter paymentDayCounter_
BusinessDayConvention paymentConvention_
Handle< YieldTermStructurediscountCurve_
Date issueDate_
Date datedDate_
Date maturityDate_
Frequency frequency_
Leg cashflows_


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 ( Compounding  compounding,
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,
Compounding  compounding,
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,
Compounding  compounding,
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,
Compounding  compounding,
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.

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.

void performCalculations (  )  const [protected, virtual]

In case a pricing engine is not used, this method must be overridden to perform the actual calculations and set any needed results. In case a pricing engine is used, the default implementation can be used.

Reimplemented from Instrument.

Reimplemented in ConvertibleBond.