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

Serializable Equity Cliquet Option. More...

#include <ored/portfolio/cliquetoption.hpp>

+ Inheritance diagram for CliquetOption:
+ Collaboration diagram for CliquetOption:

Public Member Functions

 CliquetOption (const std::string &tradeType)
 Default constructor. More...
 
 CliquetOption (const std::string &tradeType, ore::data::Envelope &env, const QuantLib::ext::shared_ptr< ore::data::Underlying > &underlying, std::string currency, QuantLib::Real notional, std::string longShort, std::string callPut, ore::data::ScheduleData scheduleData, QuantLib::Real moneyness=1.0, QuantLib::Real localCap=QuantLib::Null< QuantLib::Real >(), QuantLib::Real localFloor=QuantLib::Null< QuantLib::Real >(), QuantLib::Real globalCap=QuantLib::Null< QuantLib::Real >(), QuantLib::Real globalFloor=QuantLib::Null< QuantLib::Real >(), QuantLib::Size settlementDays=0, QuantLib::Real premium=0.0, std::string premiumCcy="", std::string premiumPayDate="")
 Constructor. More...
 
void build (const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
 Build QuantLib/QuantExt instrument, link pricing engine. More...
 
Inspectors
const std::string & name () const
 
const QuantLib::ext::shared_ptr< ore::data::Underlying > & underlying () const
 
const std::string & currency () const
 
const std::string & longShort () const
 
const std::string & callPut () const
 
const ore::data::ScheduleDatascheduleData () const
 
const QuantLib::Real & moneyness () const
 
const QuantLib::Real & localCap () const
 
const QuantLib::Real & localFloor () const
 
const QuantLib::Real & globalCap () const
 
const QuantLib::Real & globalFloor () const
 
QuantLib::Size settlementDays () const
 
QuantLib::Real premium () const
 
const std::string & premiumCcy () const
 
const std::string & premiumPayDate () const
 
- Public Member Functions inherited from Trade
 Trade ()
 Default constructor. More...
 
 Trade (const string &tradeType, const Envelope &env=Envelope(), const TradeActions &ta=TradeActions())
 Base class constructor. More...
 
virtual ~Trade ()
 Default destructor. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &)=0
 
virtual std::map< std::string, RequiredFixings::FixingDatesfixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
const RequiredFixingsrequiredFixings () const
 
virtual std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const
 
void reset ()
 Reset trade, clear all base class data. This does not reset accumulated timings for this trade. More...
 
void resetPricingStats (const std::size_t numberOfPricings=0, const boost::timer::nanosecond_type cumulativePricingTime=0)
 Reset accumulated timings to given values. More...
 
string & id ()
 Set the trade id. More...
 
void setEnvelope (const Envelope &envelope)
 Set the envelope with counterparty and portfolio info. More...
 
void setAdditionalData (const std::map< std::string, boost::any > &additionalData)
 
TradeActionstradeActions ()
 Set the trade actions. More...
 
const string & id () const
 
const string & tradeType () const
 
const Envelopeenvelope () const
 
const set< string > & portfolioIds () const
 
const TradeActionstradeActions () const
 
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument () const
 
const std::vector< QuantLib::Leg > & legs () const
 
const std::vector< string > & legCurrencies () const
 
const std::vector< bool > & legPayers () const
 
const string & npvCurrency () const
 
virtual QuantLib::Real notional () const
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
virtual string notionalCurrency () const
 
const Date & maturity () const
 
virtual bool isExpired (const Date &d)
 
const string & issuer () const
 
template<typename T >
additionalDatum (const std::string &tag) const
 returns any additional datum. More...
 
virtual const std::map< std::string, boost::any > & additionalData () const
 returns all additional data returned by the trade once built More...
 
const std::string & sensitivityTemplate () const
 
void validate () const
 Utility to validate that everything that needs to be set in this base class is actually set. More...
 
virtual bool hasCashflows () const
 
boost::timer::nanosecond_type getCumulativePricingTime () const
 Get cumulative timing spent on pricing. More...
 
std::size_t getNumberOfPricings () const
 Get number of pricings. More...
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Serialisation

QuantLib::ext::shared_ptr< ore::data::Underlyingunderlying_
 
std::string currency_
 
QuantLib::Real cliquetNotional_
 
std::set< QuantLib::Date > valuationDates_
 
std::string longShort_
 
std::string callPut_
 
ore::data::ScheduleData scheduleData_
 
QuantLib::Real moneyness_
 
QuantLib::Real localCap_
 
QuantLib::Real localFloor_
 
QuantLib::Real globalCap_
 
QuantLib::Real globalFloor_
 
QuantLib::Size settlementDays_
 
QuantLib::Real premium_
 
std::string premiumCcy_
 
std::string premiumPayDate_
 
virtual void fromXML (ore::data::XMLNode *node) override
 
virtual ore::data::XMLNodetoXML (ore::data::XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Member Functions inherited from Trade
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 setLegBasedAdditionalData (const Size legNo, Size resultLegId=Null< Size >()) const
 
void setSensitivityTemplate (const EngineBuilder &builder)
 
void setSensitivityTemplate (const std::string &id)
 
- Protected Attributes inherited from Trade
string tradeType_
 
QuantLib::ext::shared_ptr< InstrumentWrapperinstrument_
 
std::vector< QuantLib::Leg > legs_
 
std::vector< string > legCurrencies_
 
std::vector< boollegPayers_
 
string npvCurrency_
 
QuantLib::Real notional_
 
string notionalCurrency_
 
Date maturity_
 
string issuer_
 
string sensitivityTemplate_
 
bool sensitivityTemplateSet_ = false
 
std::size_t savedNumberOfPricings_ = 0
 
boost::timer::nanosecond_type savedCumulativePricingTime_ = 0
 
RequiredFixings requiredFixings_
 
std::map< std::string, boost::any > additionalData_
 

Detailed Description

Serializable Equity Cliquet Option.

Definition at line 36 of file cliquetoption.hpp.

Constructor & Destructor Documentation

◆ CliquetOption() [1/2]

CliquetOption ( const std::string &  tradeType)

Default constructor.

Definition at line 39 of file cliquetoption.hpp.

39: ore::data::Trade(tradeType) {}
Trade base class.
Definition: trade.hpp:55

◆ CliquetOption() [2/2]

CliquetOption ( const std::string &  tradeType,
ore::data::Envelope env,
const QuantLib::ext::shared_ptr< ore::data::Underlying > &  underlying,
std::string  currency,
QuantLib::Real  notional,
std::string  longShort,
std::string  callPut,
ore::data::ScheduleData  scheduleData,
QuantLib::Real  moneyness = 1.0,
QuantLib::Real  localCap = QuantLib::Null<QuantLib::Real>(),
QuantLib::Real  localFloor = QuantLib::Null<QuantLib::Real>(),
QuantLib::Real  globalCap = QuantLib::Null<QuantLib::Real>(),
QuantLib::Real  globalFloor = QuantLib::Null<QuantLib::Real>(),
QuantLib::Size  settlementDays = 0,
QuantLib::Real  premium = 0.0,
std::string  premiumCcy = "",
std::string  premiumPayDate = "" 
)

Constructor.

Definition at line 41 of file cliquetoption.hpp.

50 : ore::data::Trade(tradeType, env), underlying_(underlying), currency_(currency), longShort_(longShort),
51 callPut_(callPut), scheduleData_(scheduleData), moneyness_(moneyness), localCap_(localCap),
52 localFloor_(localFloor), globalCap_(globalCap), globalFloor_(globalFloor), settlementDays_(settlementDays),
53 premium_(premium), premiumCcy_(premiumCcy), premiumPayDate_(premiumPayDate) {
55 }
const Position::Type longShort_
QuantLib::ext::shared_ptr< ore::data::Underlying > underlying_
ore::data::ScheduleData scheduleData_
QuantLib::Size settlementDays_
virtual QuantLib::Real notional() const
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
Definition: trade.hpp:153
+ Here is the call graph for this function:

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &  )
override

Build QuantLib/QuantExt instrument, link pricing engine.

Definition at line 44 of file cliquetoption.cpp.

44 {
45
46 // ISDA taxonomy
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") {
52 // assuming that Commoditiy is treated like Equity
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");
60 } else {
61 WLOG("ISDA taxonomy not set for trade " << id());
62 }
63
64 additionalData_["isdaTransaction"] = string("");
65
66 Currency ccy = parseCurrency(currency_);
67
68 QL_REQUIRE(tradeActions().empty(), "TradeActions not supported for VanillaOption");
69
70 // Payoff
71 Option::Type type = parseOptionType(callPut_);
72 QuantLib::ext::shared_ptr<PercentageStrikePayoff> payoff = QuantLib::ext::make_shared<PercentageStrikePayoff>(type, moneyness_);
73
74 Schedule schedule;
75 schedule = makeSchedule(scheduleData_);
76 Date expiryDate = schedule.dates().back();
77
78 // Vanilla European/American.
79 // If price adjustment is necessary we build a simple EU Option
80 QuantLib::ext::shared_ptr<QuantLib::Instrument> instrument;
81 QuantLib::ext::shared_ptr<EuropeanExercise> exerciseDate = QuantLib::ext::make_shared<EuropeanExercise>(expiryDate);
82
83 Date paymentDate = schedule.calendar().advance(expiryDate, settlementDays_, Days);
84
85 for (auto d : schedule.dates())
86 valuationDates_.insert(schedule.calendar().adjust(d, schedule.businessDayConvention()));
87
88 Position::Type position = parsePositionType(longShort_);
89
90 // Create QuantExt Cliquet Option
91 QuantLib::ext::shared_ptr<Instrument> cliquet = QuantLib::ext::make_shared<QuantExt::CliquetOption>(
92 payoff, exerciseDate, valuationDates_, paymentDate, cliquetNotional_, position, localCap_, localFloor_,
94
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);
99
100 cliquet->setPricingEngine(cliquetOptionBuilder->engine(name(), ccy));
101 setSensitivityTemplate(*cliquetOptionBuilder);
102
103 instrument_ = QuantLib::ext::shared_ptr<InstrumentWrapper>(new VanillaInstrument(cliquet));
104
106 maturity_ = expiryDate;
109
110 // add required fixings (all valuation dates)
111 for (auto const& d : valuationDates_) {
112 requiredFixings_.addFixingDate(d, "EQ-" + name(), paymentDate);
113 }
114
115 additionalData_["notional"] = cliquetNotional_;
116}
const std::set< Date > valuationDates_
QuantLib::Real cliquetNotional_
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
TradeActions & tradeActions()
Set the trade actions.
Definition: trade.hpp:126
string npvCurrency_
Definition: trade.hpp:201
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
RequiredFixings requiredFixings_
Definition: trade.hpp:223
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument() const
Definition: trade.hpp:141
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
string notionalCurrency_
Definition: trade.hpp:203
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Vanilla Instrument Wrapper.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
Option::Type parseOptionType(const std::string &s)
Convert text to QuantLib::Option::Type.
Definition: parsers.cpp:481
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
string name
+ Here is the call graph for this function:

◆ name()

const std::string & name ( ) const

Definition at line 62 of file cliquetoption.hpp.

62{ return underlying_->name(); }

◆ underlying()

const QuantLib::ext::shared_ptr< ore::data::Underlying > & underlying ( ) const

Definition at line 63 of file cliquetoption.hpp.

63{ return underlying_; }

◆ currency()

const std::string & currency ( ) const

Definition at line 64 of file cliquetoption.hpp.

64{ return currency_; }

◆ longShort()

const std::string & longShort ( ) const

Definition at line 65 of file cliquetoption.hpp.

65{ return longShort_; }

◆ callPut()

const std::string & callPut ( ) const

Definition at line 66 of file cliquetoption.hpp.

66{ return callPut_; }

◆ scheduleData()

const ore::data::ScheduleData & scheduleData ( ) const

Definition at line 67 of file cliquetoption.hpp.

67{ return scheduleData_; }

◆ moneyness()

const QuantLib::Real & moneyness ( ) const

Definition at line 68 of file cliquetoption.hpp.

68{ return moneyness_; }
+ Here is the caller graph for this function:

◆ localCap()

const QuantLib::Real & localCap ( ) const

Definition at line 69 of file cliquetoption.hpp.

69{ return localCap_; }
+ Here is the caller graph for this function:

◆ localFloor()

const QuantLib::Real & localFloor ( ) const

Definition at line 70 of file cliquetoption.hpp.

70{ return localFloor_; }
+ Here is the caller graph for this function:

◆ globalCap()

const QuantLib::Real & globalCap ( ) const

Definition at line 71 of file cliquetoption.hpp.

71{ return globalCap_; }
+ Here is the caller graph for this function:

◆ globalFloor()

const QuantLib::Real & globalFloor ( ) const

Definition at line 72 of file cliquetoption.hpp.

72{ return globalFloor_; }
+ Here is the caller graph for this function:

◆ settlementDays()

QuantLib::Size settlementDays ( ) const

Definition at line 73 of file cliquetoption.hpp.

73{ return settlementDays_; }
+ Here is the caller graph for this function:

◆ premium()

QuantLib::Real premium ( ) const

Definition at line 74 of file cliquetoption.hpp.

74{ return premium_; }
+ Here is the caller graph for this function:

◆ premiumCcy()

const std::string & premiumCcy ( ) const

Definition at line 75 of file cliquetoption.hpp.

75{ return premiumCcy_; }
+ Here is the caller graph for this function:

◆ premiumPayDate()

const std::string & premiumPayDate ( ) const

Definition at line 76 of file cliquetoption.hpp.

76{ return premiumPayDate_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( ore::data::XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 118 of file cliquetoption.cpp.

118 {
119 Trade::fromXML(node);
120
121 XMLNode* clNode = XMLUtils::getChildNode(node, tradeType() + "Data");
122 QL_REQUIRE(clNode, "No EquityCliquetOptionData Node");
123
124 XMLNode* tmp = XMLUtils::getChildNode(clNode, "Underlying");
125 if (!tmp)
126 tmp = XMLUtils::getChildNode(node, "Name");
127 UnderlyingBuilder underlyingBuilder;
128 underlyingBuilder.fromXML(tmp);
129 underlying_ = underlyingBuilder.underlying();
130
131 currency_ = XMLUtils::getChildValue(clNode, "Currency", true);
132 cliquetNotional_ = XMLUtils::getChildValueAsDouble(clNode, "Notional", true);
133 longShort_ = XMLUtils::getChildValue(clNode, "LongShort", true);
134 callPut_ = XMLUtils::getChildValue(clNode, "OptionType", true);
135 XMLNode* scheduleNode = XMLUtils::getChildNode(clNode, "ScheduleData");
136 scheduleData_.fromXML(scheduleNode);
137 moneyness_ = XMLUtils::getChildValueAsDouble(clNode, "Moneyness", false);
138 localCap_ = getRealOrNull(clNode, "LocalCap");
139 localFloor_ = getRealOrNull(clNode, "LocalFloor");
140 globalCap_ = getRealOrNull(clNode, "GlobalCap");
141 globalFloor_ = getRealOrNull(clNode, "GlobalFloor");
142 settlementDays_ = XMLUtils::getChildValueAsInt(clNode, "SettlementDays", false);
143 premium_ = XMLUtils::getChildValueAsDouble(clNode, "Premium", false);
144 premiumCcy_ = XMLUtils::getChildValue(clNode, "PremiumCurrency", false);
145 premiumPayDate_ = XMLUtils::getChildValue(clNode, "PremiumPaymentDate", false);
146}
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
const string & tradeType() const
Definition: trade.hpp:133
const QuantLib::ext::shared_ptr< Underlying > & underlying()
Definition: underlying.hpp:266
void fromXML(XMLNode *node) override
Definition: underlying.cpp:305
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
Definition: xmlutils.cpp:286
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static int getChildValueAsInt(XMLNode *node, const string &name, bool mandatory=false, int defaultValue=0)
Definition: xmlutils.cpp:291
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( ore::data::XMLDocument doc) const
overridevirtual

Reimplemented from Trade.

Definition at line 148 of file cliquetoption.cpp.

148 {
149 XMLNode* node = Trade::toXML(doc);
150 XMLNode* clNode = doc.allocNode(tradeType() + "Data");
151 XMLUtils::appendNode(node, clNode);
152 XMLUtils::appendNode(clNode, underlying_->toXML(doc));
153 XMLUtils::addChild(doc, clNode, "Currency", currency_);
154 XMLUtils::addChild(doc, clNode, "Notional", cliquetNotional_);
155 XMLUtils::addChild(doc, clNode, "LongShort", longShort_);
156 XMLUtils::addChild(doc, clNode, "OptionType", callPut_);
158 if (moneyness_ != Null<Real>())
159 XMLUtils::addChild(doc, clNode, "Moneyness", moneyness_);
160 if (localCap_ != Null<Real>())
161 XMLUtils::addChild(doc, clNode, "LocalCap", localCap_);
162 if (localFloor_ != Null<Real>())
163 XMLUtils::addChild(doc, clNode, "LocalFloor", localFloor_);
164 if (globalCap_ != Null<Real>())
165 XMLUtils::addChild(doc, clNode, "GlobalCap", globalCap_);
166 if (globalFloor_ != Null<Real>())
167 XMLUtils::addChild(doc, clNode, "GlobalFloor", globalFloor_);
168 if (settlementDays_ != Null<Size>())
169 XMLUtils::addChild(doc, clNode, "SettlementDays", static_cast<int>(settlementDays_));
170 if (premium_ != Null<Real>())
171 XMLUtils::addChild(doc, clNode, "Premium", premium_);
172 if (premiumCcy_ != "")
173 XMLUtils::addChild(doc, clNode, "PremiumCurrency", premiumCcy_);
174 if (premiumPayDate_ != "")
175 XMLUtils::addChild(doc, clNode, "PremiumPaymentDate", premiumPayDate_);
176 return node;
177}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

Member Data Documentation

◆ underlying_

QuantLib::ext::shared_ptr<ore::data::Underlying> underlying_
private

Definition at line 86 of file cliquetoption.hpp.

◆ currency_

std::string currency_
private

Definition at line 87 of file cliquetoption.hpp.

◆ cliquetNotional_

QuantLib::Real cliquetNotional_
private

Definition at line 88 of file cliquetoption.hpp.

◆ valuationDates_

std::set<QuantLib::Date> valuationDates_
private

Definition at line 89 of file cliquetoption.hpp.

◆ longShort_

std::string longShort_
private

Definition at line 90 of file cliquetoption.hpp.

◆ callPut_

std::string callPut_
private

Definition at line 91 of file cliquetoption.hpp.

◆ scheduleData_

ore::data::ScheduleData scheduleData_
private

Definition at line 92 of file cliquetoption.hpp.

◆ moneyness_

QuantLib::Real moneyness_
private

Definition at line 93 of file cliquetoption.hpp.

◆ localCap_

QuantLib::Real localCap_
private

Definition at line 94 of file cliquetoption.hpp.

◆ localFloor_

QuantLib::Real localFloor_
private

Definition at line 95 of file cliquetoption.hpp.

◆ globalCap_

QuantLib::Real globalCap_
private

Definition at line 96 of file cliquetoption.hpp.

◆ globalFloor_

QuantLib::Real globalFloor_
private

Definition at line 97 of file cliquetoption.hpp.

◆ settlementDays_

QuantLib::Size settlementDays_
private

Definition at line 98 of file cliquetoption.hpp.

◆ premium_

QuantLib::Real premium_
private

Definition at line 99 of file cliquetoption.hpp.

◆ premiumCcy_

std::string premiumCcy_
private

Definition at line 100 of file cliquetoption.hpp.

◆ premiumPayDate_

std::string premiumPayDate_
private

Definition at line 101 of file cliquetoption.hpp.