QuantLib: a free/open-source library for quantitative finance
Reference manual - version 1.40
Loading...
Searching...
No Matches
CPICoupon Class Reference

Coupon paying the performance of a CPI (zero inflation) index More...

#include <ql/cashflows/cpicoupon.hpp>

Inheritance diagram for CPICoupon:

Public Member Functions

Constructors
 CPICoupon (Real baseCPI, const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const ext::shared_ptr< ZeroInflationIndex > &index, const Period &observationLag, CPI::InterpolationType observationInterpolation, const DayCounter &dayCounter, Real fixedRate, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
 CPICoupon (const Date &baseDate, const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const ext::shared_ptr< ZeroInflationIndex > &index, const Period &observationLag, CPI::InterpolationType observationInterpolation, const DayCounter &dayCounter, Real fixedRate, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
 CPICoupon (Real baseCPI, const Date &baseDate, const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const ext::shared_ptr< ZeroInflationIndex > &index, const Period &observationLag, CPI::InterpolationType observationInterpolation, const DayCounter &dayCounter, Real fixedRate, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
Inspectors
Real fixedRate () const
 fixed rate that will be inflated by the index ratio
Rate baseCPI () const
 base value for the CPI index
Date baseDate () const
 base date for the base fixing of the CPI index
CPI::InterpolationType observationInterpolation () const
 how do you observe the index? as-is, flat, linear?
ext::shared_ptr< ZeroInflationIndexcpiIndex () const
 index used
Calculations
Real accruedAmount (const Date &) const override
 accrued amount at the given date
Rate indexFixing () const override
 the index value observed (with a lag) at the end date
Rate indexRatio (Date d) const
 the ratio between the index fixing at the passed date and the base CPI
Rate adjustedIndexGrowth () const
 the ratio between the end index fixing and the base CPI
Public Member Functions inherited from InflationCoupon
 InflationCoupon (const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, ext::shared_ptr< InflationIndex > index, const Period &observationLag, DayCounter dayCounter, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
Real amount () const override
 returns the amount of the cash flow
Real price (const Handle< YieldTermStructure > &discountingCurve) const
DayCounter dayCounter () const override
 day counter for accrual calculation
Real accruedAmount (const Date &) const override
 accrued amount at the given date
Rate rate () const override
 accrued rate
const ext::shared_ptr< InflationIndex > & index () const
 yoy inflation index
Period observationLag () const
 how the coupon observes the index
Natural fixingDays () const
 fixing days
virtual Date fixingDate () const
 fixing date
void performCalculations () const override
void accept (AcyclicVisitor &) override
void setPricer (const ext::shared_ptr< InflationCouponPricer > &)
ext::shared_ptr< InflationCouponPricerpricer () const
Public Member Functions inherited from Coupon
 Coupon (const Date &paymentDate, Real nominal, const Date &accrualStartDate, const Date &accrualEndDate, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const Date &exCouponDate=Date())
Date date () const override
Date exCouponDate () const override
 returns the date that the cash flow trades exCoupon
virtual Real nominal () const
const DateaccrualStartDate () const
 start of the accrual period
const DateaccrualEndDate () const
 end of the accrual period
const DatereferencePeriodStart () const
 start date of the reference period
const DatereferencePeriodEnd () const
 end date of the reference period
Time accrualPeriod () const
 accrual period as fraction of year
Date::serial_type accrualDays () const
 accrual period in days
Time accruedPeriod (const Date &) const
 accrued period as fraction of year at the given date
Date::serial_type accruedDays (const Date &) const
 accrued days at the given date
Public Member Functions inherited from CashFlow
bool hasOccurred (const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const override
 returns true if an event has already occurred before a date
bool tradingExCoupon (const Date &refDate=Date()) const
 returns true if the cashflow is trading ex-coupon on the refDate
Public Member Functions inherited from Event
Public Member Functions inherited from Observable
 Observable (const Observable &)
Observableoperator= (const Observable &)
 Observable (Observable &&)=delete
Observableoperator= (Observable &&)=delete
void notifyObservers ()
Public Member Functions inherited from LazyObject
void update () override
bool isCalculated () const
void forwardFirstNotificationOnly ()
void alwaysForwardNotifications ()
void recalculate ()
void freeze ()
void unfreeze ()
Public Member Functions inherited from Observer
 Observer (const Observer &)
Observeroperator= (const 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 deepUpdate ()

Visitability

Real baseCPI_
Real fixedRate_
CPI::InterpolationType observationInterpolation_
Date baseDate_
void accept (AcyclicVisitor &) override
bool checkPricerImpl (const ext::shared_ptr< InflationCouponPricer > &) const override
 makes sure you were given the correct type of pricer

Additional Inherited Members

Public Types inherited from Observer
typedef set_type::iterator iterator
virtual void calculate () const
ext::shared_ptr< InflationCouponPricerpricer_
ext::shared_ptr< InflationIndexindex_
Period observationLag_
DayCounter dayCounter_
Natural fixingDays_
Real rate_
Date paymentDate_
Real nominal_
Date accrualStartDate_
Date accrualEndDate_
Date refPeriodStart_
Date refPeriodEnd_
Date exCouponDate_
Real accrualPeriod_
bool calculated_ = false
bool frozen_ = false
bool alwaysForward_

Detailed Description

Coupon paying the performance of a CPI (zero inflation) index

The performance is relative to the index value on the base date.

The other inflation value is taken from the refPeriodEnd date with observation lag, so any roll/calendar etc. will be built in by the caller. By default this is done in the InflationCoupon which uses ModifiedPreceding with fixing days assumed positive meaning earlier, i.e. always stay in same month (relative to referencePeriodEnd).

This is more sophisticated than an IndexedCashFlow because it does date calculations itself.

Constructor & Destructor Documentation

◆ CPICoupon() [1/3]

CPICoupon ( Real baseCPI,
const Date & paymentDate,
Real nominal,
const Date & startDate,
const Date & endDate,
const ext::shared_ptr< ZeroInflationIndex > & index,
const Period & observationLag,
CPI::InterpolationType observationInterpolation,
const DayCounter & dayCounter,
Real fixedRate,
const Date & refPeriodStart = Date(),
const Date & refPeriodEnd = Date(),
const Date & exCouponDate = Date() )

This constructor takes the base CPI to be used in the calculations.

◆ CPICoupon() [2/3]

CPICoupon ( const Date & baseDate,
const Date & paymentDate,
Real nominal,
const Date & startDate,
const Date & endDate,
const ext::shared_ptr< ZeroInflationIndex > & index,
const Period & observationLag,
CPI::InterpolationType observationInterpolation,
const DayCounter & dayCounter,
Real fixedRate,
const Date & refPeriodStart = Date(),
const Date & refPeriodEnd = Date(),
const Date & exCouponDate = Date() )

This constructor takes a base date; the coupon will use it to retrieve the base CPI to be used in the calculations.

◆ CPICoupon() [3/3]

CPICoupon ( Real baseCPI,
const Date & baseDate,
const Date & paymentDate,
Real nominal,
const Date & startDate,
const Date & endDate,
const ext::shared_ptr< ZeroInflationIndex > & index,
const Period & observationLag,
CPI::InterpolationType observationInterpolation,
const DayCounter & dayCounter,
Real fixedRate,
const Date & refPeriodStart = Date(),
const Date & refPeriodEnd = Date(),
const Date & exCouponDate = Date() )

This constructor takes both a base CPI and a base date. If both are passed, the base CPI is used in the calculations.

Member Function Documentation

◆ baseCPI()

Rate baseCPI ( ) const

base value for the CPI index

Warning
make sure that the interpolation used to create this is what you are using for the fixing, i.e. the observationInterpolation.

◆ accruedAmount()

Real accruedAmount ( const Date & ) const
overridevirtual

accrued amount at the given date

Implements Coupon.

◆ indexFixing()

Rate indexFixing ( ) const
overridevirtual

the index value observed (with a lag) at the end date

Reimplemented from InflationCoupon.

◆ indexRatio()

Rate indexRatio ( Date d) const

the ratio between the index fixing at the passed date and the base CPI

No adjustments are applied

◆ adjustedIndexGrowth()

Rate adjustedIndexGrowth ( ) const

the ratio between the end index fixing and the base CPI

This might include adjustments calculated by the pricer

◆ accept()

void accept ( AcyclicVisitor & )
overridevirtual

Reimplemented from Coupon.

◆ checkPricerImpl()

bool checkPricerImpl ( const ext::shared_ptr< InflationCouponPricer > & ) const
overrideprotectedvirtual

makes sure you were given the correct type of pricer

Implements InflationCoupon.