31Real getRealOrNull(
XMLNode* node,
const string&
name) {
47 if (underlying_->type() ==
"Equity") {
48 additionalData_[
"isdaAssetClass"] = string(
"Equity");
49 additionalData_[
"isdaBaseProduct"] = string(
"Other");
50 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
51 }
else if (underlying_->type() ==
"Commodity") {
53 additionalData_[
"isdaAssetClass"] = string(
"Commodity");
54 additionalData_[
"isdaBaseProduct"] = string(
"Other");
55 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
56 }
else if (underlying_->type() ==
"FX") {
57 additionalData_[
"isdaAssetClass"] = string(
"Foreign Exchange");
58 additionalData_[
"isdaBaseProduct"] = string(
"Complex Exotic");
59 additionalData_[
"isdaSubProduct"] = string(
"Generic");
61 WLOG(
"ISDA taxonomy not set for trade " <<
id());
64 additionalData_[
"isdaTransaction"] = string(
"");
68 QL_REQUIRE(tradeActions().empty(),
"TradeActions not supported for VanillaOption");
72 QuantLib::ext::shared_ptr<PercentageStrikePayoff> payoff = QuantLib::ext::make_shared<PercentageStrikePayoff>(type, moneyness_);
76 Date expiryDate = schedule.dates().back();
80 QuantLib::ext::shared_ptr<QuantLib::Instrument> instrument;
81 QuantLib::ext::shared_ptr<EuropeanExercise> exerciseDate = QuantLib::ext::make_shared<EuropeanExercise>(expiryDate);
83 Date paymentDate = schedule.calendar().advance(expiryDate, settlementDays_, Days);
85 for (
auto d : schedule.dates())
86 valuationDates_.insert(schedule.calendar().adjust(d, schedule.businessDayConvention()));
91 QuantLib::ext::shared_ptr<Instrument> cliquet = QuantLib::ext::make_shared<QuantExt::CliquetOption>(
95 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(tradeType_);
96 QL_REQUIRE(builder,
"No builder found for " << tradeType_);
97 QuantLib::ext::shared_ptr<CliquetOptionEngineBuilder> cliquetOptionBuilder =
98 QuantLib::ext::dynamic_pointer_cast<CliquetOptionEngineBuilder>(builder);
100 cliquet->setPricingEngine(cliquetOptionBuilder->engine(
name(), ccy));
101 setSensitivityTemplate(*cliquetOptionBuilder);
103 instrument_ = QuantLib::ext::shared_ptr<InstrumentWrapper>(
new VanillaInstrument(cliquet));
105 npvCurrency_ = currency_;
106 maturity_ = expiryDate;
108 notionalCurrency_ = currency_;
112 requiredFixings_.addFixingDate(d,
"EQ-" +
name(), paymentDate);
115 additionalData_[
"notional"] = cliquetNotional_;
122 QL_REQUIRE(clNode,
"No EquityCliquetOptionData Node");
128 underlyingBuilder.
fromXML(tmp);
136 scheduleData_.fromXML(scheduleNode);
138 localCap_ = getRealOrNull(clNode,
"LocalCap");
140 globalCap_ = getRealOrNull(clNode,
"GlobalCap");
158 if (moneyness_ != Null<Real>())
168 if (settlementDays_ != Null<Size>())
172 if (premiumCcy_ !=
"")
Engine builder for cliquet options.
const Position::Type longShort_
const std::set< Date > valuationDates_
const Date premiumPayDate_
virtual void fromXML(ore::data::XMLNode *node) override
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const QuantLib::ext::shared_ptr< Underlying > & underlying()
void fromXML(XMLNode *node) override
Vanilla Instrument Wrapper.
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Real parseReal(const string &s)
Convert text to Real.
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
#define WLOG(text)
Logging Macro (Level = Warning)
Schedule makeSchedule(const ScheduleDates &data)
Serializable Credit Default Swap.
Reference data model and serialization.