Logo
Reference manual - version qle_version
CommodityIndex Class Referenceabstract

Commodity Index. More...

#include <qle/indexes/commodityindex.hpp>

Inheritance diagram for CommodityIndex:

Public Member Functions

 CommodityIndex (const std::string &underlyingName, const QuantLib::Date &expiryDate, const Calendar &fixingCalendar, const Handle< QuantExt::PriceTermStructure > &priceCurve=Handle< QuantExt::PriceTermStructure >(), const QuantLib::Date &optionExpiryDate=QuantLib::Date())
 CommodityIndex (const std::string &underlyingName, const QuantLib::Date &expiryDate, const Calendar &fixingCalendar, bool keepDays, const Handle< QuantExt::PriceTermStructure > &priceCurve=Handle< QuantExt::PriceTermStructure >(), const QuantLib::Date &optionExpiryDate=QuantLib::Date())
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
Inspectors
std::string underlyingName () const
const Handle< QuantExt::PriceTermStructure > & priceCurve () const
bool isFuturesIndex () const
const QuantLib::Date & expiryDate () const
const QuantLib::Date & optionExpiryDate () const
bool keepDays () const

Fixing calculations

std::string underlyingName_
Date expiryDate_
Calendar fixingCalendar_
Handle< QuantExt::PriceTermStructurecurve_
std::string name_
bool isFuturesIndex_
bool keepDays_
Date optionExpiryDate_
virtual Real forecastFixing (const Date &fixingDate) const
virtual Real forecastFixing (const Time &fixingTime) const override
 returns the fixing at the given time
virtual Real pastFixing (const Date &fixingDate) const override
 returns a past fixing at the given date
virtual QuantLib::ext::shared_ptr< CommodityIndexclone (const QuantLib::Date &expiryDate=QuantLib::Date(), const Date &optionExpiryDate=QuantLib::Date(), const QuantLib::ext::optional< QuantLib::Handle< PriceTermStructure > > &ts=QuantLib::ext::nullopt) const =0
void init ()

Detailed Description

Commodity Index.

This index can represent both spot and futures prices. In the latter case the constructor needs to be called with the futures expiry date. If the expiry date is set to Date(), the index is interpreted as spot index.

If it is spot index, the index name() is set to the underlying name passed to the constructor prefixed by "COMM-".

If it is a futures index and keepDays_ is false, we set the name() to "COMM-" + underlyingName + "-" + "yyyy-mm", where "yyyy" is the expiry date's year and "mm" is the expiry date's month. The index forecast for fixing Date yields the price curve's forecast to the futures expiry instead which is beyond the fixing date. If keepDays_ is true, the date suffix in the name is "yyyy-mm-dd" i.e. we keep the full date. This is useful for commodities whose expiry cycle is less than one month e.g. daily.

Constructor & Destructor Documentation

◆ CommodityIndex()

CommodityIndex ( const std::string & underlyingName,
const QuantLib::Date & expiryDate,
const Calendar & fixingCalendar,
const Handle< QuantExt::PriceTermStructure > & priceCurve = Handle< QuantExt::PriceTermStructure >(),
const QuantLib::Date & optionExpiryDate = QuantLib::Date() )

spot quote is interpreted as of today

Member Function Documentation

◆ forecastFixing()

virtual Real forecastFixing ( const Time & fixingTime) const
overridevirtual

returns the fixing at the given time

Implements EqFxIndexBase.

◆ pastFixing()

virtual Real pastFixing ( const Date & fixingDate) const
overridevirtual

returns a past fixing at the given date

the date passed as arguments must be the actual calendar date of the fixing; no settlement days must be used.

Implements EqFxIndexBase.

Reimplemented in OffPeakPowerIndex.

◆ clone()

virtual QuantLib::ext::shared_ptr< CommodityIndex > clone ( const QuantLib::Date & expiryDate = QuantLib::Date(),
const Date & optionExpiryDate = QuantLib::Date(),
const QuantLib::ext::optional< QuantLib::Handle< PriceTermStructure > > & ts = QuantLib::ext::nullopt ) const
pure virtual

Returns a copy of itself with a potentially different expiry date and pricing curve.

If the expiryDate is an empty Date, it is ignored and the CommodityIndex instance's expiry date is used. If the ts is uninitialised, it is ignored and the CommodityIndex instance's price curve is used.

Implemented in CommodityFuturesIndex, and CommoditySpotIndex.