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
EquityIndex Class Reference

Base class for equity indexes. More...

#include <equityindex.hpp>

+ Inheritance diagram for EquityIndex:
+ Collaboration diagram for EquityIndex:

Public Member Functions

 EquityIndex (std::string name, Calendar fixingCalendar, Currency currency, Handle< YieldTermStructure > interest={}, Handle< YieldTermStructure > dividend={}, Handle< Quote > spot={})
 
 EquityIndex (std::string name, Calendar fixingCalendar, Handle< YieldTermStructure > interest={}, Handle< YieldTermStructure > dividend={}, Handle< Quote > spot={})
 
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...
 
Inspectors
Currency currency () const
 The index currency. More...
 
Handle< YieldTermStructureequityInterestRateCurve () const
 the rate curve used to forecast fixings More...
 
Handle< YieldTermStructureequityDividendCurve () const
 the dividend curve used to forecast fixings More...
 
Handle< Quotespot () const
 index spot value More...
 
Fixing calculations
virtual Real forecastFixing (const Date &fixingDate) const
 It can be overridden to implement particular conventions. More...
 
- 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 ()
 

Other methods

std::string name_
 
Calendar fixingCalendar_
 
Currency currency_
 
Handle< YieldTermStructureinterest_
 
Handle< YieldTermStructuredividend_
 
Handle< Quotespot_
 
virtual ext::shared_ptr< EquityIndexclone (const Handle< YieldTermStructure > &interest, const Handle< YieldTermStructure > &dividend, const Handle< Quote > &spot) const
 

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 equity indexes.

The equity index object allows to retrieve past fixings, as well as project future fixings using either both the risk free interest rate term structure and the dividend term structure, or just the interest rate term structure in which case one can provide a term structure of equity forwards implied from, e.g. option prices.

In case of the first method, the forward is calculated as:

\[ I(t, T) = I(t, t) \frac{P_{D}(t, T)}{P_{R}(t, T)}, \]

where \( I(t, t) \) is today's value of the index, \( P_{D}(t, T) \) is a discount factor of the dividend curve at future time \( T \), and \( P_{R}(t, T) \) is a discount factor of the risk free curve at future time \( T \).

In case of the latter method, the forward is calculated as:

\[ I(t, T) = I(t, t) \frac{1}{P_{F}(t, T)}, \]

where \( P_{F}(t, T) \) is a discount factor of the equity forward term structure.

To forecast future fixings, the user can either provide a handle to the current index spot. If spot handle is empty, today's fixing will be used, instead.

Definition at line 63 of file equityindex.hpp.

Constructor & Destructor Documentation

◆ EquityIndex() [1/2]

EquityIndex ( std::string  name,
Calendar  fixingCalendar,
Currency  currency,
Handle< YieldTermStructure interest = {},
Handle< YieldTermStructure dividend = {},
Handle< Quote spot = {} 
)

Definition at line 46 of file equityindex.cpp.

+ Here is the call graph for this function:

◆ EquityIndex() [2/2]

EquityIndex ( std::string  name,
Calendar  fixingCalendar,
Handle< YieldTermStructure interest = {},
Handle< YieldTermStructure dividend = {},
Handle< Quote spot = {} 
)
Deprecated:
Use the constructor taking a currency. Deprecated in version 1.36.

Definition at line 34 of file equityindex.cpp.

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 84 of file equityindex.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 85 of file equityindex.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 122 of file equityindex.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 63 of file equityindex.cpp.

+ Here is the call graph for this function:

◆ currency()

Currency currency ( ) const

The index currency.

Definition at line 92 of file equityindex.hpp.

+ Here is the caller graph for this function:

◆ equityInterestRateCurve()

Handle< YieldTermStructure > equityInterestRateCurve ( ) const

the rate curve used to forecast fixings

Definition at line 94 of file equityindex.hpp.

◆ equityDividendCurve()

Handle< YieldTermStructure > equityDividendCurve ( ) const

the dividend curve used to forecast fixings

Definition at line 96 of file equityindex.hpp.

◆ spot()

Handle< Quote > spot ( ) const

index spot value

Definition at line 98 of file equityindex.hpp.

+ Here is the caller graph for this function:

◆ forecastFixing()

Real forecastFixing ( const Date fixingDate) const
virtual

It can be overridden to implement particular conventions.

Definition at line 86 of file equityindex.cpp.

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

◆ clone()

ext::shared_ptr< EquityIndex > clone ( const Handle< YieldTermStructure > &  interest,
const Handle< YieldTermStructure > &  dividend,
const Handle< Quote > &  spot 
) const
virtual

returns a copy of itself linked to different interest, dividend curves or spot quote

Definition at line 104 of file equityindex.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 114 of file equityindex.hpp.

◆ fixingCalendar_

Calendar fixingCalendar_
private

Definition at line 115 of file equityindex.hpp.

◆ currency_

Currency currency_
private

Definition at line 116 of file equityindex.hpp.

◆ interest_

Handle<YieldTermStructure> interest_
private

Definition at line 117 of file equityindex.hpp.

◆ dividend_

Handle<YieldTermStructure> dividend_
private

Definition at line 118 of file equityindex.hpp.

◆ spot_

Handle<Quote> spot_
private

Definition at line 119 of file equityindex.hpp.