157 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> adapter(new StrippedOptionletAdapter(optionletStripper));
158 adapter->enableExtrapolation();
159
160
161
162 spreadQuote_ = QuantLib::ext::shared_ptr<SimpleQuote>(
new SimpleQuote(-1.0));
163
164 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> spreadedAdapter(
165 new SpreadedOptionletVolatility(Handle<OptionletVolatilityStructure>(adapter), Handle<Quote>(
spreadQuote_)));
166
167
168
169 QuantLib::ext::shared_ptr<PricingEngine> engine;
170 if (optionletStripper->volatilityType() == ShiftedLognormal) {
171 engine = QuantLib::ext::make_shared<BlackCapFloorEngine>(
172 discount_, Handle<OptionletVolatilityStructure>(spreadedAdapter), optionletStripper->displacement());
173 } else if (optionletStripper->volatilityType() == Normal) {
174 engine = QuantLib::ext::make_shared<BachelierCapFloorEngine>(
discount_,
175 Handle<OptionletVolatilityStructure>(spreadedAdapter));
176 } else {
177 QL_FAIL("Unknown volatility type: " << optionletStripper->volatilityType());
178 }
179
180 cap_->setPricingEngine(engine);
181}
const Handle< YieldTermStructure > discount_
QuantLib::ext::shared_ptr< SimpleQuote > spreadQuote_
QuantLib::ext::shared_ptr< QuantLib::CapFloor > cap_