Logo
Reference manual - version qle_version
Public Member Functions | List of all members
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 >())
 
 CommodityIndex (const std::string &underlyingName, const QuantLib::Date &expiryDate, const Calendar &fixingCalendar, bool keepDays, const Handle< QuantExt::PriceTermStructure > &priceCurve=Handle< QuantExt::PriceTermStructure >())
 
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
 
bool keepDays () const
 

Fixing calculations

std::string underlyingName_
 
Date expiryDate_
 
Calendar fixingCalendar_
 
Handle< QuantExt::PriceTermStructurecurve_
 
std::string name_
 
bool isFuturesIndex_
 
bool keepDays_
 
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 More...
 
virtual boost::shared_ptr< CommodityIndexclone (const QuantLib::Date &expiryDate=QuantLib::Date(), const boost::optional< QuantLib::Handle< PriceTermStructure >> &ts=boost::none) 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 >() 
)

spot quote is interpreted as of today

Member Function Documentation

◆ 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 boost::shared_ptr<CommodityIndex> clone ( const QuantLib::Date &  expiryDate = QuantLib::Date(),
const boost::optional< QuantLib::Handle< PriceTermStructure >> &  ts = boost::none 
) 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, CommoditySpotIndex, CommodityBasisFutureIndex, and OffPeakPowerIndex.