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

#include <ored/portfolio/autocallable_01.hpp>

+ Inheritance diagram for Autocallable_01:
+ Collaboration diagram for Autocallable_01:

Public Member Functions

 Autocallable_01 ()
 
 Autocallable_01 (const Envelope &env, const string &notionalAmount, const string &determinationLevel, const string &triggerLevel, const QuantLib::ext::shared_ptr< Underlying > &underlying, const string &position, const string &payCcy, const ScheduleData &fixingDates, const ScheduleData &settlementDates, const vector< string > &accumulationFactors, const string &cap)
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 
void setIsdaTaxonomyFields () override
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
- Public Member Functions inherited from ScriptedTrade
 ScriptedTrade (const std::string &tradeType="ScriptedTrade", const Envelope &env=Envelope())
 
 ScriptedTrade (const Envelope &env, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > &currencies, const std::vector< ScriptedTradeValueTypeData > &daycounters, const std::map< std::string, ScriptedTradeScriptData > &script, const std::string &productTag, const std::string &tradeType="ScriptedTrade")
 
 ScriptedTrade (const Envelope &env, const std::vector< ScriptedTradeEventData > &events, const std::vector< ScriptedTradeValueTypeData > &numbers, const std::vector< ScriptedTradeValueTypeData > &indices, const std::vector< ScriptedTradeValueTypeData > &currencies, const std::vector< ScriptedTradeValueTypeData > &daycounters, const std::string &scriptName, const std::string &tradeType="ScriptedTrade")
 
void clear ()
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 
QuantLib::Real notional () const override
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
std::string notionalCurrency () const override
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (ore::data::XMLDocument &doc) const override
 
void build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const PremiumData &premiumData, const Real premiumMultiplier)
 
std::map< ore::data::AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
 
virtual void setIsdaTaxonomyFields ()
 
const std::vector< ScriptedTradeEventData > & events () const
 
const std::vector< ScriptedTradeValueTypeData > & numbers () const
 
const std::vector< ScriptedTradeValueTypeData > & indices () const
 
const std::vector< ScriptedTradeValueTypeData > & currencies () const
 
const std::vector< ScriptedTradeValueTypeData > & daycounters () const
 
const std::map< std::string, ScriptedTradeScriptData > & script () const
 
const std::string & productTag () const
 
const std::string & scriptName () const
 
const std::string & simmProductClass () const
 
const std::string & scheduleProductClass () const
 
const ScriptedTradeScriptDatascript (const std::string &purpose, const bool fallBackOnEmptyPurpose=true) 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
 
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...
 

Private Member Functions

void initIndices ()
 

Private Attributes

string notionalAmount_
 
string determinationLevel_
 
string triggerLevel_
 
string position_
 
string payCcy_
 
QuantLib::ext::shared_ptr< Underlyingunderlying_
 
ScheduleData fixingDates_
 
ScheduleData settlementDates_
 
vector< string > accumulationFactors_
 
string cap_
 

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 ScriptedTrade
std::vector< ScriptedTradeEventDataevents_
 
std::vector< ScriptedTradeValueTypeDatanumbers_
 
std::vector< ScriptedTradeValueTypeDataindices_
 
std::vector< ScriptedTradeValueTypeDatacurrencies_
 
std::vector< ScriptedTradeValueTypeDatadaycounters_
 
std::map< std::string, ScriptedTradeScriptDatascript_
 
std::string productTag_
 
std::string scriptName_
 
std::string simmProductClass_
 
std::string scheduleProductClass_
 
- 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

Definition at line 33 of file autocallable_01.hpp.

Constructor & Destructor Documentation

◆ Autocallable_01() [1/2]

Definition at line 35 of file autocallable_01.hpp.

35: ScriptedTrade("Autocallable_01") {}
ScriptedTrade(const std::string &tradeType="ScriptedTrade", const Envelope &env=Envelope())

◆ Autocallable_01() [2/2]

Autocallable_01 ( const Envelope env,
const string &  notionalAmount,
const string &  determinationLevel,
const string &  triggerLevel,
const QuantLib::ext::shared_ptr< Underlying > &  underlying,
const string &  position,
const string &  payCcy,
const ScheduleData fixingDates,
const ScheduleData settlementDates,
const vector< string > &  accumulationFactors,
const string &  cap 
)

Definition at line 36 of file autocallable_01.hpp.

40 : ScriptedTrade("Autocallable_01", env), notionalAmount_(notionalAmount),
41 determinationLevel_(determinationLevel), triggerLevel_(triggerLevel), position_(position), payCcy_(payCcy),
42 underlying_(underlying), fixingDates_(fixingDates), settlementDates_(settlementDates),
43 accumulationFactors_(accumulationFactors), cap_(cap) {
45 }
vector< string > accumulationFactors_
QuantLib::ext::shared_ptr< Underlying > underlying_
+ Here is the call graph for this function:

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< EngineFactory > &  )
overridevirtual

Build QuantLib/QuantExt instrument, link pricing engine. If build() is called multiple times, reset() should be called between these calls.

Implements Trade.

Definition at line 25 of file autocallable_01.cpp.

25 {
26
27 // set script parameters
28
29 clear();
31
32 numbers_.emplace_back("Number", "NotionalAmount", notionalAmount_);
33 numbers_.emplace_back("Number", "DeterminationLevel", determinationLevel_);
34 numbers_.emplace_back("Number", "TriggerLevel", triggerLevel_);
35
36 Position::Type position = parsePositionType(position_);
37 numbers_.emplace_back("Number", "LongShort", position == Position::Long ? "1" : "-1");
38
39 currencies_.emplace_back("Currency", "PayCcy", payCcy_);
40
41 events_.emplace_back("FixingDates", fixingDates_);
42 events_.emplace_back("SettlementDates", settlementDates_);
43
44 numbers_.emplace_back("Number", "AccumulationFactors", accumulationFactors_);
45 numbers_.emplace_back("Number", "Cap", cap_);
46
47 // set product tag
48
49 productTag_ = "MultiAssetOption({AssetClass})";
50
51 // set script
52
53 script_ = {{"", ScriptedTradeScriptData(
54 "NUMBER i, terminated, currentNotional;\n"
55 "FOR i IN (1, SIZE(FixingDates), 1) DO\n"
56 " IF terminated == 0 AND Underlying(FixingDates[i]) <= TriggerLevel THEN\n"
57 " Option = LOGPAY( LongShort * NotionalAmount * AccumulationFactors[i], FixingDates[i],\n"
58 " SettlementDates[i], PayCcy);\n"
59 " terminated = 1;\n"
60 " END;\n"
61 " IF terminated == 0 AND i == SIZE(FixingDates) AND Underlying(FixingDates[i]) > "
62 "DeterminationLevel THEN\n"
63 " Option = LOGPAY( -LongShort * NotionalAmount * min( Cap, Underlying(FixingDates[i]) -\n"
64 " DeterminationLevel ),\n"
65 " FixingDates[i], SettlementDates[i], PayCcy);\n"
66 " END;\n"
67 "END;\n",
68 "Option", {{"currentNotional", "NotionalAmount"}, {"notionalCurrency", "PayCcy"}}, {})}};
69
70 // build trade
71
72 ScriptedTrade::build(factory);
73}
std::vector< ScriptedTradeEventData > events_
std::vector< ScriptedTradeValueTypeData > currencies_
std::vector< ScriptedTradeValueTypeData > numbers_
std::map< std::string, ScriptedTradeScriptData > script_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
+ Here is the call graph for this function:

◆ setIsdaTaxonomyFields()

void setIsdaTaxonomyFields ( )
overridevirtual

Reimplemented from ScriptedTrade.

Definition at line 75 of file autocallable_01.cpp.

75 {
77
78 // ISDA taxonomy, asset class set in the base class build
79 // asset class set in the base class already
80 std::string assetClass = boost::any_cast<std::string>(additionalData_["isdaAssetClass"]);
81 if (assetClass == "Equity") {
82 additionalData_["isdaBaseProduct"] = string("Other");
83 additionalData_["isdaSubProduct"] = string("Price Return Basic Performance");
84 }
85 else if (assetClass == "Commodity") {
86 // isda taxonomy missing for this class, using the same as equity
87 additionalData_["isdaBaseProduct"] = string("Other");
88 additionalData_["isdaSubProduct"] = string("Price Return Basic Performance");
89 }
90 else if (assetClass == "Foreign Exchange") {
91 additionalData_["isdaBaseProduct"] = string("Exotic");
92 additionalData_["isdaSubProduct"] = string("Target");
93 }
94 else {
95 WLOG("ISDA taxonomy incomplete for trade " << id());
96 }
97 additionalData_["isdaTransaction"] = string("");
98}
virtual void setIsdaTaxonomyFields()
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 102 of file autocallable_01.cpp.

102 {
103 Trade::fromXML(node);
104 XMLNode* tradeDataNode = XMLUtils::getChildNode(node, "Autocallable01Data");
105 QL_REQUIRE(tradeDataNode, "Autocallable01Data node not found");
106 notionalAmount_ = XMLUtils::getChildValue(tradeDataNode, "NotionalAmount");
107 determinationLevel_ = XMLUtils::getChildValue(tradeDataNode, "DeterminationLevel");
108 triggerLevel_ = XMLUtils::getChildValue(tradeDataNode, "TriggerLevel");
109
110 XMLNode* tmp = XMLUtils::getChildNode(tradeDataNode, "Underlying");
111 if (!tmp)
112 tmp = XMLUtils::getChildNode(tradeDataNode, "Name");
113 UnderlyingBuilder underlyingBuilder;
114 underlyingBuilder.fromXML(tmp);
115 underlying_ = underlyingBuilder.underlying();
116
117 position_ = XMLUtils::getChildValue(tradeDataNode, "Position", true);
118 payCcy_ = XMLUtils::getChildValue(tradeDataNode, "PayCcy", true);
119 fixingDates_.fromXML(XMLUtils::getChildNode(XMLUtils::getChildNode(tradeDataNode, "FixingDates"), "ScheduleData"));
121 XMLUtils::getChildNode(XMLUtils::getChildNode(tradeDataNode, "SettlementDates"), "ScheduleData"));
122 accumulationFactors_ = XMLUtils::getChildrenValues(tradeDataNode, "AccumulationFactors", "Factor");
123 cap_ = XMLUtils::getChildValue(tradeDataNode, "Cap");
124 initIndices();
125}
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
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 vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from Trade.

Definition at line 127 of file autocallable_01.cpp.

127 {
128 XMLNode* node = Trade::toXML(doc);
129 XMLNode* tradeNode = doc.allocNode("Autocallable01Data");
130 XMLUtils::appendNode(node, tradeNode);
131 XMLUtils::addChild(doc, tradeNode, "NotionalAmount", notionalAmount_);
132 XMLUtils::addChild(doc, tradeNode, "DeterminationLevel", determinationLevel_);
133 XMLUtils::addChild(doc, tradeNode, "TriggerLevel", triggerLevel_);
134 XMLUtils::appendNode(tradeNode, underlying_->toXML(doc));
135 XMLUtils::addChild(doc, tradeNode, "Position", position_);
136 XMLUtils::addChild(doc, tradeNode, "PayCcy", payCcy_);
137 XMLNode* f = doc.allocNode("FixingDates");
139 XMLUtils::appendNode(tradeNode, f);
140 XMLNode* s = doc.allocNode("SettlementDates");
142 XMLUtils::appendNode(tradeNode, s);
143 XMLUtils::addChildren(doc, tradeNode, "AccumulationFactors", "Factor", accumulationFactors_);
144 XMLUtils::addChild(doc, tradeNode, "Cap", cap_);
145 return node;
146}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
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:

◆ initIndices()

void initIndices ( )
private

Definition at line 100 of file autocallable_01.cpp.

100{ indices_.emplace_back("Index", "Underlying", scriptedIndexName(underlying_)); }
std::vector< ScriptedTradeValueTypeData > indices_
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName(const QuantLib::ext::shared_ptr< Underlying > &underlying)
Definition: utilities.cpp:614
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ notionalAmount_

string notionalAmount_
private

Definition at line 53 of file autocallable_01.hpp.

◆ determinationLevel_

string determinationLevel_
private

Definition at line 53 of file autocallable_01.hpp.

◆ triggerLevel_

string triggerLevel_
private

Definition at line 53 of file autocallable_01.hpp.

◆ position_

string position_
private

Definition at line 53 of file autocallable_01.hpp.

◆ payCcy_

string payCcy_
private

Definition at line 53 of file autocallable_01.hpp.

◆ underlying_

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

Definition at line 54 of file autocallable_01.hpp.

◆ fixingDates_

ScheduleData fixingDates_
private

Definition at line 55 of file autocallable_01.hpp.

◆ settlementDates_

ScheduleData settlementDates_
private

Definition at line 55 of file autocallable_01.hpp.

◆ accumulationFactors_

vector<string> accumulationFactors_
private

Definition at line 56 of file autocallable_01.hpp.

◆ cap_

string cap_
private

Definition at line 57 of file autocallable_01.hpp.