Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

Classes | Public Member Functions | Protected Member Functions | Protected Attributes

QuantLib::Bond Class Reference

Base bond class. More...

#include <bond.hpp>

Inheritance diagram for QuantLib::Bond:
Inheritance graph
Collaboration diagram for QuantLib::Bond:
Collaboration graph

List of all members.


class  arguments
class  engine
class  results

Public Member Functions

 Bond (Natural settlementDays, const Calendar &calendar, const Date &issueDate=Date(), const Leg &coupons=Leg())
 constructor for amortizing or non-amortizing bonds.
 Bond (Natural settlementDays, const Calendar &calendar, Real faceAmount, const Date &maturityDate, const Date &issueDate=Date(), const Leg &cashflows=Leg())
 old constructor for non amortizing bonds.
Date nextCashFlowDate (Date d=Date()) const
virtual Rate nextCouponRate (Date d=Date()) const
void notifyObservers ()
Date previousCashFlowDate (Date d=Date()) const
Rate previousCouponRate (Date d=Date()) const
 Previous coupon already paid at a given date.
void registerWith (const boost::shared_ptr< Observable > &)
void unregisterWith (const boost::shared_ptr< Observable > &)
Instrument interface
bool isExpired () const
 returns whether the instrument might have value greater than zero.
Natural settlementDays () const
const Calendarcalendar () const
const std::vector< Real > & notionals () const
virtual Real notional (Date d=Date()) const
const Legcashflows () const
const Legredemptions () const
const boost::shared_ptr
< CashFlow > & 
redemption () const
Date maturityDate () const
Date issueDate () const
bool isTradable (Date d=Date()) const
Date settlementDate (Date d=Date()) const
Real cleanPrice () const
 theoretical clean price
Real dirtyPrice () const
 theoretical dirty price
Real settlementValue () const
 theoretical settlement value
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
Real settlementValue (Real cleanPrice) const
 settlement value as a function of the clean price
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
virtual Real accruedAmount (Date d=Date()) const
 accrued amount at a given date
Real NPV () const
 returns the net present value of the instrument.
Real errorEstimate () const
 returns the error estimate on the NPV when available.
const DatevaluationDate () const
 returns the date the net present value refers to.
template<typename T >
result (const std::string &tag) const
 returns any additional result returned by the pricing engine.
const std::map< std::string,
boost::any > & 
additionalResults () const
 returns all additional result returned by the pricing engine.
void setPricingEngine (const boost::shared_ptr< PricingEngine > &)
 set the pricing engine to be used.
Observer interface
void update ()

These methods do not modify the structure of the object and are therefore declared as const. Data members which will be calculated on demand need to be declared as mutable.

void recalculate ()
void freeze ()
void unfreeze ()

Protected Member Functions

void addRedemptionsToCashflows (const std::vector< Real > &redemptions=std::vector< Real >())
void calculateNotionalsFromCashflows ()
void fetchResults (const PricingEngine::results *) const
void setSingleRedemption (Real notional, Real redemption, const Date &date)
void setSingleRedemption (Real notional, const boost::shared_ptr< CashFlow > &redemption)
void setupArguments (PricingEngine::arguments *) const
void setupExpired () const
void calculate () const
virtual void performCalculations () const

Protected Attributes

bool calculated_
Calendar calendar_
Leg cashflows_
boost::shared_ptr< PricingEngineengine_
bool frozen_
Date issueDate_
Date maturityDate_
std::vector< Realnotionals_
std::vector< DatenotionalSchedule_
Leg redemptions_
Natural settlementDays_
Real settlementValue_

The value of this attribute and any other that derived classes might declare must be set during calculation.

Real NPV_
Real errorEstimate_
Date valuationDate_
std::map< std::string, boost::any > additionalResults_

Detailed Description

Base bond class.

Derived classes must fill the uninitialized data members.

Most methods assume that the cash flows are stored sorted by date, the redemption(s) being after any cash flow at the same date. In particular, if there's one single redemption, it must be the last cash flow,
  • price/yield calculations are cross-checked for consistency.
  • price/yield calculations are checked against known good values.

Definition at line 59 of file bond.hpp.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index