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

#include <ored/portfolio/legbuilders.hpp>

+ Inheritance diagram for EquityLegBuilder:
+ Collaboration diagram for EquityLegBuilder:

Public Member Functions

 EquityLegBuilder ()
 
Leg buildLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const override
 
- Public Member Functions inherited from LegBuilder
 LegBuilder (const string &legType)
 
virtual ~LegBuilder ()
 
virtual Leg buildLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const =0
 
const string & legType () const
 

Detailed Description

Definition at line 133 of file legbuilders.hpp.

Constructor & Destructor Documentation

◆ EquityLegBuilder()

Definition at line 135 of file legbuilders.hpp.

135: LegBuilder("Equity") {}
LegBuilder(const string &legType)

Member Function Documentation

◆ buildLeg()

Leg buildLeg ( const LegData data,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
RequiredFixings requiredFixings,
const string &  configuration,
const QuantLib::Date &  openEndDateReplacement = Null<Date>(),
const bool  useXbsCurves = false 
) const
overridevirtual

Implements LegBuilder.

Definition at line 275 of file legbuilders.cpp.

277 {
278 auto eqData = QuantLib::ext::dynamic_pointer_cast<EquityLegData>(data.concreteLegData());
279 QL_REQUIRE(eqData, "Wrong LegType, expected Equity");
280 string eqName = eqData->eqName();
281 auto eqCurve = *engineFactory->market()->equityCurve(eqName, configuration);
282
283 // A little hacky but ensures for a dividend swap the swap value doesn't move equity price
284 if (eqData->returnType() == EquityReturnType::Dividend) {
285 Real spotVal = eqCurve->equitySpot()->value();
286 Handle<Quote> divSpot = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(spotVal));
287 eqCurve = eqCurve->clone(divSpot, eqCurve->equityForecastCurve(), eqCurve->equityDividendCurve());
288 }
289
290 Currency dataCurrency = parseCurrencyWithMinors(data.currency());
291 Currency eqCurrency;
292 // Set the equity currency if provided
293 if (!eqData->eqCurrency().empty())
294 eqCurrency = parseCurrencyWithMinors(eqData->eqCurrency());
295
296 if (eqCurve->currency().empty()) {
297 WLOG("No equity currency set in EquityIndex for equity " << eqCurve->name());
298 } else {
299 // check if it equity currency not set, use from market else check if it matches what is in market
300 if (!eqCurrency.empty())
301 QL_REQUIRE(eqCurve->currency() == eqCurrency,
302 "Equity Currency provided does not match currency of Equity Curve");
303 else
304 eqCurrency = eqCurve->currency();
305 }
306
307 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex = nullptr;
308 // if equity currency differs from the leg currency we need an FxIndex
309 if (!eqCurrency.empty() && dataCurrency != eqCurrency) {
310 QL_REQUIRE(eqData->fxIndex() != "",
311 "No FxIndex - if equity currency differs from leg currency an FxIndex must be provided");
312
313 // An extra check, this ensures that the equity currency provided to use in the FX Index, matches that in
314 // equity curves in the market, this is required as future cashflows will be in the equity curve currency
315 if (!eqCurve->currency().empty() && !eqCurrency.empty()) {
316 QL_REQUIRE(eqCurve->currency() == eqCurrency,
317 "Equity Currency provided does not match currency of Equity Curve");
318 }
319
320 fxIndex = buildFxIndex(eqData->fxIndex(), data.currency(), eqCurrency.code(), engineFactory->market(),
321 configuration, useXbsCurves);
322 }
323
324 Leg result = makeEquityLeg(data, eqCurve, fxIndex, openEndDateReplacement);
325 addToRequiredFixings(result, QuantLib::ext::make_shared<FixingDateGetter>(requiredFixings));
326 return result;
327}
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
@ data
Definition: log.hpp:77
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
Leg makeEquityLeg(const LegData &data, const QuantLib::ext::shared_ptr< EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex, const QuantLib::Date &openEndDateReplacement)
Definition: legdata.cpp:2352
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
Definition: marketdata.cpp:137
+ Here is the call graph for this function: