QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CommodityIndex Class Reference

base class for commodity indexes More...

#include <commodityindex.hpp>

+ Inheritance diagram for CommodityIndex:
+ Collaboration diagram for CommodityIndex:

Public Member Functions

 CommodityIndex (std::string name, CommodityType commodityType, Currency currency, UnitOfMeasure unitOfMeasure, Calendar calendar, Real lotQuantity, ext::shared_ptr< CommodityCurve > forwardCurve, ext::shared_ptr< ExchangeContracts > exchangeContracts, int nearbyOffset)
 
Index interface
std::string name () const override
 Returns the name of the index. More...
 
Calendar fixingCalendar () const override
 returns the calendar defining valid fixing dates More...
 
bool isValidFixingDate (const Date &fixingDate) const override
 returns TRUE if the fixing date is a valid one More...
 
Real fixing (const Date &fixingDate, bool forecastTodaysFixing=false) const override
 returns the fixing at the given date More...
 
Observer interface
void update () override
 
- Public Member Functions inherited from Index
 ~Index () override=default
 
virtual std::string name () const =0
 Returns the name of the index. More...
 
virtual Calendar fixingCalendar () const =0
 returns the calendar defining valid fixing dates More...
 
virtual bool isValidFixingDate (const Date &fixingDate) const =0
 returns TRUE if the fixing date is a valid one More...
 
bool hasHistoricalFixing (const Date &fixingDate) const
 returns whether a historical fixing was stored for the given date More...
 
virtual Real fixing (const Date &fixingDate, bool forecastTodaysFixing=false) const =0
 returns the fixing at the given date More...
 
virtual Real pastFixing (const Date &fixingDate) const
 returns a past fixing at the given date More...
 
const TimeSeries< Real > & timeSeries () const
 returns the fixing TimeSeries More...
 
virtual bool allowsNativeFixings ()
 check if index allows for native fixings. More...
 
void update () override
 
virtual void addFixing (const Date &fixingDate, Real fixing, bool forceOverwrite=false)
 
void addFixings (const TimeSeries< Real > &t, bool forceOverwrite=false)
 stores historical fixings from a TimeSeries More...
 
template<class DateIterator , class ValueIterator >
void addFixings (DateIterator dBegin, DateIterator dEnd, ValueIterator vBegin, bool forceOverwrite=false)
 stores historical fixings at the given dates More...
 
void clearFixings ()
 clears all stored historical fixings More...
 
- Public Member Functions inherited from Observable
 Observable ()=default
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (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 ()
 

Inspectors

std::string name_
 
CommodityType commodityType_
 
UnitOfMeasure unitOfMeasure_
 
Currency currency_
 
Calendar calendar_
 
Real lotQuantity_
 
ext::shared_ptr< CommodityCurveforwardCurve_
 
Real forwardCurveUomConversionFactor_ = 1
 
ext::shared_ptr< ExchangeContractsexchangeContracts_
 
Integer nearbyOffset_
 
const CommodityTypecommodityType () const
 
const Currencycurrency () const
 
const UnitOfMeasureunitOfMeasure () const
 
const ext::shared_ptr< CommodityCurve > & forwardCurve () const
 
Real lotQuantity () const
 
Real forwardPrice (const Date &date) const
 
Date lastQuoteDate () const
 
bool empty () const
 
bool forwardCurveEmpty () const
 
const Calendarcalendar () const
 
Real price (const Date &date)
 
void addQuote (const Date &quoteDate, Real quote)
 
void addQuotes (const std::map< Date, Real > &quotes)
 
void clearQuotes ()
 
bool isValidQuoteDate (const Date &quoteDate) const
 
const TimeSeries< Real > & quotes () const
 
std::ostream & operator<< (std::ostream &, const CommodityIndex &)
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from Index
ext::shared_ptr< Observablenotifier () const
 

Detailed Description

base class for commodity indexes

Definition at line 35 of file commodityindex.hpp.

Constructor & Destructor Documentation

◆ CommodityIndex()

CommodityIndex ( std::string  name,
CommodityType  commodityType,
Currency  currency,
UnitOfMeasure  unitOfMeasure,
Calendar  calendar,
Real  lotQuantity,
ext::shared_ptr< CommodityCurve forwardCurve,
ext::shared_ptr< ExchangeContracts exchangeContracts,
int  nearbyOffset 
)

Definition at line 26 of file commodityindex.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ name()

std::string name ( ) const
overridevirtual

Returns the name of the index.

Warning:
This method is used for output and comparison between indexes. It is not meant to be used for writing switch-on-type code.

Implements Index.

Definition at line 154 of file commodityindex.hpp.

+ Here is the caller graph for this function:

◆ fixingCalendar()

Calendar fixingCalendar ( ) const
overridevirtual

returns the calendar defining valid fixing dates

Implements Index.

Definition at line 158 of file commodityindex.hpp.

+ Here is the caller graph for this function:

◆ isValidFixingDate()

bool isValidFixingDate ( const Date fixingDate) const
overridevirtual

returns TRUE if the fixing date is a valid one

Implements Index.

Definition at line 162 of file commodityindex.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixing()

Real fixing ( const Date fixingDate,
bool  forecastTodaysFixing = false 
) const
overridevirtual

returns the 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 Index.

Definition at line 166 of file commodityindex.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void update ( )
overridevirtual

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Implements Observer.

Definition at line 150 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ commodityType()

const CommodityType & commodityType ( ) const

Definition at line 170 of file commodityindex.hpp.

◆ currency()

const Currency & currency ( ) const

Definition at line 178 of file commodityindex.hpp.

◆ unitOfMeasure()

const UnitOfMeasure & unitOfMeasure ( ) const

Definition at line 174 of file commodityindex.hpp.

◆ forwardCurve()

const ext::shared_ptr< CommodityCurve > & forwardCurve ( ) const

Definition at line 187 of file commodityindex.hpp.

◆ lotQuantity()

Real lotQuantity ( ) const

Definition at line 182 of file commodityindex.hpp.

◆ forwardPrice()

Real forwardPrice ( const Date date) const

Definition at line 191 of file commodityindex.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lastQuoteDate()

Date lastQuoteDate ( ) const

Definition at line 202 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ empty()

bool empty ( ) const

Definition at line 206 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ forwardCurveEmpty()

bool forwardCurveEmpty ( ) const

Definition at line 210 of file commodityindex.hpp.

◆ calendar()

const Calendar & calendar ( ) const
Deprecated:
Use fixingCalendar instead. Deprecated in version 1.37.

Definition at line 75 of file commodityindex.hpp.

◆ price()

Real price ( const Date date)
Deprecated:
Use fixing instead. Deprecated in version 1.37.

Definition at line 83 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ addQuote()

void addQuote ( const Date quoteDate,
Real  quote 
)
Deprecated:
Use addFixing instead. Deprecated in version 1.37.

Definition at line 91 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ addQuotes()

void addQuotes ( const std::map< Date, Real > &  quotes)
Deprecated:
Use addFixings instead. Deprecated in version 1.37.

Definition at line 99 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ clearQuotes()

void clearQuotes ( )
Deprecated:
Use clearFixings instead. Deprecated in version 1.37.

Definition at line 109 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ isValidQuoteDate()

bool isValidQuoteDate ( const Date quoteDate) const
Deprecated:
Use isValidFixingDate instead. Deprecated in version 1.37.

Definition at line 117 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ quotes()

const TimeSeries< Real > & quotes ( ) const
Deprecated:
Use timeSeries instead. Deprecated in version 1.37.

Definition at line 125 of file commodityindex.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const CommodityIndex index 
)
friend

Definition at line 52 of file commodityindex.cpp.

Member Data Documentation

◆ name_

std::string name_
protected

Definition at line 131 of file commodityindex.hpp.

◆ commodityType_

CommodityType commodityType_
protected

Definition at line 132 of file commodityindex.hpp.

◆ unitOfMeasure_

UnitOfMeasure unitOfMeasure_
protected

Definition at line 133 of file commodityindex.hpp.

◆ currency_

Currency currency_
protected

Definition at line 134 of file commodityindex.hpp.

◆ calendar_

Calendar calendar_
protected

Definition at line 135 of file commodityindex.hpp.

◆ lotQuantity_

Real lotQuantity_
protected

Definition at line 136 of file commodityindex.hpp.

◆ forwardCurve_

ext::shared_ptr<CommodityCurve> forwardCurve_
protected

Definition at line 137 of file commodityindex.hpp.

◆ forwardCurveUomConversionFactor_

Real forwardCurveUomConversionFactor_ = 1
protected

Definition at line 138 of file commodityindex.hpp.

◆ exchangeContracts_

ext::shared_ptr<ExchangeContracts> exchangeContracts_
protected

Definition at line 139 of file commodityindex.hpp.

◆ nearbyOffset_

Integer nearbyOffset_
protected

Definition at line 140 of file commodityindex.hpp.