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

Commodity term structure. More...

#include <commoditycurve.hpp>

+ Inheritance diagram for CommodityCurve:
+ Collaboration diagram for CommodityCurve:

Public Member Functions

 CommodityCurve (std::string name, CommodityType commodityType, Currency currency, UnitOfMeasure unitOfMeasure, const Calendar &calendar, const std::vector< Date > &dates, std::vector< Real > prices, const DayCounter &dayCounter=Actual365Fixed())
 
 CommodityCurve (std::string name, CommodityType commodityType, Currency currency, UnitOfMeasure unitOfMeasure, const Calendar &calendar, const DayCounter &dayCounter=Actual365Fixed())
 
- Public Member Functions inherited from TermStructure
 TermStructure (DayCounter dc=DayCounter())
 default constructor More...
 
 TermStructure (const Date &referenceDate, Calendar calendar=Calendar(), DayCounter dc=DayCounter())
 initialize with a fixed reference date More...
 
 TermStructure (Natural settlementDays, Calendar, DayCounter dc=DayCounter())
 calculate the reference date based on the global evaluation date More...
 
 ~TermStructure () override=default
 
virtual DayCounter dayCounter () const
 the day counter used for date/time conversion More...
 
Time timeFromReference (const Date &date) const
 date/time conversion More...
 
virtual Time maxTime () const
 the latest time for which the curve can return values More...
 
virtual const DatereferenceDate () const
 the date at which discount = 1.0 and/or variance = 0.0 More...
 
virtual Calendar calendar () const
 the calendar used for reference and/or option date calculation More...
 
virtual Natural settlementDays () const
 the settlementDays used for reference date calculation More...
 
void update () override
 
- 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 ()
 
- 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 Extrapolator
 Extrapolator ()=default
 
virtual ~Extrapolator ()=default
 
void enableExtrapolation (bool b=true)
 enable extrapolation in subsequent calls More...
 
void disableExtrapolation (bool b=true)
 disable extrapolation in subsequent calls More...
 
bool allowsExtrapolation () const
 tells whether extrapolation is enabled More...
 

Friends

class CommodityIndex
 

Inspectors

std::ostream & operator<< (std::ostream &out, const CommodityCurve &curve)
 
std::string name_
 
CommodityType commodityType_
 
UnitOfMeasure unitOfMeasure_
 
Currency currency_
 
std::vector< Datedates_
 
std::vector< Timetimes_
 
std::vector< Realdata_
 
Interpolation interpolation_
 
ForwardFlat interpolator_
 
ext::shared_ptr< CommodityCurvebasisOfCurve_
 
Real basisOfCurveUomConversionFactor_
 
const std::string & name () const
 
const CommodityTypecommodityType () const
 
const UnitOfMeasureunitOfMeasure () const
 
const Currencycurrency () const
 
Date maxDate () const override
 the latest date for which the curve can return values More...
 
const std::vector< Time > & times () const
 
const std::vector< Date > & dates () const
 
const std::vector< Real > & prices () const
 
std::vector< std::pair< Date, Real > > nodes () const
 
bool empty () const
 
void setPrices (std::map< Date, Real > &prices)
 
void setBasisOfCurve (const ext::shared_ptr< CommodityCurve > &basisOfCurve)
 
Real price (const Date &d, const ext::shared_ptr< ExchangeContracts > &exchangeContracts, Integer nearbyOffset) const
 
Real basisOfPrice (const Date &d) const
 
Date underlyingPriceDate (const Date &date, const ext::shared_ptr< ExchangeContracts > &exchangeContracts, Integer nearbyOffset) const
 
const ext::shared_ptr< CommodityCurve > & basisOfCurve () const
 
Real basisOfPriceImpl (Time t) const
 
Real priceImpl (Time t) const
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from TermStructure
void checkRange (const Date &d, bool extrapolate) const
 date-range check More...
 
void checkRange (Time t, bool extrapolate) const
 time-range check More...
 
- Protected Attributes inherited from TermStructure
bool moving_ = false
 
bool updated_ = true
 
Calendar calendar_
 

Detailed Description

Commodity term structure.

Definition at line 38 of file commoditycurve.hpp.

Constructor & Destructor Documentation

◆ CommodityCurve() [1/2]

CommodityCurve ( std::string  name,
CommodityType  commodityType,
Currency  currency,
UnitOfMeasure  unitOfMeasure,
const Calendar calendar,
const std::vector< Date > &  dates,
std::vector< Real prices,
const DayCounter dayCounter = Actual365Fixed() 
)

Definition at line 26 of file commoditycurve.cpp.

+ Here is the call graph for this function:

◆ CommodityCurve() [2/2]

CommodityCurve ( std::string  name,
CommodityType  commodityType,
Currency  currency,
UnitOfMeasure  unitOfMeasure,
const Calendar calendar,
const DayCounter dayCounter = Actual365Fixed() 
)

Definition at line 57 of file commoditycurve.cpp.

Member Function Documentation

◆ name()

const std::string & name ( ) const

Definition at line 126 of file commoditycurve.hpp.

+ Here is the caller graph for this function:

◆ commodityType()

const CommodityType & commodityType ( ) const

Definition at line 114 of file commoditycurve.hpp.

◆ unitOfMeasure()

const UnitOfMeasure & unitOfMeasure ( ) const

Definition at line 118 of file commoditycurve.hpp.

◆ currency()

const Currency & currency ( ) const

Definition at line 122 of file commoditycurve.hpp.

◆ maxDate()

Date maxDate ( ) const
overridevirtual

the latest date for which the curve can return values

Implements TermStructure.

Definition at line 130 of file commoditycurve.hpp.

◆ times()

const std::vector< Time > & times ( ) const

Definition at line 134 of file commoditycurve.hpp.

◆ dates()

const std::vector< Date > & dates ( ) const

Definition at line 138 of file commoditycurve.hpp.

◆ prices()

const std::vector< Real > & prices ( ) const

Definition at line 142 of file commoditycurve.hpp.

+ Here is the caller graph for this function:

◆ nodes()

std::vector< std::pair< Date, Real > > nodes ( ) const

Definition at line 155 of file commoditycurve.hpp.

◆ empty()

bool empty ( ) const

Definition at line 146 of file commoditycurve.hpp.

◆ setPrices()

void setPrices ( std::map< Date, Real > &  prices)

Definition at line 68 of file commoditycurve.cpp.

+ Here is the call graph for this function:

◆ setBasisOfCurve()

void setBasisOfCurve ( const ext::shared_ptr< CommodityCurve > &  basisOfCurve)

Definition at line 89 of file commoditycurve.cpp.

+ Here is the call graph for this function:

◆ price()

Real price ( const Date d,
const ext::shared_ptr< ExchangeContracts > &  exchangeContracts,
Integer  nearbyOffset 
) const

Definition at line 168 of file commoditycurve.hpp.

+ Here is the call graph for this function:

◆ basisOfPrice()

Real basisOfPrice ( const Date d) const

Definition at line 162 of file commoditycurve.hpp.

+ Here is the call graph for this function:

◆ underlyingPriceDate()

Date underlyingPriceDate ( const Date date,
const ext::shared_ptr< ExchangeContracts > &  exchangeContracts,
Integer  nearbyOffset 
) const

Definition at line 187 of file commoditycurve.hpp.

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

◆ basisOfCurve()

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

Definition at line 151 of file commoditycurve.hpp.

+ Here is the caller graph for this function:

◆ basisOfPriceImpl()

Real basisOfPriceImpl ( Time  t) const
protected

Definition at line 205 of file commoditycurve.hpp.

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

◆ priceImpl()

Real priceImpl ( Time  t) const
protected

Definition at line 221 of file commoditycurve.hpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ CommodityIndex

friend class CommodityIndex
friend

Definition at line 39 of file commoditycurve.hpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const CommodityCurve curve 
)
friend

Definition at line 99 of file commoditycurve.cpp.

Member Data Documentation

◆ name_

std::string name_
protected

Definition at line 92 of file commoditycurve.hpp.

◆ commodityType_

CommodityType commodityType_
protected

Definition at line 93 of file commoditycurve.hpp.

◆ unitOfMeasure_

UnitOfMeasure unitOfMeasure_
protected

Definition at line 94 of file commoditycurve.hpp.

◆ currency_

Currency currency_
protected

Definition at line 95 of file commoditycurve.hpp.

◆ dates_

std::vector<Date> dates_
mutableprotected

Definition at line 96 of file commoditycurve.hpp.

◆ times_

std::vector<Time> times_
mutableprotected

Definition at line 97 of file commoditycurve.hpp.

◆ data_

std::vector<Real> data_
mutableprotected

Definition at line 98 of file commoditycurve.hpp.

◆ interpolation_

Interpolation interpolation_
mutableprotected

Definition at line 99 of file commoditycurve.hpp.

◆ interpolator_

ForwardFlat interpolator_
protected

Definition at line 100 of file commoditycurve.hpp.

◆ basisOfCurve_

ext::shared_ptr<CommodityCurve> basisOfCurve_
protected

Definition at line 101 of file commoditycurve.hpp.

◆ basisOfCurveUomConversionFactor_

Real basisOfCurveUomConversionFactor_
protected

Definition at line 102 of file commoditycurve.hpp.