Build QuantLib/QuantExt instrument, link pricing engine.
61 {
62
63
66 additionalData_[
"isdaSubProduct"] = string(
"Price Return Basic Performance");
67
69
70 const QuantLib::ext::shared_ptr<Market> market = engineFactory->market();
73
74 QL_REQUIRE(
tradeActions().empty(),
"TradeActions not supported for FxOption");
76 QL_REQUIRE(
barrier_.
levels().size() == 2,
"Invalid number of barrier levels");
78
79
87
88 QL_REQUIRE(rebate == 0, "Rebates not supported for EquityDoubleTouchOptions");
89 if (payoffAtExpiry == false) {
90 payoffAtExpiry = true;
91 DLOG(
"Payoff at hit not yet supported for EquityDoubleTouchOptions, setting to payoff at expiry");
92 }
93
96 QL_REQUIRE(levelLow < levelHigh, "barrier levels are not in ascending order");
97
98
99
100 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff(new CashOrNothingPayoff(Option::Call, (levelLow + levelHigh) / 2, 1.0));
101 Leg leg;
102
103 leg.push_back(QuantLib::ext::shared_ptr<CashFlow>(new SimpleCashFlow(1.0, expiryDate)));
104
105 QuantLib::ext::shared_ptr<Exercise> exercise = QuantLib::ext::make_shared<EuropeanExercise>(expiryDate);
106
107 QuantLib::ext::shared_ptr<Instrument> doubleTouch =
108 QuantLib::ext::make_shared<DoubleBarrierOption>(barrierType, levelLow, levelHigh, 0.0, payoff, exercise);
109 QuantLib::ext::shared_ptr<Instrument> underlying = QuantLib::ext::make_shared<Swap>(Leg(), leg);
110
111
112
113 QuantLib::ext::shared_ptr<QuantExt::EquityIndex2> eqIndex = engineFactory->market()->equityCurve(assetName).currentLink();
114
115
116 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder(
tradeType_);
117 QL_REQUIRE(builder,
"No builder found for " <<
tradeType_);
118 QuantLib::ext::shared_ptr<EquityDoubleTouchOptionEngineBuilder> eqDoubleTouchOptBuilder =
119 QuantLib::ext::dynamic_pointer_cast<EquityDoubleTouchOptionEngineBuilder>(builder);
120 doubleTouch->setPricingEngine(eqDoubleTouchOptBuilder->engine(assetName, ccy));
122 if (
type_ ==
"KnockIn") {
123
124
125 builder = engineFactory->builder("Swap");
126 QL_REQUIRE(builder, "No builder found for Swap");
127 QuantLib::ext::shared_ptr<SwapEngineBuilderBase> swapBuilder =
128 QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(builder);
130 }
131
132 bool isLong = (positionType == Position::Long) ? true : false;
133
134 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
135 std::vector<Real> additionalMultipliers;
139
140 Handle<Quote> spot = market->equitySpot(assetName);
141 instrument_ = QuantLib::ext::make_shared<DoubleBarrierOptionWrapper>(
142 doubleTouch, isLong, expiryDate, false, underlying, barrierType, spot, levelLow, levelHigh, 0, ccy, start, eqIndex, cal,
147 maturity_ = std::max(lastPremiumDate, expiryDate);
148
149 if (start != Date()) {
150 for (Date d = start; d <= expiryDate; d = eqIndex->fixingCalendar().advance(d, 1 * Days))
152 }
153
156}
std::vector< ore::data::TradeBarrier > levels() const
const std::string & style() const
const string & equityName() const
const string & longShort() const
const bool & payoffAtExpiry() const
const PremiumData & premiumData() const
const vector< string > & exerciseDates() const
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
TradeActions & tradeActions()
Set the trade actions.
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 setSensitivityTemplate(const EngineBuilder &builder)
RequiredFixings requiredFixings_
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
#define DLOG(text)
Logging Macro (Level = Debug)