26std::pair<std::string, std::string>
getLowerAndUpperBound(
const std::string& type,
const std::string& binaryLevelA,
27 const std::string& binaryLevelB) {
30 }
else if (type ==
"Put") {
32 }
else if (type ==
"Collar") {
33 return {binaryLevelA, binaryLevelB};
35 QL_FAIL(
"DoubleDigitalOption got unexpected option type '"
36 << type <<
"'. Valid values are 'Call', 'Put' and 'Collar'.");
51 std::string lowerBound1, upperBound1, lowerBound2, upperBound2;
56 numbers_.emplace_back(
"Number",
"LowerBound1", lowerBound1);
57 numbers_.emplace_back(
"Number",
"UpperBound1", upperBound1);
58 numbers_.emplace_back(
"Number",
"LowerBound2", lowerBound2);
59 numbers_.emplace_back(
"Number",
"UpperBound2", upperBound2);
62 numbers_.emplace_back(
"Number",
"LongShort", position == Position::Long ?
"1" :
"-1");
69 "underlying type " <<
underlying1_->type() <<
" not supported");
72 "underlying type " <<
underlying2_->type() <<
" not supported");
76 "underlying type " <<
underlying3_->type() <<
" not supported");
79 "Underlying1 and Underlying3 must belong to the same asset class. Got "
85 "underlying type " <<
underlying4_->type() <<
" not supported");
88 "Underlying2 and Underlying4 must belong to the same asset class. Got "
104 string underlying1Str, underlying2Str;
105 underlying1Str =
underlying3_ ?
"(Underlying1(Expiry) - Underlying3(Expiry))" :
"Underlying1(Expiry)";
106 underlying2Str =
underlying4_ ?
"(Underlying2(Expiry) - Underlying4(Expiry))" :
"Underlying2(Expiry)";
111 "IF " + underlying1Str +
" >= LowerBound1 AND " + underlying1Str +
" <= UpperBound1 AND\n"
112 " " + underlying2Str +
" >= LowerBound2 AND " + underlying2Str +
" <= UpperBound2 THEN\n"
113 " Option = LongShort * LOGPAY( BinaryPayout, Expiry, Settlement, PayCcy);\n"
114 " ExerciseProbability = 1;\n"
117 {{
"ExerciseProbability",
"ExerciseProbability"},
118 {
"currentNotional",
"BinaryPayout"},
119 {
"notionalCurrency",
"PayCcy"}},
140 QL_REQUIRE(tradeDataNode,
"DoubleDigitalOptionData node not found");
157 "A non empty upper bound 'BinaryLevelUpper1' is required if and only if a type1 is set to 'Collar', "
158 "please check trade xml.");
162 "A non empty upper bound 'BinaryLevelUpper2' is required if and only if a type2 is set to 'Collar', "
163 "please check trade xml.");
169 underlyingBuilder1.
fromXML(tmp);
176 underlyingBuilder2.
fromXML(tmp);
184 underlyingBuilder3.
fromXML(tmp);
193 underlyingBuilder4.
fromXML(tmp);
string binaryLevelUpper2_
QuantLib::ext::shared_ptr< Underlying > underlying4_
QuantLib::ext::shared_ptr< Underlying > underlying1_
string binaryLevelUpper1_
QuantLib::ext::shared_ptr< Underlying > underlying3_
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
QuantLib::ext::shared_ptr< Underlying > underlying2_
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
std::vector< ScriptedTradeEventData > events_
std::vector< ScriptedTradeValueTypeData > currencies_
std::vector< ScriptedTradeValueTypeData > indices_
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 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 XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
double digital option wrapper for scripted trade
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
#define LOG(text)
Logging Macro (Level = Notice)
QL_DEPRECATED_ENABLE_WARNING std::string scriptedIndexName(const QuantLib::ext::shared_ptr< Underlying > &underlying)
std::string to_string(const LocationInfo &l)
std::pair< std::string, std::string > getLowerAndUpperBound(const std::string &type, const std::string &binaryLevelA, const std::string &binaryLevelB)
Serializable Credit Default Swap.
string conversion utilities