22#include <ql/math/interpolations/cubicinterpolation.hpp>
23#include <ql/math/interpolations/linearinterpolation.hpp>
24#include <ql/math/interpolations/sabrinterpolation.hpp>
25#include <ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp>
26#include <ql/termstructures/volatility/interpolatedsmilesection.hpp>
27#include <ql/termstructures/volatility/optionlet/optionletstripper.hpp>
37 const bool flatExtrapolation)
38 : OptionletVolatilityStructure(s->settlementDays(), s->calendar(), s->businessDayConvention(), s->dayCounter()),
39 optionletStripper_(s), nInterpolations_(s->optionletMaturities()), strikeInterpolations_(nInterpolations_),
40 flatExtrapolation_(flatExtrapolation) {
45 std::vector<Rate> optionletStrikes =
47 std::vector<Real> stddevs;
49 for (Size i = 0; i < optionletStrikes.size(); i++) {
50 stddevs.push_back(
volatilityImpl(tEff, optionletStrikes[i]) * std::sqrt(tEff));
55 return QuantLib::ext::make_shared<InterpolatedSmileSection<LinearFlat> >(t, optionletStrikes, stddevs, Null<Real>(),
59 return QuantLib::ext::make_shared<InterpolatedSmileSection<Linear> >(
72 LinearInterpolation timeInterpolator(optionletTimes.begin(), optionletTimes.end(), vol.begin());
76 length =
max(
min(length, optionletTimes.back()), optionletTimes.front());
79 return timeInterpolator(length,
true);
89 const std::vector<Volatility>& optionletVolatilities =
optionletStripper_->optionletVolatilities(i);
107 QuantLib::ext::shared_ptr<Interpolation> tmp = QuantLib::ext::shared_ptr<LinearInterpolation>(
108 new LinearInterpolation(optionletStrikes.begin(), optionletStrikes.end(), optionletVolatilities.begin()));
Linear-interpolation and flat extrapolation factory and traits
QuantLib::Volatility volatilityImpl(QuantLib::Time length, QuantLib::Rate strike) const override
void performCalculations() const override
QuantLib::Rate maxStrike() const override
QuantLib::Rate minStrike() const override
QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl(QuantLib::Time optionTime) const override
QuantLib::VolatilityType volatilityType() const override
QuantLib::Size nInterpolations_
QuantLib::Date maxDate() const override
const QuantLib::ext::shared_ptr< QuantLib::StrippedOptionletBase > optionletStripper_
const bool flatExtrapolation_
QuantLib::Real displacement() const override
std::vector< QuantLib::ext::shared_ptr< QuantLib::Interpolation > > strikeInterpolations_
StrippedOptionletAdapter2(const QuantLib::ext::shared_ptr< QuantLib::StrippedOptionletBase > &, const bool flatExtrapolation=false)
CompiledFormula min(CompiledFormula x, const CompiledFormula &y)
CompiledFormula max(CompiledFormula x, const CompiledFormula &y)
StrippedOptionlet Adapter (with a deeper update method, linear interpolation and optional flat extrap...