38 static const std::string
script =
39 "NUMBER payoff, initialIndex, triggerEvent, strikeIndexObs, strikeIndexLevel, d, resetMinValue;\n"
43 "strikeIndexLevel = Underlying(StrikeDate);\n"
45 "resetMinValue = strikeIndexLevel * ResetMinimum;\n"
47 "strikeIndexObs = Underlying(StrikeObservationDates[1]);\n"
49 "FOR d IN (1, SIZE(StrikeObservationDates), 1) DO\n"
50 " IF Underlying(StrikeObservationDates[d]) < TriggerLevel * strikeIndexLevel THEN\n"
51 " triggerEvent = 1;\n"
52 " strikeIndexObs = min(strikeIndexObs, Underlying(StrikeObservationDates[d]));\n"
56 "IF triggerEvent == 1 THEN\n"
57 " initialIndex = max(ResetMinimum * strikeIndexLevel, strikeIndexObs);\n"
59 " initialIndex = strikeIndexLevel;\n"
62 "IF Underlying(ExpiryDate) > Strike * initialIndex THEN\n"
63 " payoff = LongShort * Notional * Multiplier * min(Cap, max(0, (Underlying(ExpiryDate) - initialIndex)/initialIndex));\n"
65 " payoff = -1* LongShort * Notional * (Strike * initialIndex - Underlying(ExpiryDate))/initialIndex;\n"
68 "Option = PAY(payoff, ExpiryDate, SettlementDate, Currency) - PAY(Premium, PremiumDate, PremiumDate, Currency);\n";
85 "Expiry date must be before settlement date");
106 {{
"initialIndex",
"initialIndex"}, {
"strikeIndexLevel",
"strikeIndexLevel"},
107 {
"payoffAmount",
"payoff"}, {
"resetMinimumValue",
"resetMinValue"},
108 {
"lowestStrikeObs",
"strikeIndexObs"},
110 {
"TriggerEvent",
"triggerEvent"}},
122 std::string assetClass = boost::any_cast<std::string>(
additionalData_[
"isdaAssetClass"]);
123 if (assetClass ==
"Equity") {
125 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
126 }
else if (assetClass ==
"Commodity") {
129 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
130 }
else if (assetClass ==
"Foreign Exchange") {
134 WLOG(
"ISDA taxonomy incomplete for trade " <<
id());
144 QL_REQUIRE(tradeDataNode,
"BestEntryOptionData node not found");
155 QL_REQUIRE(underlying,
"Underlying node not found");
158 underlyingBuilder.
fromXML(underlying);
162 QL_REQUIRE(observationNode,
"No strike observation dates provided");
std::string resetMinimum_
void setIsdaTaxonomyFields() override
std::string triggerLevel_
void fromXML(XMLNode *node) override
QuantLib::ext::shared_ptr< Underlying > underlying_
XMLNode * toXML(XMLDocument &doc) const override
ScheduleData observationDates_
std::string settlementDate_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
bool hasData() const
Check if has any dates/rules/derived schedules.
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const std::map< std::string, ScriptedTradeScriptData > & script() const
std::vector< ScriptedTradeEventData > events_
std::vector< ScriptedTradeValueTypeData > currencies_
std::vector< ScriptedTradeValueTypeData > indices_
virtual void setIsdaTaxonomyFields()
std::vector< ScriptedTradeValueTypeData > numbers_
std::map< std::string, ScriptedTradeScriptData > script_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
const string & tradeType() const
std::map< std::string, boost::any > additionalData_
const QuantLib::ext::shared_ptr< Underlying > & underlying()
void fromXML(XMLNode *node) override
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
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.
#define WLOG(text)
Logging Macro (Level = Warning)
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName(const QuantLib::ext::shared_ptr< Underlying > &underlying)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
trade schedule data model and serialization
string conversion utilities