22#include <boost/lexical_cast.hpp>
45 numbers_.emplace_back(
"Number",
"LongShort", position == Position::Long ?
"1" :
"-1");
57 "FOR i IN (1, SIZE(Underlyings), 1) DO\n" +
58 (
strikeIncluded_ ?
" p = p + Weights[i] * ( Underlyings[i](ValuationDate) / StrikePrices[i] - Strike );\n" :
59 " p = p + Weights[i] * Underlyings[i](ValuationDate) / StrikePrices[i];\n") +
61 "Option = LOGPAY( LongShort * NotionalAmount * ParticipationRate *\n" +
62 (
strikeIncluded_ ?
" max( p, 0 ), ValuationDate, SettlementDate, PayCcy );\n" :
63 " max( p - Strike, 0 ), ValuationDate, SettlementDate, PayCcy );\n") +
64 "currentNotional = NotionalAmount * ParticipationRate;\n",
65 "Option", {{
"currentNotional",
"currentNotional"}, {
"notionalCurrency",
"PayCcy"}}, {})}};
78 std::string assetClass = boost::any_cast<std::string>(
additionalData_[
"isdaAssetClass"]);
79 if (assetClass ==
"Equity") {
81 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
82 }
else if (assetClass ==
"Commodity") {
85 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
86 }
else if (assetClass ==
"Foreign Exchange") {
90 WLOG(
"ISDA taxonomy incomplete for trade " <<
id());
96 std::vector<std::string> underlyingNames, weights;
99 QL_REQUIRE(u->weight() != Null<Real>(),
"underlying '" << u->name() <<
"' has no weight");
100 weights.push_back(boost::lexical_cast<std::string>(u->weight()));
102 indices_.emplace_back(
"Index",
"Underlyings", underlyingNames);
103 numbers_.emplace_back(
"Number",
"Weights", weights);
109 QL_REQUIRE(tradeDataNode,
"PerformanceOption01Data node not found");
115 QL_REQUIRE(underlyingsNode,
"No Underlyings node");
117 for (
auto const& n : underlyings) {
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
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 void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
#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.