Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CompoEquityIndex Class Reference

#include <qle/indexes/compoequityindex.hpp>

+ Inheritance diagram for CompoEquityIndex:
+ Collaboration diagram for CompoEquityIndex:

Public Member Functions

 CompoEquityIndex (const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &source, const QuantLib::ext::shared_ptr< FxIndex > &fxIndex, const Date &dividendCutoffDate=Date())
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2source () const
 
void addDividend (const Dividend &dividend, bool forceOverwrite=false) override
 stores the historical dividend at the given date More...
 
const std::set< Dividend > & dividendFixings () const override
 
Real pastFixing (const Date &fixingDate) const override
 returns a past fixing at the given date More...
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2clone (const Handle< Quote > spotQuote, const Handle< YieldTermStructure > &rate, const Handle< YieldTermStructure > &dividend) const override
 
- Public Member Functions inherited from EquityIndex2
 EquityIndex2 (const std::string &familyName, const Calendar &fixingCalendar, const Currency &currency, const Handle< Quote > spotQuote=Handle< Quote >(), const Handle< YieldTermStructure > &rate=Handle< YieldTermStructure >(), const Handle< YieldTermStructure > &dividend=Handle< YieldTermStructure >())
 
std::string name () const override
 
Currency currency () const
 
Calendar fixingCalendar () const override
 
bool isValidFixingDate (const Date &fixingDate) const override
 
Real fixing (const Date &fixingDate, bool forecastTodaysFixing=false) const override
 
Real fixing (const Date &fixingDate, bool forecastTodaysFixing, bool incDividend) const
 
Real dividendsBetweenDates (const Date &startDate, const Date &endDate) const
 
void update () override
 
std::string familyName () const
 
const Handle< Quote > & equitySpot () const
 
const Handle< YieldTermStructure > & equityForecastCurve () const
 
const Handle< YieldTermStructure > & equityDividendCurve () const
 
virtual Real forecastFixing (const Date &fixingDate) const
 
virtual Real forecastFixing (const Time &fixingTime) const override
 returns the fixing at the given time More...
 
virtual Real forecastFixing (const Date &fixingDate, bool incDividend) const
 
virtual Real forecastFixing (const Time &fixingTime, bool incDividend) const
 
- Public Member Functions inherited from EqFxIndexBase
virtual ~EqFxIndexBase ()
 
virtual Real forecastFixing (const Time &fixingTime) const =0
 returns the fixing at the given time More...
 
virtual Real pastFixing (const Date &fixingDate) const =0
 returns a past fixing at the given date More...
 

Private Member Functions

void performCalculations () const override
 

Private Attributes

QuantLib::ext::shared_ptr< QuantExt::EquityIndex2source_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Date dividendCutoffDate_
 
std::set< DividenddividendFixings_
 

Additional Inherited Members

- Protected Attributes inherited from EquityIndex2
std::string familyName_
 
Currency currency_
 
const Handle< YieldTermStructure > rate_
 
const Handle< YieldTermStructure > dividend_
 
std::string name_
 
const Handle< Quote > spotQuote_
 

Detailed Description

Definition at line 34 of file compoequityindex.hpp.

Constructor & Destructor Documentation

◆ CompoEquityIndex()

CompoEquityIndex ( const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  source,
const QuantLib::ext::shared_ptr< FxIndex > &  fxIndex,
const Date &  dividendCutoffDate = Date() 
)
  • fxIndex source ccy must be the equity ccy, fxIndex target ccy is the new equity ccy
  • dividends before the divCutoffDate are ignored, this is useful since there have to be fixings for the fx index on all dividend dates which might not be available

Definition at line 27 of file compoequityindex.cpp.

29 : QuantExt::EquityIndex2(source->familyName() + "_compo_" + fxIndex->targetCurrency().code(),
30 JointCalendar(source->fixingCalendar(), fxIndex->fixingCalendar()), fxIndex->targetCurrency(),
31 Handle<Quote>(QuantLib::ext::make_shared<CompositeQuote<std::function<Real(Real, Real)>>>(
32 source->equitySpot(), fxIndex->fxQuote(),
33 std::function<Real(Real, Real)>([](Real x, Real y) { return x * y; }))),
34 Handle<YieldTermStructure>(QuantLib::ext::make_shared<DiscountRatioModifiedCurve>(
35 source->equityForecastCurve(), fxIndex->targetCurve(), fxIndex->sourceCurve())),
36 source->equityDividendCurve()),
37 source_(source), fxIndex_(fxIndex), dividendCutoffDate_(dividendCutoffDate) {
38 LazyObject::registerWith(source_);
39 LazyObject::registerWith(fxIndex_);
40}
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > source() const
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > source_

Member Function Documentation

◆ source()

QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > source ( ) const

Definition at line 42 of file compoequityindex.cpp.

42{ return source_; }

◆ addDividend()

void addDividend ( const Dividend fixing,
bool  forceOverwrite = false 
)
overridevirtual

stores the historical dividend at the given date

the date passed as arguments must be the actual calendar date of the dividend.

Reimplemented from EquityIndex2.

Definition at line 44 of file compoequityindex.cpp.

44 {
45 if (dividendCutoffDate_ == Date() || dividend.exDate >= dividendCutoffDate_) {
46 Dividend newDiv(dividend.exDate, dividend.name, dividend.rate / fxIndex_->fixing(dividend.exDate),
47 dividend.payDate);
48 source_->addDividend(newDiv, forceOverwrite);
49 LazyObject::update();
50 }
51}

◆ dividendFixings()

const std::set< Dividend > & dividendFixings ( ) const
overridevirtual

Reimplemented from EquityIndex2.

Definition at line 64 of file compoequityindex.cpp.

64 {
65 calculate();
66 return dividendFixings_;
67}
std::set< Dividend > dividendFixings_

◆ pastFixing()

Real pastFixing ( const Date &  fixingDate) const
overridevirtual

returns a past 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.

Reimplemented from EquityIndex2.

Definition at line 69 of file compoequityindex.cpp.

69 {
70 return source_->fixing(fixingDate) * fxIndex_->fixing(fixingDate);
71}

◆ clone()

QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > clone ( const Handle< Quote >  spotQuote,
const Handle< YieldTermStructure > &  rate,
const Handle< YieldTermStructure > &  dividend 
) const
overridevirtual

Reimplemented from EquityIndex2.

Definition at line 73 of file compoequityindex.cpp.

75 {
76 return QuantLib::ext::make_shared<CompoEquityIndex>(source_->clone(spotQuote, rate, dividend), fxIndex_);
77}

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 53 of file compoequityindex.cpp.

53 {
54 dividendFixings_ = std::set<Dividend>();
55 auto const& ts = source_->dividendFixings();
56 for (auto const& d : ts) {
57 if (dividendCutoffDate_ == Date() || d.exDate >= dividendCutoffDate_) {
58 Dividend div(d.exDate, d.name, d.rate * fxIndex_->fixing(fxIndex_->fixingCalendar().adjust(d.exDate, Preceding)), d.payDate);
59 dividendFixings_.insert(div);
60 }
61 }
62}

Member Data Documentation

◆ source_

QuantLib::ext::shared_ptr<QuantExt::EquityIndex2> source_
private

Definition at line 53 of file compoequityindex.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<FxIndex> fxIndex_
private

Definition at line 54 of file compoequityindex.hpp.

◆ dividendCutoffDate_

Date dividendCutoffDate_
private

Definition at line 55 of file compoequityindex.hpp.

◆ dividendFixings_

std::set<Dividend> dividendFixings_
mutableprivate

Definition at line 57 of file compoequityindex.hpp.