Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
OptionletStripper2::ObjectiveFunction Class Reference
+ Collaboration diagram for OptionletStripper2::ObjectiveFunction:

Public Member Functions

 ObjectiveFunction (const QuantLib::ext::shared_ptr< QuantExt::OptionletStripper > &, const QuantLib::ext::shared_ptr< QuantLib::CapFloor > &, Real targetValue, const Handle< YieldTermStructure > &discount)
 
Real operator() (Volatility spreadVol) const
 

Private Attributes

QuantLib::ext::shared_ptr< SimpleQuote > spreadQuote_
 
QuantLib::ext::shared_ptr< QuantLib::CapFloor > cap_
 
Real targetValue_
 
const Handle< YieldTermStructure > discount_
 

Detailed Description

Definition at line 62 of file optionletstripper2.hpp.

Constructor & Destructor Documentation

◆ ObjectiveFunction()

ObjectiveFunction ( const QuantLib::ext::shared_ptr< QuantExt::OptionletStripper > &  ,
const QuantLib::ext::shared_ptr< QuantLib::CapFloor > &  ,
Real  targetValue,
const Handle< YieldTermStructure > &  discount 
)

Definition at line 153 of file optionletstripper2.cpp.

156 : cap_(cap), targetValue_(targetValue), discount_(discount) {
157 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> adapter(new StrippedOptionletAdapter(optionletStripper));
158 adapter->enableExtrapolation();
159
160 // set an implausible value, so that calculation is forced
161 // at first operator()(Volatility x) call
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 // Use the same volatility type as optionletStripper
168 // Anything else would not make sense
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_

Member Function Documentation

◆ operator()()

Real operator() ( Volatility  spreadVol) const

Definition at line 183 of file optionletstripper2.cpp.

183 {
184 if (s != spreadQuote_->value())
185 spreadQuote_->setValue(s);
186 return cap_->NPV() - targetValue_;
187}

Member Data Documentation

◆ spreadQuote_

QuantLib::ext::shared_ptr<SimpleQuote> spreadQuote_
private

Definition at line 70 of file optionletstripper2.hpp.

◆ cap_

QuantLib::ext::shared_ptr<QuantLib::CapFloor> cap_
private

Definition at line 71 of file optionletstripper2.hpp.

◆ targetValue_

Real targetValue_
private

Definition at line 72 of file optionletstripper2.hpp.

◆ discount_

const Handle<YieldTermStructure> discount_
private

Definition at line 73 of file optionletstripper2.hpp.