41
42 string scriptStr;
43
44 if (scriptedLibraryOverride) {
45 QL_REQUIRE(tradeTypes.size() == 1, "");
46 string scriptName = *tradeTypes.begin();
47
48 QL_REQUIRE(ScriptLibraryStorage::instance().get().has(scriptName, ""),
49 "script '" << scriptName << "' not found in library");
50 ScriptedTradeScriptData
script = ScriptLibraryStorage::instance().get().get(scriptName,
"").second;
52 } else {
53 scriptStr = "NUMBER Payoff, d, premiumPayment;\n"
54 "Payoff = 0;\n"
55 "premiumPayment = 0;\n"
56 "IF PremiumPaymentDate >= TODAY THEN"
57 " premiumPayment = PAY(LongShort * Notional * Premium, PremiumPaymentDate, PremiumPaymentDate, "
58 "PremiumCurrency);"
59 "END;\n"
60 "FOR d IN (2, SIZE(ValuationDates), 1) DO"
61 " Payoff = Payoff + min( max( Type * ( (Underlying(ValuationDates[d]) / "
62 "Underlying(ValuationDates[d-1])) - Moneyness ), LocalFloor ), LocalCap );"
63 "END;\n"
64 "Option = premiumPayment + PAY( LongShort * Notional * min( max( Payoff, GlobalFloor ), GlobalCap "
65 "), Expiry, PayDate, PayCcy );\n";
66 }
67
68 ScriptParser parser(scriptStr);
69 QL_REQUIRE(parser.success(), "could not initialise AST for McScriptEuropeanEngine: " << parser.error());
72}
const Size regressionOrder_
const QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > p_
const std::string underlyingCcy_
const std::string baseCcy_
const std::string underlying_