QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
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 (const 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
 
Observer interface
void update () override
 
- Public Member Functions inherited from Observable
 Observable ()
 
 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_
 
TimeSeries< Realquotes_
 
ext::shared_ptr< CommodityCurveforwardCurve_
 
Real forwardCurveUomConversionFactor_ = 1
 
ext::shared_ptr< ExchangeContractsexchangeContracts_
 
Integer nearbyOffset_
 
const CommodityTypecommodityType () const
 
const Currencycurrency () const
 
const UnitOfMeasureunitOfMeasure () const
 
const Calendarcalendar () const
 
const ext::shared_ptr< CommodityCurve > & forwardCurve () const
 
Real lotQuantity () const
 
Real price (const Date &date)
 
Real forwardPrice (const Date &date) const
 
Date lastQuoteDate () const
 
void addQuote (const Date &quoteDate, Real quote)
 
void addQuotes (const std::map< Date, Real > &quotes)
 
void clearQuotes () const
 
bool isValidQuoteDate (const Date &quoteDate) const
 returns TRUE if the quote date is valid More...
 
bool empty () const
 
bool forwardCurveEmpty () 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
 

Detailed Description

base class for commodity indexes

Definition at line 35 of file commodityindex.hpp.

Constructor & Destructor Documentation

◆ CommodityIndex()

CommodityIndex ( const 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

Definition at line 112 of file commodityindex.hpp.

+ 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 108 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ commodityType()

const CommodityType & commodityType ( ) const

Definition at line 116 of file commodityindex.hpp.

◆ currency()

const Currency & currency ( ) const

Definition at line 124 of file commodityindex.hpp.

◆ unitOfMeasure()

const UnitOfMeasure & unitOfMeasure ( ) const

Definition at line 120 of file commodityindex.hpp.

◆ calendar()

const Calendar & calendar ( ) const

Definition at line 128 of file commodityindex.hpp.

+ Here is the caller graph for this function:

◆ forwardCurve()

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

Definition at line 137 of file commodityindex.hpp.

◆ lotQuantity()

Real lotQuantity ( ) const

Definition at line 132 of file commodityindex.hpp.

◆ price()

Real price ( const Date date)

Definition at line 145 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ forwardPrice()

Real forwardPrice ( const Date date) const

Definition at line 156 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 167 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ addQuote()

void addQuote ( const Date quoteDate,
Real  quote 
)

Definition at line 183 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ addQuotes()

void addQuotes ( const std::map< Date, Real > &  quotes)

Definition at line 70 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ clearQuotes()

void clearQuotes ( ) const

Definition at line 193 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ isValidQuoteDate()

bool isValidQuoteDate ( const Date quoteDate) const

returns TRUE if the quote date is valid

Definition at line 197 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ empty()

bool empty ( ) const

Definition at line 173 of file commodityindex.hpp.

+ Here is the call graph for this function:

◆ forwardCurveEmpty()

bool forwardCurveEmpty ( ) const

Definition at line 177 of file commodityindex.hpp.

◆ quotes()

const TimeSeries< Real > & quotes ( ) const

Definition at line 141 of file commodityindex.hpp.

+ 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 54 of file commodityindex.cpp.

Member Data Documentation

◆ name_

std::string name_
protected

Definition at line 88 of file commodityindex.hpp.

◆ commodityType_

CommodityType commodityType_
protected

Definition at line 89 of file commodityindex.hpp.

◆ unitOfMeasure_

UnitOfMeasure unitOfMeasure_
protected

Definition at line 90 of file commodityindex.hpp.

◆ currency_

Currency currency_
protected

Definition at line 91 of file commodityindex.hpp.

◆ calendar_

Calendar calendar_
protected

Definition at line 92 of file commodityindex.hpp.

◆ lotQuantity_

Real lotQuantity_
protected

Definition at line 93 of file commodityindex.hpp.

◆ quotes_

TimeSeries<Real> quotes_
protected

Definition at line 94 of file commodityindex.hpp.

◆ forwardCurve_

ext::shared_ptr<CommodityCurve> forwardCurve_
protected

Definition at line 95 of file commodityindex.hpp.

◆ forwardCurveUomConversionFactor_

Real forwardCurveUomConversionFactor_ = 1
protected

Definition at line 96 of file commodityindex.hpp.

◆ exchangeContracts_

ext::shared_ptr<ExchangeContracts> exchangeContracts_
protected

Definition at line 97 of file commodityindex.hpp.

◆ nearbyOffset_

Integer nearbyOffset_
protected

Definition at line 98 of file commodityindex.hpp.