25#include <boost/make_shared.hpp>
30#include <ql/errors.hpp>
42 additionalData_[
"isdaAssetClass"] = string(
"Equity");
43 additionalData_[
"isdaBaseProduct"] = string(
"Forward");
44 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
46 additionalData_[
"isdaTransaction"] = string(
"");
48 additionalData_[
"strikeCurrency"] = strikeCurrency_;
55 if (!strikeCurrency_.empty()) {
59 WLOG(
"No Strike Currency provide for trade " <<
id() <<
", assuming trade currency " << ccy);
62 additionalData_[
"strike"] =
strike;
67 string name = eqName();
68 additionalData_[
"underlyingSecurityId"] =
name;
70 QuantLib::ext::shared_ptr<Instrument> inst =
74 instrument_ = QuantLib::ext::shared_ptr<InstrumentWrapper>(
new VanillaInstrument(inst));
75 npvCurrency_ = ccy.code();
80 notionalCurrency_ = ccy.code();
86 Currency equityCcy = engineFactory->market()->equityCurve(eqName())->currency();
89 QL_REQUIRE(!equityCcy.empty(),
"No equity currency in equityCurve for equity " << eqName());
90 QL_REQUIRE(ccy == equityCcy,
"EquityForward currency " << ccy <<
" does not match equity currency " << equityCcy <<
" for trade " <<
id());
92 if (!strikeCurrency_.empty()) {
94 QL_REQUIRE(strikeCcy == equityCcy,
"Strike currency " << ccy <<
" does not match equity currency " << equityCcy <<
" for trade " <<
id());
98 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(tradeType_);
99 QL_REQUIRE(builder,
"No builder found for " << tradeType_);
100 QuantLib::ext::shared_ptr<EquityForwardEngineBuilder> eqFwdBuilder =
101 QuantLib::ext::dynamic_pointer_cast<EquityForwardEngineBuilder>(builder);
102 inst->setPricingEngine(eqFwdBuilder->engine(
name, ccy));
103 setSensitivityTemplate(*eqFwdBuilder);
107 Trade::fromXML(node);
108 XMLNode* eNode = XMLUtils::getChildNode(node,
"EquityForwardData");
110 longShort_ = XMLUtils::getChildValue(eNode,
"LongShort",
true);
111 maturityDate_ = XMLUtils::getChildValue(eNode,
"Maturity",
true);
112 XMLNode* tmp = XMLUtils::getChildNode(eNode,
"Underlying");
114 tmp = XMLUtils::getChildNode(eNode,
"Name");
115 equityUnderlying_.fromXML(tmp);
116 currency_ = XMLUtils::getChildValue(eNode,
"Currency",
true);
117 strike_ = XMLUtils::getChildValueAsDouble(eNode,
"Strike",
true);
118 strikeCurrency_ = XMLUtils::getChildValue(eNode,
"StrikeCurrency",
false);
119 quantity_ = XMLUtils::getChildValueAsDouble(eNode,
"Quantity",
true);
123 XMLNode* node = Trade::toXML(doc);
125 XMLUtils::appendNode(node, eNode);
127 XMLUtils::addChild(doc, eNode,
"LongShort",
longShort_);
129 XMLUtils::appendNode(eNode, equityUnderlying_.toXML(doc));
130 XMLUtils::addChild(doc, eNode,
"Currency",
currency_);
131 XMLUtils::addChild(doc, eNode,
"Strike",
strike_);
132 if (!strikeCurrency_.empty())
133 XMLUtils::addChild(doc, eNode,
"StrikeCurrency", strikeCurrency_);
134 XMLUtils::addChild(doc, eNode,
"Quantity",
quantity_);
138std::map<AssetClass, std::set<std::string>>
139EquityForward::underlyingIndices(
const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager)
const {
140 return {{AssetClass::EQ, std::set<std::string>({eqName()})}};
Builder that returns an engine to price an equity forward.
const std::string & name() const
Position::Type longShort_
Position::Type longShort() const
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Vanilla Instrument Wrapper.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Equity Forward data model and serialization.
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
QuantLib::Real convertMinorToMajorCurrency(const std::string &s, QuantLib::Real value)
Convert a value from a minor ccy to major.
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
#define WLOG(text)
Logging Macro (Level = Warning)
Serializable Credit Default Swap.
Reference data model and serialization.