Logo
Reference manual - version qle_version
BondIndex Class Reference

Bond Index. More...

#include <qle/indexes/bondindex.hpp>

Inheritance diagram for BondIndex:

Public Types

enum class  PriceQuoteMethod { PercentageOfPar , CurrencyPerUnit }

Public Member Functions

 BondIndex (const std::string &securityName, const bool dirty=false, const bool relative=true, const Calendar &fixingCalendar=NullCalendar(), const QuantLib::ext::shared_ptr< QuantLib::Bond > &bond=nullptr, const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const Handle< DefaultProbabilityTermStructure > &defaultCurve=Handle< DefaultProbabilityTermStructure >(), const Handle< Quote > &recoveryRate=Handle< Quote >(), const Handle< Quote > &securitySpread=Handle< Quote >(), const Handle< YieldTermStructure > &incomeCurve=Handle< YieldTermStructure >(), const bool conditionalOnSurvival=true, const Date &issueDate=Date(), const PriceQuoteMethod priceQuoteMethod=PriceQuoteMethod::PercentageOfPar, const double priceQuoteBaseValue=1.0, const bool isInflationLinked=false, const double bidAskAdjustment=0.0, const bool bondIssueDateFallback=false, const std::optional< QuantLib::Bond::Price::Type > &quotedDirtyPrices=QuantLib::Bond::Price::Type::Clean)
Index interface
std::string name () const override
Calendar fixingCalendar () const override
bool isValidFixingDate (const Date &fixingDate) const override
Real fixing (const Date &fixingDate, bool forecastTodaysFixing=false) const override
Observer interface
void update () override
Fixing calculations
virtual Rate forecastFixing (const Date &fixingDate) const
Rate pastFixing (const Date &fixingDate) const override

Inspectors

std::string securityName_
bool dirty_
bool relative_
Calendar fixingCalendar_
QuantLib::ext::shared_ptr< QuantLib::Bond > bond_
Handle< YieldTermStructure > discountCurve_
Handle< DefaultProbabilityTermStructure > defaultCurve_
Handle< QuoterecoveryRate_
Handle< QuotesecuritySpread_
Handle< YieldTermStructure > incomeCurve_
bool conditionalOnSurvival_
Date issueDate_
PriceQuoteMethod priceQuoteMethod_
double priceQuoteBaseValue_
bool isInflationLinked_
double bidAskAdjustment_
bool bondIssueDateFallback_ = false
std::optional< QuantLib::Bond::Price::Type > quotedDirtyPrices_ = QuantLib::Bond::Price::Type::Clean
const std::string & securityName () const
bool dirty () const
bool relative () const
QuantLib::ext::shared_ptr< QuantLib::Bond > bond () const
Handle< YieldTermStructure > discountCurve () const
Handle< DefaultProbabilityTermStructure > defaultCurve () const
Handle< QuoterecoveryRate () const
Handle< QuotesecuritySpread () const
Handle< YieldTermStructure > incomeCurve () const
bool conditionalOnSurvival () const
Date issueDate () const
PriceQuoteMethod priceQuoteMethod () const
double priceQuoteBaseValue () const
const std::optional< QuantLib::Bond::Price::Type > & quotedDirtyPrices () const

Detailed Description

Bond Index.

Constructor & Destructor Documentation

◆ BondIndex()

BondIndex ( const std::string & securityName,
const bool dirty = false,
const bool relative = true,
const Calendar & fixingCalendar = NullCalendar(),
const QuantLib::ext::shared_ptr< QuantLib::Bond > & bond = nullptr,
const Handle< YieldTermStructure > & discountCurve = Handle< YieldTermStructure >(),
const Handle< DefaultProbabilityTermStructure > & defaultCurve = Handle< DefaultProbabilityTermStructure >(),
const Handle< Quote > & recoveryRate = Handle< Quote >(),
const Handle< Quote > & securitySpread = Handle< Quote >(),
const Handle< YieldTermStructure > & incomeCurve = Handle< YieldTermStructure >(),
const bool conditionalOnSurvival = true,
const Date & issueDate = Date(),
const PriceQuoteMethod priceQuoteMethod = PriceQuoteMethod::PercentageOfPar,
const double priceQuoteBaseValue = 1.0,
const bool isInflationLinked = false,
const double bidAskAdjustment = 0.0,
const bool bondIssueDateFallback = false,
const std::optional< QuantLib::Bond::Price::Type > & quotedDirtyPrices = QuantLib::Bond::Price::Type::Clean )

The values that this index return are of the form

  • 1.02 meaning 102% price clean or dirty (depending on the flag dirty in the ctor) i.e. the absolute bond clean or dirty NPV is divided by the current notional at the fixing date
  • 10020 meaning an absolute NPV in terms of the current notional of the underlying bond at the fixing date, again clean or dirty depending on the flag dirty in the ctor, here the notional would be 10000

The first form is returned if the flag relative in the ctor is set to true, the second if this flag is set to false.

The fixing projection (fixingDate > today) assumes that the given bond is vanilla, i.e. its present value can be calculated by discounting the cashflows retrieved with Bond::cashflows().

If the bond has a pricing engine attached and today's fixing is projected, the pricing engine's result will be used. Otherwise today's fixing will be calculated as projected fixings for dates > today, i.e. by simply discounting the bond's cashflows.

If no bond is given, only historical fixings are returned by the index and only the clean price mode and relative price mode are supported respectively. Otherwise an exception is thrown whenever a fixing is requested from the index.

To compute projected fixings for dates > today, a discountCurve is required. The other quotes and curves are optional and default as follows:

  • defaultCurve: defaults to zero hazard spread
  • recoveryRate: defaults to zero
  • securitySpread: defaults to zero
  • incomCurve: defaults to the curve build as discountCurve + securitySpread

If conditionalOnSurvival is set to true, a projected fixing will be conditional on survival until the associated bond settlement date, otherwise it will include the default probability between today and the settlement date.

If priceQuoteMethod = CurrencyPerUnit, a fixing in the fixing history will be divided by priceQuoteBaseValue before returning it.