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

#include <ored/portfolio/equityfxlegbuilder.hpp>

+ Inheritance diagram for EquityMarginLegBuilder:
+ Collaboration diagram for EquityMarginLegBuilder:

Public Member Functions

 EquityMarginLegBuilder ()
 
QuantLib::Leg buildLeg (const ore::data::LegData &data, const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &engineFactory, ore::data::RequiredFixings &requiredFixings, const std::string &configuration, const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::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 33 of file equityfxlegbuilder.hpp.

Constructor & Destructor Documentation

◆ EquityMarginLegBuilder()

Definition at line 35 of file equityfxlegbuilder.hpp.

35: LegBuilder("EquityMargin") {}
LegBuilder(const string &legType)

Member Function Documentation

◆ buildLeg()

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

Definition at line 39 of file equityfxlegbuilder.cpp.

41 {
42 auto eqMarginData = QuantLib::ext::dynamic_pointer_cast<EquityMarginLegData>(data.concreteLegData());
43 QL_REQUIRE(eqMarginData, "Wrong LegType, expected EquityMargin");
44
45 QuantLib::ext::shared_ptr<EquityLegData> eqData = eqMarginData->equityLegData();
46
47 string eqName = eqData->eqName();
48 auto eqCurve = *engineFactory->market()->equityCurve(eqName, configuration);
49
50 Currency dataCurrency = parseCurrencyWithMinors(data.currency());
51 Currency eqCurrency = eqCurve->currency();
52
53 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex = nullptr;
54 // if equity currency differs from the leg currency we need an FxIndex
55 if (dataCurrency != eqCurrency) {
56 QL_REQUIRE(eqData->fxIndex() != "",
57 "No FxIndex - if equity currency differs from leg currency an FxIndex must be provided");
58 fxIndex = buildFxIndex(eqData->fxIndex(), data.currency(), eqCurrency.code(), engineFactory->market(),
59 configuration);
60 }
61
62 Leg result = makeEquityMarginLeg(data, eqCurve, fxIndex, openEndDateReplacement);
63 addToRequiredFixings(result, QuantLib::ext::make_shared<ore::data::FixingDateGetter>(requiredFixings));
64 return result;
65}
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:310
@ data
Definition: log.hpp:77
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
QuantExt::Leg makeEquityMarginLeg(const LegData &data, const QuantLib::ext::shared_ptr< EquityIndex2 > &equityCurve, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex, const QuantLib::Date &openEndDateReplacement)
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: