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
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, 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...
 
Observer interface
void update () override
 
Inspectors
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...
 
virtual Real pastFixing (const Date &fixingDate) const
 
- 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...
 
const TimeSeries< Real > & timeSeries () const
 returns the fixing TimeSeries More...
 
virtual bool allowsNativeFixings ()
 check if index allows for native fixings. More...
 
virtual void addFixing (const Date &fixingDate, Real fixing, bool forceOverwrite=false)
 stores the historical fixing at the given date More...
 
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 ()
 
 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_
 
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
 

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()

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

Definition at line 34 of file equityindex.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 73 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 74 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 113 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 49 of file equityindex.cpp.

+ Here is the call 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 117 of file equityindex.hpp.

+ Here is the call graph for this function:

◆ equityInterestRateCurve()

Handle< YieldTermStructure > equityInterestRateCurve ( ) const

the rate curve used to forecast fixings

Definition at line 85 of file equityindex.hpp.

◆ equityDividendCurve()

Handle< YieldTermStructure > equityDividendCurve ( ) const

the dividend curve used to forecast fixings

Definition at line 87 of file equityindex.hpp.

◆ spot()

Handle< Quote > spot ( ) const

index spot value

Definition at line 89 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 77 of file equityindex.cpp.

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

◆ pastFixing()

Real pastFixing ( const Date fixingDate) const
virtual

Definition at line 72 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 95 of file equityindex.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 106 of file equityindex.hpp.

◆ fixingCalendar_

Calendar fixingCalendar_
private

Definition at line 107 of file equityindex.hpp.

◆ interest_

Handle<YieldTermStructure> interest_
private

Definition at line 108 of file equityindex.hpp.

◆ dividend_

Handle<YieldTermStructure> dividend_
private

Definition at line 109 of file equityindex.hpp.

◆ spot_

Handle<Quote> spot_
private

Definition at line 110 of file equityindex.hpp.