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

#include <ored/utilities/currencyhedgedequityindexdecomposition.hpp>

+ Collaboration diagram for CurrencyHedgedEquityIndexDecomposition:

Public Member Functions

 CurrencyHedgedEquityIndexDecomposition (const std::string indexName, const QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatum > &indexRefData, const QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatum > underlyingRefData, const std::string &indexCurrency, const std::string &underlyingIndexCurrency, const std::string &fxIndexName, const std::map< std::string, std::pair< double, std::string > > &currencyWeightsAndFxIndexNames)
 
const std::string & indexName () const
 
const std::string & underlyingIndexName () const
 
const std::string & indexCurrency () const
 
const std::string & underlyingIndexCurrency () const
 
const std::string & fxIndexName () const
 
bool isValid () const
 
QuantLib::Date referenceDate (const QuantLib::Date &asof) const
 
QuantLib::Date rebalancingDate (const QuantLib::Date &asof) const
 
const std::map< std::string, std::pair< double, std::string > > & currencyWeightsAndFxIndexNames () const
 
std::map< std::string, double > fxSpotRiskFromForwards (const double quantity, const QuantLib::Date &asof, const QuantLib::ext::shared_ptr< ore::data::Market > &todaysMarket, const double shiftsize) const
 
double unhedgedSpotExposure (double hedgedExposure, const double quantity, const QuantLib::Date &asof, const QuantLib::ext::shared_ptr< ore::data::Market > &todaysMarket) const
 
QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatumunderlyingRefData () const
 
QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatumindexRefData () const
 
void addAdditionalFixingsForEquityIndexDecomposition (const QuantLib::Date &asof, std::map< std::string, RequiredFixings::FixingDates > &fixings) const
 

Static Public Member Functions

static QuantLib::Date referenceDate (const QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexReferenceDatum > &refData, const QuantLib::Date &asof)
 
static QuantLib::Date rebalancingDate (const QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexReferenceDatum > &refData, const QuantLib::Date &asof)
 

Private Attributes

std::string name_
 
QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatumindexRefData_
 
QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatumunderlyingRefData_
 
std::string indexCurrency_
 
std::string underlyingIndexCurrency_
 
std::string fxIndexName_
 
std::map< std::string, std::pair< double, std::string > > currencyWeightsAndFxIndexNames_
 

Detailed Description

Definition at line 21 of file currencyhedgedequityindexdecomposition.hpp.

Constructor & Destructor Documentation

◆ CurrencyHedgedEquityIndexDecomposition()

CurrencyHedgedEquityIndexDecomposition ( const std::string  indexName,
const QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatum > &  indexRefData,
const QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatum underlyingRefData,
const std::string &  indexCurrency,
const std::string &  underlyingIndexCurrency,
const std::string &  fxIndexName,
const std::map< std::string, std::pair< double, std::string > > &  currencyWeightsAndFxIndexNames 
)

Definition at line 23 of file currencyhedgedequityindexdecomposition.hpp.

32 QL_REQUIRE(indexRefData_, "CurrencyHedgedDecomposition requires a valid indexRefData");
33 QL_REQUIRE(underlyingRefData_, "CurrencyHedgedDecomposition requires a valid underlyingRefData");
34 QL_REQUIRE(!indexCurrency_.empty(), "CurrencyHedgedDecomposition requires the currency of the index");
35 QL_REQUIRE(!underlyingIndexCurrency_.empty(), "CurrencyHedgedDecomposition requires the currency of the underlying index");
36 QL_REQUIRE(!fxIndexName_.empty(),
37 "CurrencyHedgedDecomposition requires the FXIndex name to convert underlyingIndexCurrency to IndexCurrency");
38 }
QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatum > underlyingRefData() const
std::map< std::string, std::pair< double, std::string > > currencyWeightsAndFxIndexNames_
QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatum > indexRefData() const
const std::map< std::string, std::pair< double, std::string > > & currencyWeightsAndFxIndexNames() const
QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatum > underlyingRefData_
QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatum > indexRefData_

Member Function Documentation

◆ indexName()

const std::string & indexName ( ) const

Definition at line 40 of file currencyhedgedequityindexdecomposition.hpp.

40{ return name_; }
+ Here is the caller graph for this function:

◆ underlyingIndexName()

const std::string & underlyingIndexName ( ) const

Definition at line 42 of file currencyhedgedequityindexdecomposition.hpp.

42{ return underlyingRefData_->id(); }
+ Here is the caller graph for this function:

◆ indexCurrency()

const std::string & indexCurrency ( ) const

Definition at line 44 of file currencyhedgedequityindexdecomposition.hpp.

44{ return indexCurrency_; }

◆ underlyingIndexCurrency()

const std::string & underlyingIndexCurrency ( ) const

Definition at line 46 of file currencyhedgedequityindexdecomposition.hpp.

◆ fxIndexName()

const std::string & fxIndexName ( ) const

Definition at line 48 of file currencyhedgedequityindexdecomposition.hpp.

48{ return fxIndexName_; }
+ Here is the caller graph for this function:

◆ isValid()

bool isValid ( ) const

Definition at line 50 of file currencyhedgedequityindexdecomposition.hpp.

+ Here is the caller graph for this function:

◆ referenceDate() [1/2]

QuantLib::Date referenceDate ( const QuantLib::Date &  asof) const

Definition at line 149 of file currencyhedgedequityindexdecomposition.cpp.

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

◆ rebalancingDate() [1/2]

QuantLib::Date rebalancingDate ( const QuantLib::Date &  asof) const

Definition at line 153 of file currencyhedgedequityindexdecomposition.cpp.

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

◆ referenceDate() [2/2]

QuantLib::Date referenceDate ( const QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexReferenceDatum > &  refData,
const QuantLib::Date &  asof 
)
static

Definition at line 119 of file currencyhedgedequityindexdecomposition.cpp.

121 {
122 QuantLib::Date hedgingDate = CurrencyHedgedEquityIndexDecomposition::rebalancingDate(refData, asof);
123 if (hedgingDate == QuantLib::Date()) {
124 return QuantLib::Date();
125 } else {
126 return refData->hedgeCalendar().advance(hedgingDate, -refData->referenceDateOffset() * QuantLib::Days,
127 QuantLib::Preceding);
128 }
129}
+ Here is the call graph for this function:

◆ rebalancingDate() [2/2]

QuantLib::Date rebalancingDate ( const QuantLib::ext::shared_ptr< CurrencyHedgedEquityIndexReferenceDatum > &  refData,
const QuantLib::Date &  asof 
)
static

Definition at line 131 of file currencyhedgedequityindexdecomposition.cpp.

133 {
134 if (refData->rebalancingStrategy() ==
136 QuantLib::Date lastBusinessDayOfCurrentMonth = QuantLib::Date::endOfMonth(asof);
137 lastBusinessDayOfCurrentMonth =
138 refData->hedgeCalendar().adjust(lastBusinessDayOfCurrentMonth, QuantLib::Preceding);
139 if (asof == lastBusinessDayOfCurrentMonth) {
140 return asof;
141 } else {
142 return refData->hedgeCalendar().advance(QuantLib::Date(1, asof.month(), asof.year()), -1 * QuantLib::Days,
143 QuantLib::Preceding);
144 }
145 }
146 return QuantLib::Date();
147}

◆ currencyWeightsAndFxIndexNames()

const std::map< std::string, std::pair< double, std::string > > & currencyWeightsAndFxIndexNames ( ) const

Definition at line 62 of file currencyhedgedequityindexdecomposition.hpp.

62 {
64 }
+ Here is the caller graph for this function:

◆ fxSpotRiskFromForwards()

std::map< std::string, double > fxSpotRiskFromForwards ( const double  quantity,
const QuantLib::Date &  asof,
const QuantLib::ext::shared_ptr< ore::data::Market > &  todaysMarket,
const double  shiftsize 
) const

Definition at line 157 of file currencyhedgedequityindexdecomposition.cpp.

158 {
159
160 std::map<std::string, double> fxRisks;
161 auto indexCurve = todaysMarket->equityCurve(indexName());
162 auto underlyingCurve = todaysMarket->equityCurve(underlyingIndexName());
163 QuantLib::Date refDate = referenceDate(asof);
164 double adjustmentFactor = 1.0;
165 // If adjustement is daily, the fxForward notional will be adjusted by the relative return of the underlying index
167 adjustmentFactor = underlyingCurve->fixing(asof) / underlyingCurve->fixing(rebalancingDate(asof));
168 }
169 // Compute notionals and fxSpotRisks
170 for (const auto& [ccy, weightAndIndex] : currencyWeightsAndFxIndexNames()) {
171 double weight = weightAndIndex.first;
172 auto fxIndexFamily = parseFxIndex(fxIndexName())->familyName();
173 auto fxIndex = todaysMarket->fxIndex("FX-" + fxIndexFamily + "-" + underlyingIndexCurrency_ + "-" + indexCurrency_);
174 double forwardNotional =
175 quantity * adjustmentFactor * weight * indexCurve->fixing(refDate) / fxIndex->fixing(refDate);
176 fxRisks[ccy] = shiftsize * forwardNotional * fxIndex->fixing(asof);
177 }
178 return fxRisks;
179}
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
Date referenceDate
Definition: utilities.cpp:442
+ Here is the call graph for this function:

◆ unhedgedSpotExposure()

double unhedgedSpotExposure ( double  hedgedExposure,
const double  quantity,
const QuantLib::Date &  asof,
const QuantLib::ext::shared_ptr< ore::data::Market > &  todaysMarket 
) const

Definition at line 182 of file currencyhedgedequityindexdecomposition.cpp.

184 {
185 auto indexCurve = todaysMarket->equityCurve(indexName());
186 auto underlyingCurve = todaysMarket->equityCurve(underlyingIndexName());
187 QuantLib::Date rebalanceDt = rebalancingDate(asof);
188 auto fxIndexFamily = parseFxIndex(fxIndexName())->familyName();
189 auto fxIndex = todaysMarket->fxIndex("FX-" + fxIndexFamily + "-" + underlyingIndexCurrency_ + "-" + indexCurrency_);
190 double hedgedUnitPrice = (hedgedExposure / quantity);
191 // In case we have a option and the unit delta isnt one
192 double scaling = hedgedUnitPrice / indexCurve->fixing(asof);
193 // Change in the fx since the last rebalacing
194 double fxReturn = fxIndex->fixing(asof) / fxIndex->fixing(rebalanceDt);
195 // Return of the underlying since last rebalacning
196 double underlyingIndexReturn = underlyingCurve->equitySpot()->value() / underlyingCurve->fixing(rebalanceDt);
197 // Unhedged price of the index
198 double unhedgedUnitPrice= indexCurve->fixing(rebalanceDt) * underlyingIndexReturn * fxReturn;
199 // Unhedged exposure
200 return scaling * quantity * unhedgedUnitPrice;
201}
+ Here is the call graph for this function:

◆ underlyingRefData()

QuantLib::ext::shared_ptr< ore::data::EquityIndexReferenceDatum > underlyingRefData ( ) const

Definition at line 73 of file currencyhedgedequityindexdecomposition.hpp.

73{ return underlyingRefData_; }

◆ indexRefData()

QuantLib::ext::shared_ptr< ore::data::CurrencyHedgedEquityIndexReferenceDatum > indexRefData ( ) const

Definition at line 75 of file currencyhedgedequityindexdecomposition.hpp.

75{ return indexRefData_; }
+ Here is the caller graph for this function:

◆ addAdditionalFixingsForEquityIndexDecomposition()

void addAdditionalFixingsForEquityIndexDecomposition ( const QuantLib::Date &  asof,
std::map< std::string, RequiredFixings::FixingDates > &  fixings 
) const

Definition at line 203 of file currencyhedgedequityindexdecomposition.cpp.

204 {
205 if (isValid()) {
206 QuantLib::Date rebalancingDt = rebalancingDate(asof);
207 QuantLib::Date referenceDt = referenceDate(asof);
208 fixings[IndexNameTranslator::instance().oreName(indexName())].addDate(rebalancingDt, false);
209 fixings[IndexNameTranslator::instance().oreName(indexName())].addDate(referenceDt, false);
210
211 IndexNameTranslator::instance().add(underlyingIndexName(), "EQ-" + underlyingIndexName());
212 fixings[IndexNameTranslator::instance().oreName(underlyingIndexName())].addDate(rebalancingDt, false);
213 fixings[IndexNameTranslator::instance().oreName(underlyingIndexName())].addDate(referenceDt, false);
214
215 fixings[fxIndexName()].addDate(referenceDt, false);
216 fixings[fxIndexName()].addDate(rebalancingDt, false);
217
218 for (const auto& [currency, name] : currencyWeightsAndFxIndexNames()) {
219 fixings[name.second].addDate(referenceDt, false);
220 fixings[name.second].addDate(rebalancingDt, false);
221 }
222 }
223}
string name
+ Here is the call graph for this function:

Member Data Documentation

◆ name_

std::string name_
private

Definition at line 82 of file currencyhedgedequityindexdecomposition.hpp.

◆ indexRefData_

QuantLib::ext::shared_ptr<ore::data::CurrencyHedgedEquityIndexReferenceDatum> indexRefData_
private

Definition at line 83 of file currencyhedgedequityindexdecomposition.hpp.

◆ underlyingRefData_

QuantLib::ext::shared_ptr<ore::data::EquityIndexReferenceDatum> underlyingRefData_
private

Definition at line 84 of file currencyhedgedequityindexdecomposition.hpp.

◆ indexCurrency_

std::string indexCurrency_
private

Definition at line 85 of file currencyhedgedequityindexdecomposition.hpp.

◆ underlyingIndexCurrency_

std::string underlyingIndexCurrency_
private

Definition at line 86 of file currencyhedgedequityindexdecomposition.hpp.

◆ fxIndexName_

std::string fxIndexName_
private

Definition at line 87 of file currencyhedgedequityindexdecomposition.hpp.

◆ currencyWeightsAndFxIndexNames_

std::map<std::string, std::pair<double, std::string> > currencyWeightsAndFxIndexNames_
private

Definition at line 88 of file currencyhedgedequityindexdecomposition.hpp.