24#ifndef quantlib_zabr_interpolated_smile_section_hpp
25#define quantlib_zabr_interpolated_smile_section_hpp
37template <
typename Evaluation>
44 const Date& optionDate,
46 const std::vector<Rate>& strikes,
47 bool hasFloatingStrikes,
55 bool isAlphaFixed =
false,
56 bool isBetaFixed =
false,
57 bool isNuFixed =
false,
58 bool isRhoFixed =
false,
59 bool isGammaFixed =
false,
60 bool vegaWeighted =
true,
61 ext::shared_ptr<EndCriteria>
endCriteria = ext::shared_ptr<EndCriteria>(),
62 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
66 const Date& optionDate,
68 const std::vector<Rate>& strikes,
69 bool hasFloatingStrikes,
71 const std::vector<Volatility>& vols,
77 bool isAlphaFixed =
false,
78 bool isBetaFixed =
false,
79 bool isNuFixed =
false,
80 bool isRhoFixed =
false,
81 bool isGammaFixed =
false,
82 bool vegaWeighted =
true,
83 ext::shared_ptr<EndCriteria>
endCriteria = ext::shared_ptr<EndCriteria>(),
84 ext::shared_ptr<OptimizationMethod> method = ext::shared_ptr<OptimizationMethod>(),
127 mutable std::vector<Volatility>
vols_;
134 const ext::shared_ptr<OptimizationMethod>
method_;
137template <
typename Evaluation>
143template <
typename Evaluation>
147 return (*zabrInterpolation_)(strike,
true);
150template <
typename Evaluation>
153 return zabrInterpolation_->alpha();
156template <
typename Evaluation>
159 return zabrInterpolation_->beta();
162template <
typename Evaluation>
165 return zabrInterpolation_->nu();
168template <
typename Evaluation>
171 return zabrInterpolation_->rho();
174template <
typename Evaluation>
177 return zabrInterpolation_->gamma();
180template <
typename Evaluation>
183 return zabrInterpolation_->rmsError();
186template <
typename Evaluation>
189 return zabrInterpolation_->maxError();
192template <
typename Evaluation>
196 return zabrInterpolation_->endCriteria();
199template <
typename Evaluation>
202 return actualStrikes_.front();
205template <
typename Evaluation>
208 return actualStrikes_.back();
211template <
typename Evaluation>
214 return forwardValue_;
217template <
typename Evaluation>
219 const Date& optionDate,
221 const std::vector<Rate>& strikes,
222 bool hasFloatingStrikes,
236 ext::shared_ptr<EndCriteria> endCriteria,
237 ext::shared_ptr<OptimizationMethod> method,
240 atmVolatility_(
std::move(atmVolatility)), volHandles_(volHandles), strikes_(strikes),
241 actualStrikes_(strikes), hasFloatingStrikes_(hasFloatingStrikes), vols_(volHandles.size()),
242 alpha_(
alpha), beta_(
beta),
nu_(
nu), rho_(
rho), gamma_(gamma), isAlphaFixed_(isAlphaFixed),
243 isBetaFixed_(isBetaFixed), isNuFixed_(isNuFixed), isRhoFixed_(isRhoFixed),
244 isGammaFixed_(isGammaFixed), vegaWeighted_(vegaWeighted), endCriteria_(
std::move(endCriteria)),
245 method_(
std::move(method)) {
253template <
typename Evaluation>
255 const Date& optionDate,
257 const std::vector<Rate>& strikes,
258 bool hasFloatingStrikes,
260 const std::vector<Volatility>& volHandles,
272 ext::shared_ptr<EndCriteria> endCriteria,
273 ext::shared_ptr<OptimizationMethod> method,
278 volHandles_(volHandles.size()), strikes_(strikes), actualStrikes_(strikes),
279 hasFloatingStrikes_(hasFloatingStrikes), vols_(volHandles.size()), alpha_(
alpha), beta_(
beta),
280 nu_(
nu), rho_(
rho), gamma_(gamma), isAlphaFixed_(isAlphaFixed), isBetaFixed_(isBetaFixed),
281 isNuFixed_(isNuFixed), isRhoFixed_(isRhoFixed), isGammaFixed_(isGammaFixed),
282 vegaWeighted_(vegaWeighted), endCriteria_(
std::move(endCriteria)), method_(
std::move(method)) {
286 ext::shared_ptr<Quote>(
new SimpleQuote(volHandles[i])));
289template <
typename Evaluation>
291 ext::shared_ptr<ZabrInterpolation<Evaluation> > tmp(
293 actualStrikes_.begin(), actualStrikes_.end(), vols_.begin(),
294 exerciseTime(), forwardValue_, alpha_, beta_,
nu_, rho_, gamma_,
295 isAlphaFixed_, isBetaFixed_, isNuFixed_, isRhoFixed_, isGammaFixed_,
296 vegaWeighted_, endCriteria_, method_));
297 swap(tmp, zabrInterpolation_);
300template <
typename Evaluation>
302 forwardValue_ = forward_->value();
304 actualStrikes_.clear();
306 for (
Size i = 0; i < volHandles_.size(); ++i) {
307 if (volHandles_[i]->isValid()) {
308 if (hasFloatingStrikes_) {
309 actualStrikes_.push_back(forwardValue_ + strikes_[i]);
310 vols_.push_back(atmVolatility_->value() +
311 volHandles_[i]->value());
313 actualStrikes_.push_back(strikes_[i]);
314 vols_.push_back(volHandles_[i]->value());
320 createInterpolation();
321 zabrInterpolation_->update();
324template <
typename Evaluation>
327 Real v = (*zabrInterpolation_)(strike,
true);
328 return v *
v * exerciseTime();
Actual/365 (Fixed) day counter.
Actual/365 (Fixed) day count convention.
Shared handle to an observable.
Framework for calculation on demand and result caching.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
purely virtual base class for market observables
market element returning a stored value
interest rate volatility smile section
Real atmLevel() const override
const Handle< Quote > forward_
Market data.
void performCalculations() const override
const ext::shared_ptr< EndCriteria > endCriteria_
bool isAlphaFixed_
Sabr interpolation settings.
Real minStrike() const override
EndCriteria::Type endCriteria() const
void createInterpolation() const
Creates the mutable SABRInterpolation.
std::vector< Rate > actualStrikes_
Only strikes corresponding to valid market data.
const ext::shared_ptr< OptimizationMethod > method_
ZabrInterpolatedSmileSection(const Date &optionDate, Handle< Quote > forward, const std::vector< Rate > &strikes, bool hasFloatingStrikes, Handle< Quote > atmVolatility, const std::vector< Handle< Quote > > &volHandles, Real alpha, Real beta, Real nu, Real rho, Real gamma, bool isAlphaFixed=false, bool isBetaFixed=false, bool isNuFixed=false, bool isRhoFixed=false, bool isGammaFixed=false, bool vegaWeighted=true, ext::shared_ptr< EndCriteria > endCriteria=ext::shared_ptr< EndCriteria >(), ext::shared_ptr< OptimizationMethod > method=ext::shared_ptr< OptimizationMethod >(), const DayCounter &dc=Actual365Fixed())
all market data are quotes
Real varianceImpl(Rate strike) const override
Real alpha_
Sabr parameters.
ext::shared_ptr< ZabrInterpolation< Evaluation > > zabrInterpolation_
std::vector< Volatility > vols_
std::vector< Rate > strikes_
const Handle< Quote > atmVolatility_
Real maxStrike() const override
std::vector< Handle< Quote > > volHandles_
Volatility volatilityImpl(Rate strike) const override
zabr smile interpolation between discrete volatility points.
Real Volatility
volatility
std::size_t Size
size of a container
Globally accessible relinkable pointer.
framework for calculation on demand and result caching
void swap(Array &v, Array &w) noexcept
ext::shared_ptr< BlackVolTermStructure > v
Smile section base class.
ZABR interpolation interpolation between discrete points.