19#include <boost/make_shared.hpp>
27#include <ql/errors.hpp>
28#include <ql/exercise.hpp>
29#include <ql/instruments/compositeinstrument.hpp>
30#include <ql/instruments/vanillaoption.hpp>
42 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
67 const QuantLib::ext::shared_ptr<Market>& market = engineFactory->market();
81 TLOG(
"Setting strike currency to payoff currency " << ccy <<
" for trade " <<
id() <<
".");
86 QL_FAIL(
"Strike currency must be specified for a quanto payoff for trade " <<
id() <<
".");
96 QL_REQUIRE(ccy == strikeCcy,
"Equity composite option requires pay ccy ("
97 << ccy.code() <<
") to match strike ccy (" << strikeCcy.code()
98 <<
"), quanto composite options are not supported (underlying currency is "
103 QuantLib::ext::shared_ptr<Exercise> exercise;
104 switch (exerciseType) {
105 case QuantLib::Exercise::Type::European: {
106 exercise = QuantLib::ext::make_shared<EuropeanExercise>(
expiryDate_);
110 QL_FAIL(
"Option Style " <<
option_.
style() <<
" is not supported for an composite equity option");
114 QuantLib::ext::shared_ptr<Instrument> vanilla;
115 if (exerciseType == Exercise::European && settlementType == Settlement::Cash) {
122 if (opd->rulesBased()) {
123 const Calendar& cal = opd->calendar();
124 QL_REQUIRE(cal != Calendar(),
"Need a non-empty calendar for rules based payment date.");
127 const vector<Date>& dates = opd->dates();
128 QL_REQUIRE(dates.size() == 1,
"Need exactly one payment date for cash settled European option.");
135 "Payment date must equal expiry date for a Composite payoff. Trade: " <<
id() <<
".");
138 QuantLib::Date(),
"Composite payoff is not currently supported for Forward Options: Trade "
141 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff(
new PlainVanillaPayoff(type,
strike_.
value()));
142 vanilla = QuantLib::ext::make_shared<QuantLib::VanillaOption>(payoff, exercise);
144 string tradeTypeBuilder =
"EquityEuropeanCompositeOption";
146 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(tradeTypeBuilder);
147 QL_REQUIRE(builder,
"No builder found for " << tradeTypeBuilder);
151 auto compositeBuilder = QuantLib::ext::dynamic_pointer_cast<EquityEuropeanCompositeEngineBuilder>(builder);
158 Real bsInd = (positionType == QuantLib::Position::Long ? 1.0 : -1.0);
161 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
162 std::vector<Real> additionalMultipliers;
165 -bsInd, ccy, engineFactory, configuration));
167 instrument_ = QuantLib::ext::shared_ptr<InstrumentWrapper>(
168 new VanillaInstrument(vanilla, mult, additionalInstruments, additionalMultipliers));
178 QL_REQUIRE(eqNode,
"No EquityOptionData Node");
189 WLOG(
"EquityOption::fromXML: node StrikeCurrency is deprecated, please use StrikeData node");
Engine builder for equity options.
const string & equityName() const
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Equity names.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
EquityUnderlying equityUnderlying_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
static const string defaultConfiguration
Default configuration label.
const string & callPut() const
const string & longShort() const
const string & style() const
const string & settlement() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const boost::optional< OptionPaymentData > & paymentData() const
const PremiumData & premiumData() const
const vector< string > & exerciseDates() const
virtual void fromXML(XMLNode *node) override
Date addPremiums(std::vector< QuantLib::ext::shared_ptr< Instrument > > &instruments, std::vector< Real > &multipliers, const Real tradeMultiplier, const PremiumData &premiumData, const Real premiumMultiplier, const Currency &tradeCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &factory, const string &configuration)
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_
XMLNode * toXML(XMLDocument &doc) const
void setCurrency(const std::string ¤cy)
void fromXML(XMLNode *node, const bool isRequired=true, const bool allowYieldStrike=false)
QuantLib::Real value() const
Vanilla Instrument Wrapper.
QuantLib::Date expiryDate_
Store the option expiry date.
const QuantLib::Date paymentDate() const
Currency underlyingCurrency_
QuantLib::Date forwardDate_
Store the (optional) forward date.
QuantLib::ext::shared_ptr< QuantLib::Index > index_
An index is needed if the option is to be automatically exercised on expiry.
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
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 XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Engine builder for equity composite options.
Equity Option data model and serialization.
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Currency parseCurrencyWithMinors(const string &s)
Convert text to QuantLib::Currency.
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.
Settlement::Type parseSettlementType(const std::string &s)
Convert text to QuantLib::Settlement::Type.
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
Classes and functions for log message handling.
#define WLOG(text)
Logging Macro (Level = Warning)
#define TLOG(text)
Logging Macro (Level = Data)
Serializable Credit Default Swap.
Reference data model and serialization.