QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
Base bond class. More...
#include <bond.hpp>
Classes | |
class | arguments |
class | engine |
class | Price |
Bond price information. More... | |
class | results |
Public Member Functions | |
Bond (Natural settlementDays, Calendar calendar, const Date &issueDate=Date(), const Leg &coupons=Leg()) | |
constructor for amortizing or non-amortizing bonds. More... | |
Bond (Natural settlementDays, Calendar calendar, Real faceAmount, const Date &maturityDate, const Date &issueDate=Date(), const Leg &cashflows=Leg()) | |
old constructor for non amortizing bonds. More... | |
Instrument interface | |
bool | isExpired () const override |
returns whether the instrument might have value greater than zero. More... | |
Observable interface | |
void | deepUpdate () override |
Inspectors | |
Natural | settlementDays () const |
const Calendar & | calendar () const |
const std::vector< Real > & | notionals () const |
virtual Real | notional (Date d=Date()) const |
const Leg & | cashflows () const |
const Leg & | redemptions () const |
const ext::shared_ptr< CashFlow > & | redemption () const |
Date | startDate () const |
Date | maturityDate () const |
Date | issueDate () const |
bool | isTradable (Date d=Date()) const |
Date | settlementDate (Date d=Date()) const |
Public Member Functions inherited from Instrument | |
Instrument () | |
Real | NPV () const |
returns the net present value of the instrument. More... | |
Real | errorEstimate () const |
returns the error estimate on the NPV when available. More... | |
const Date & | valuationDate () const |
returns the date the net present value refers to. More... | |
template<typename T > | |
T | result (const std::string &tag) const |
returns any additional result returned by the pricing engine. More... | |
const std::map< std::string, ext::any > & | additionalResults () const |
returns all additional result returned by the pricing engine. More... | |
void | setPricingEngine (const ext::shared_ptr< PricingEngine > &) |
set the pricing engine to be used. More... | |
Public Member Functions inherited from LazyObject | |
LazyObject () | |
~LazyObject () override=default | |
void | update () override |
bool | isCalculated () const |
void | forwardFirstNotificationOnly () |
void | alwaysForwardNotifications () |
void | recalculate () |
void | freeze () |
void | unfreeze () |
Public Member Functions inherited from Observable | |
Observable () | |
Observable (const Observable &) | |
Observable & | operator= (const Observable &) |
Observable (Observable &&)=delete | |
Observable & | operator= (Observable &&)=delete |
virtual | ~Observable ()=default |
void | notifyObservers () |
Public Member Functions inherited from Observer | |
Observer ()=default | |
Observer (const Observer &) | |
Observer & | operator= (const Observer &) |
virtual | ~Observer () |
std::pair< iterator, bool > | registerWith (const ext::shared_ptr< Observable > &) |
void | registerWithObservables (const ext::shared_ptr< Observer > &) |
Size | unregisterWith (const ext::shared_ptr< Observable > &) |
void | unregisterWithAll () |
virtual void | update ()=0 |
virtual void | deepUpdate () |
Calculations | |
Natural | settlementDays_ |
Calendar | calendar_ |
std::vector< Date > | notionalSchedule_ |
std::vector< Real > | notionals_ |
Leg | cashflows_ |
Leg | redemptions_ |
Date | maturityDate_ |
Date | issueDate_ |
Real | settlementValue_ |
Real | cleanPrice () const |
theoretical clean price More... | |
Real | dirtyPrice () const |
theoretical dirty price More... | |
Real | settlementValue () const |
theoretical settlement value More... | |
Rate | yield (const DayCounter &dc, Compounding comp, Frequency freq, Real accuracy=1.0e-8, Size maxEvaluations=100, Real guess=0.05, Bond::Price::Type priceType=Bond::Price::Clean) const |
theoretical bond yield More... | |
Real | cleanPrice (Rate yield, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const |
clean price given a yield and settlement date More... | |
Real | dirtyPrice (Rate yield, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date()) const |
dirty price given a yield and settlement date More... | |
Real | settlementValue (Real cleanPrice) const |
settlement value as a function of the clean price More... | |
Rate | yield (Real price, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date(), Real accuracy=1.0e-8, Size maxEvaluations=100, Real guess=0.05, Bond::Price::Type priceType=Bond::Price::Clean) const |
Rate | yield (Bond::Price price, const DayCounter &dc, Compounding comp, Frequency freq, Date settlementDate=Date(), Real accuracy=1.0e-8, Size maxEvaluations=100, Real guess=0.05) const |
yield given a price and settlement date More... | |
virtual Real | accruedAmount (Date d=Date()) const |
accrued amount at a given date More... | |
virtual Rate | nextCouponRate (Date d=Date()) const |
Rate | previousCouponRate (Date d=Date()) const |
Previous coupon already paid at a given date. More... | |
Date | nextCashFlowDate (Date d=Date()) const |
Date | previousCashFlowDate (Date d=Date()) const |
void | setupExpired () const override |
void | setupArguments (PricingEngine::arguments *) const override |
void | fetchResults (const PricingEngine::results *) const override |
void | addRedemptionsToCashflows (const std::vector< Real > &redemptions=std::vector< Real >()) |
void | setSingleRedemption (Real notional, Real redemption, const Date &date) |
void | setSingleRedemption (Real notional, const ext::shared_ptr< CashFlow > &redemption) |
void | calculateNotionalsFromCashflows () |
Additional Inherited Members | |
Public Types inherited from Observer | |
typedef set_type::iterator | iterator |
Protected Member Functions inherited from Instrument | |
void | calculate () const override |
void | performCalculations () const override |
Protected Member Functions inherited from LazyObject | |
Protected Attributes inherited from Instrument | |
Real | NPV_ |
Real | errorEstimate_ |
Date | valuationDate_ |
std::map< std::string, ext::any > | additionalResults_ |
ext::shared_ptr< PricingEngine > | engine_ |
Protected Attributes inherited from LazyObject | |
bool | calculated_ = false |
bool | frozen_ = false |
bool | alwaysForward_ |
Base bond class.
Derived classes must fill the uninitialized data members.
|
overridevirtual |
returns whether the instrument might have value greater than zero.
Implements Instrument.
Definition at line 103 of file bond.cpp.
|
overridevirtual |
This method allows to explicitly update the instance itself and nested observers. If notifications are disabled a call to this method ensures an update of such nested observers. It should be implemented in derived classes whenever applicable
Reimplemented from Observer.
Definition at line 367 of file bond.cpp.
const std::vector< Real > & notionals | ( | ) | const |
const Leg & cashflows | ( | ) | const |
const Leg & redemptions | ( | ) | const |
const ext::shared_ptr< CashFlow > & redemption | ( | ) | const |
Date startDate | ( | ) | const |
Date maturityDate | ( | ) | const |
Date issueDate | ( | ) | const |
Real cleanPrice | ( | ) | const |
theoretical clean price
The default bond settlement is used for calculation.
Definition at line 174 of file bond.cpp.
Real dirtyPrice | ( | ) | const |
theoretical dirty price
The default bond settlement is used for calculation.
Definition at line 178 of file bond.cpp.
Real settlementValue | ( | ) | const |
Rate yield | ( | const DayCounter & | dc, |
Compounding | comp, | ||
Frequency | freq, | ||
Real | accuracy = 1.0e-8 , |
||
Size | maxEvaluations = 100 , |
||
Real | guess = 0.05 , |
||
Bond::Price::Type | priceType = Bond::Price::Clean |
||
) | const |
Real cleanPrice | ( | Rate | yield, |
const DayCounter & | dc, | ||
Compounding | comp, | ||
Frequency | freq, | ||
Date | settlementDate = Date() |
||
) | const |
Real dirtyPrice | ( | Rate | yield, |
const DayCounter & | dc, | ||
Compounding | comp, | ||
Frequency | freq, | ||
Date | settlementDate = Date() |
||
) | const |
Rate yield | ( | Real | price, |
const DayCounter & | dc, | ||
Compounding | comp, | ||
Frequency | freq, | ||
Date | settlementDate = Date() , |
||
Real | accuracy = 1.0e-8 , |
||
Size | maxEvaluations = 100 , |
||
Real | guess = 0.05 , |
||
Bond::Price::Type | priceType = Bond::Price::Clean |
||
) | const |
Definition at line 238 of file bond.cpp.
Rate yield | ( | Bond::Price | price, |
const DayCounter & | dc, | ||
Compounding | comp, | ||
Frequency | freq, | ||
Date | settlementDate = Date() , |
||
Real | accuracy = 1.0e-8 , |
||
Size | maxEvaluations = 100 , |
||
Real | guess = 0.05 |
||
) | const |
Expected next coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the already-fixed not-yet-paid one.
The current bond settlement is used if no date is given.
Definition at line 275 of file bond.cpp.
Previous coupon already paid at a given date.
Expected previous coupon: depending on (the bond and) the given date the coupon can be historic, deterministic or expected in a stochastic sense. When the bond settlement date is used the coupon is the last paid one.
The current bond settlement is used if no date is given.
Definition at line 279 of file bond.cpp.
|
overrideprotectedvirtual |
This method must leave the instrument in a consistent state when the expiration condition is met.
Reimplemented from Instrument.
Definition at line 291 of file bond.cpp.
|
overrideprotectedvirtual |
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.
Reimplemented in ConvertibleBond.
Definition at line 296 of file bond.cpp.
|
overrideprotectedvirtual |
When a derived result structure is defined for an instrument, this method should be overridden to read from it. This is mandatory in case a pricing engine is used.
Reimplemented from Instrument.
Definition at line 305 of file bond.cpp.
|
protected |
This method can be called by derived classes in order to build redemption payments from the existing cash flows. It must be called after setting up the cashflows_ vector and will fill the notionalSchedule_, notionals_, and redemptions_ data members.
If given, the elements of the redemptions vector will multiply the amount of the redemption cash flow. The elements will be taken in base 100, i.e., a redemption equal to 100 does not modify the amount.
Definition at line 315 of file bond.cpp.
This method can be called by derived classes in order to build a bond with a single redemption payment. It will fill the notionalSchedule_, notionals_, and redemptions_ data members.
Definition at line 342 of file bond.cpp.
|
protected |
used internally to collect notional information from the coupons. It should not be called by derived classes, unless they already provide redemption cash flows (in which case they must set up the redemptions_ data member independently). It will fill the notionalSchedule_ and notionals_ data members.
Definition at line 374 of file bond.cpp.