33 for (
auto const n : c) {
57 DLOG(
"EquityPosition::build() called for " <<
id());
58 QL_REQUIRE(!
data_.
underlyings().empty(),
"EquityPosition::build(): no underlyings given");
63 std::vector<std::string> currencies;
68 QL_REQUIRE(!
indices_.back()->currency().empty(),
69 "did not get currency for equity name '" << u.name() <<
"', is this set up?");
70 currencies.push_back(
indices_.back()->currency().code());
77 for (
auto const& c : currencies) {
89 qlInstr->setPricingEngine(QuantLib::ext::make_shared<EquityPositionInstrumentWrapperEngine>());
91 instrument_ = QuantLib::ext::make_shared<VanillaInstrument>(qlInstr);
103 QuantLib::ext::static_pointer_cast<EquityPositionInstrumentWrapper>(
instrument_->qlInstrument())
104 ->setNpvCurrencyConversion(conversion);
118std::map<AssetClass, std::set<std::string>>
120 std::map<AssetClass, std::set<std::string>> result;
128 const Real quantity,
const std::vector<QuantLib::ext::shared_ptr<QuantExt::EquityIndex2>>& equities,
129 const std::vector<Real>& weights,
const std::vector<Handle<Quote>>& fxConversion)
130 : quantity_(quantity), equities_(equities), weights_(weights), fxConversion_(fxConversion) {
131 QL_REQUIRE(
equities_.size() ==
weights_.size(),
"EquityPositionInstrumentWrapper: equities size ("
132 <<
equities_.size() <<
") must match weights size ("
135 "EquityPositionInstrumentWrapper: fxConversion size ("
154 QL_REQUIRE(a !=
nullptr,
"wrong argument type in EquityPositionInstrumentWrapper");
163 Instrument::fetchResults(r);
168 for (Size i = 0; i <
arguments_.equities_.size(); ++i) {
176 result *=
arguments_.npvCcyConversion_->value();
const Instrument::results * results_
const std::vector< EquityUnderlying > & underlyings() const
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
std::vector< EquityUnderlying > underlyings_
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
void fromXML(XMLNode *node) override
std::vector< Handle< Quote > > fxConversion_
void setNpvCurrencyConversion(const std::string &ccy, const Handle< Quote > &conversion)
XMLNode * toXML(XMLDocument &doc) const override
std::vector< QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > > indices_
std::vector< Real > weights_
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
std::vector< QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > > equities_
std::vector< Handle< Quote > > fxConversion_
std::vector< Real > weights_
Handle< Quote > npvCcyConversion_
void calculate() const override
void fetchResults(const QuantLib::PricingEngine::results *) const override
EquityPositionInstrumentWrapper(const Real quantity, const std::vector< QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > > &equities, const std::vector< Real > &weights, const std::vector< Handle< Quote > > &fxConversion={})
std::vector< QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > > equities_
bool isExpired() const override
std::vector< Handle< Quote > > fxConversion_
std::vector< Real > weights_
Handle< Quote > npvCcyConversion_
void setupExpired() const override
void setupArguments(QuantLib::PricingEngine::arguments *) const override
void setNpvCurrencyConversion(const Handle< Quote > &npvCcyConversion)
virtual void fromXML(XMLNode *node) override
void setSensitivityTemplate(const EngineBuilder &builder)
virtual XMLNode * toXML(XMLDocument &doc) const override
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Equity Position trade data model and serialization.
#define DLOG(text)
Logging Macro (Level = Debug)
Serializable Credit Default Swap.
Swap::arguments * arguments_