24#ifndef quantext_eq_comm_option_surface_stripper_hpp
25#define quantext_eq_comm_option_surface_stripper_hpp
31#include <ql/exercise.hpp>
32#include <ql/instruments/vanillaoption.hpp>
33#include <ql/math/solvers1d/brent.hpp>
34#include <ql/patterns/lazyobject.hpp>
35#include <ql/processes/blackscholesprocess.hpp>
36#include <ql/quotes/simplequote.hpp>
37#include <ql/termstructures/yieldtermstructure.hpp>
49 QuantLib::Real
accuracy = QuantLib::Null<QuantLib::Real>();
53 std::pair<QuantLib::Real, QuantLib::Real>
minMax =
54 std::make_pair(QuantLib::Null<QuantLib::Real>(), QuantLib::Null<QuantLib::Real>());
56 QuantLib::Real
step = QuantLib::Null<QuantLib::Real>();
58 QuantLib::Real
lowerBound = QuantLib::Null<QuantLib::Real>();
60 QuantLib::Real
upperBound = QuantLib::Null<QuantLib::Real>();
68 const QuantLib::ext::shared_ptr<OptionInterpolatorBase>& putSurface,
69 const QuantLib::Calendar& calendar,
70 const QuantLib::DayCounter& dayCounter,
71 QuantLib::Exercise::Type type = QuantLib::Exercise::European,
72 bool lowerStrikeConstExtrap =
true,
73 bool upperStrikeConstExtrap =
true,
74 bool timeFlatExtrapolation =
false,
75 bool preferOutOfTheMoney =
false,
84 QuantLib::ext::shared_ptr<QuantLib::BlackVolTermStructure>
volSurface();
88 virtual QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>
process(
89 const QuantLib::ext::shared_ptr<QuantLib::SimpleQuote>& volatilityQuote)
const = 0;
92 virtual QuantLib::Real
forward(
const QuantLib::Date& date)
const = 0;
95 QuantLib::ext::shared_ptr<OptionInterpolatorBase>
putSurface_;
108 PriceError(
const QuantLib::VanillaOption& option, QuantLib::SimpleQuote& volatility,
109 QuantLib::Real targetPrice);
111 QuantLib::Real
operator()(QuantLib::Volatility volatility)
const;
120 std::vector<QuantLib::Real>
strikes(
const QuantLib::Date& expiry,
bool isCall)
const;
128 QuantLib::Real
implyVol(QuantLib::Date expiry,
129 QuantLib::Real strike,
130 QuantLib::Option::Type type,
131 QuantLib::ext::shared_ptr<QuantLib::PricingEngine> engine,
132 QuantLib::SimpleQuote& volQuote)
const;
137 mutable QuantLib::ext::shared_ptr<QuantLib::BlackVolTermStructure>
volSurface_;
154 const QuantLib::ext::shared_ptr<OptionInterpolatorBase>& callSurface,
155 const QuantLib::ext::shared_ptr<OptionInterpolatorBase>& putSurface,
156 const QuantLib::Calendar& calendar,
157 const QuantLib::DayCounter& dayCounter,
158 QuantLib::Exercise::Type type = QuantLib::Exercise::European,
159 bool lowerStrikeConstExtrap =
true,
160 bool upperStrikeConstExtrap =
true,
161 bool timeFlatExtrapolation =
false,
162 bool preferOutOfTheMoney =
false,
168 QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>
process(
169 const QuantLib::ext::shared_ptr<QuantLib::SimpleQuote>& volatilityQuote)
const override;
171 QuantLib::Real
forward(
const QuantLib::Date& date)
const override;
182 const QuantLib::Handle<QuantExt::PriceTermStructure>& priceCurve,
183 const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve,
184 const QuantLib::ext::shared_ptr<OptionInterpolatorBase>& callSurface,
185 const QuantLib::ext::shared_ptr<OptionInterpolatorBase>& putSurface,
186 const QuantLib::Calendar& calendar,
187 const QuantLib::DayCounter& dayCounter,
188 QuantLib::Exercise::Type type = QuantLib::Exercise::European,
189 bool lowerStrikeConstExtrap =
true,
190 bool upperStrikeConstExtrap =
true,
191 bool timeFlatExtrapolation =
false,
192 bool preferOutOfTheMoney =
false,
198 QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>
process(
199 const QuantLib::ext::shared_ptr<QuantLib::SimpleQuote>& volatilityQuote)
const override;
201 QuantLib::Real
forward(
const QuantLib::Date& date)
const override;
QuantLib::Handle< QuantExt::PriceTermStructure > priceCurve_
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
QuantLib::Real forward(const QuantLib::Date &date) const override
Return the forward price at a given date.
QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process(const QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > &volatilityQuote) const override
Generate the relevant Black Scholes process for the underlying.
QuantLib::Handle< QuantExt::EquityIndex2 > equityIndex_
QuantLib::Real forward(const QuantLib::Date &date) const override
Return the forward price at a given date.
QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process(const QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > &volatilityQuote) const override
Generate the relevant Black Scholes process for the underlying.
Function object used in solving.
QuantLib::Real operator()(QuantLib::Volatility volatility) const
QuantLib::SimpleQuote & volatility_
QuantLib::Real targetPrice_
const QuantLib::VanillaOption & option_
Abstract base class for the option stripper.
QuantLib::Exercise::Type type_
void performCalculations() const override
const QuantLib::DayCounter & dayCounter_
bool upperStrikeConstExtrap_
const QuantLib::Calendar & calendar_
virtual QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process(const QuantLib::ext::shared_ptr< QuantLib::SimpleQuote > &volatilityQuote) const =0
Generate the relevant Black Scholes process for the underlying.
QuantLib::ext::shared_ptr< QuantLib::BlackVolTermStructure > volSurface_
Solver1DOptions solverOptions_
bool havePrices_
Set to true if we must strip volatilities from prices.
virtual QuantLib::Real forward(const QuantLib::Date &date) const =0
Return the forward price at a given date.
QuantLib::ext::shared_ptr< QuantLib::BlackVolTermStructure > volSurface()
Return the stripped volatility structure.
QuantLib::ext::shared_ptr< OptionInterpolatorBase > putSurface_
std::function< Real(const PriceError &)> solver_
Store the function that will be called each time to solve for volatility.
Brent brent_
Solver used when implying volatility from price.
bool timeFlatExtrapolation_
bool lowerStrikeConstExtrap_
QuantLib::Real implyVol(QuantLib::Date expiry, QuantLib::Real strike, QuantLib::Option::Type type, QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engine, QuantLib::SimpleQuote &volQuote) const
QuantLib::ext::shared_ptr< OptionInterpolatorBase > callSurface_
bool preferOutOfTheMoney_
equity index class for holding equity fixing histories and forwarding.
Surface to store option prices.
Term structure of prices.
std::pair< QuantLib::Real, QuantLib::Real > minMax
Set the minimum and maximum search.
QuantLib::Real accuracy
The accuracy for the search.
QuantLib::Real initialGuess
The initial guess for the search.
QuantLib::Real upperBound
The upper bound of the search domain. A Null<Real>() indicates that the bound should not be set.
QuantLib::Real lowerBound
The lower bound of the search domain. A Null<Real>() indicates that the bound should not be set.
QuantLib::Real step
Set the step size for the search.
QuantLib::Size maxEvaluations
The maximum number of evaluations. Default used if not set.