41#include <ql/experimental/inflation/yoyoptionletstripper.hpp>
59 template<
class Interpolator1D>
66 const Natural settlementDays,
68 const BusinessDayConvention bdc,
71 const ext::shared_ptr<YoYCapFloorTermPriceSurface>& capFloorPrices,
72 const ext::shared_ptr<QuantLib::YoYInflationCapFloorEngine>& pricer,
73 const ext::shared_ptr<YoYOptionletStripper>& yoyOptionletStripper,
75 const Interpolator1D& interpolator = Interpolator1D(),
76 VolatilityType volType = ShiftedLognormal,
77 Real displacement = 0.0);
81 virtual Date
maxDate()
const override;
82 std::pair<std::vector<Rate>, std::vector<Volatility> >
Dslice(
89 Rate strike)
const override;
101 mutable std::pair<std::vector<Rate>, std::vector<Volatility> >
slice_;
109 template<
class Interpolator1D>
112 const Natural settlementDays,
114 const BusinessDayConvention bdc,
115 const DayCounter& dc,
117 const ext::shared_ptr<YoYCapFloorTermPriceSurface> &capFloorPrices,
118 const ext::shared_ptr<QuantLib::YoYInflationCapFloorEngine> &pricer,
119 const ext::shared_ptr<YoYOptionletStripper> &yoyOptionletStripper,
121 const Interpolator1D &interpolator,
122 VolatilityType volType,
125 capFloorPrices->yoyIndex()->frequency(),
126 capFloorPrices->yoyIndex()->interpolated(),
127 volType, displacement),
128 capFloorPrices_(capFloorPrices), yoyInflationCouponPricer_(pricer),
129 yoyOptionletStripper_(yoyOptionletStripper),
130 factory1D_(interpolator), slope_(slope), lastDateisSet_(false) {
135 template<
class Interpolator1D>
138 Size n = capFloorPrices_->maturities().size();
139 return referenceDate()+capFloorPrices_->maturities()[n-1];
143 template<
class Interpolator1D>
146 return capFloorPrices_->strikes().front();
150 template<
class Interpolator1D>
153 return capFloorPrices_->strikes().back();
157 template<
class Interpolator1D>
162 yoyOptionletStripper_->initialize(capFloorPrices_,
163 yoyInflationCouponPricer_,
168 template<
class Interpolator1D>
174 if (this->allowsExtrapolation()) {
175 this->tempKinterpolation_.enableExtrapolation();
177 return tempKinterpolation_(strike);
181 template<
class Interpolator1D>
182 std::pair<std::vector<Rate>, std::vector<Volatility> >
184 Dslice(
const Date &d)
const {
190 template<
class Interpolator1D>
194 Natural years = (Natural)floor(length);
195 Natural days = (Natural)floor((length - years) * 365.0);
196 Date d = referenceDate() + Period(years, Years) + Period(days, Days);
198 return this->volatilityImpl(d, strike);
201 template<
class Interpolator1D>
205 if (!lastDateisSet_ || d != lastDate_ ) {
208 Date d_eff = d + capFloorPrices_->observationLag();
211 if (this->allowsExtrapolation())
212 d_eff = std::min(d_eff, maxDate());
213 slice_ = yoyOptionletStripper_->slice(d_eff);
215 tempKinterpolation_ =
216 factory1D_.interpolate( slice_.first.begin(),
218 slice_.second.begin() );
219 lastDateisSet_ =
true;
K-interpolated YoY optionlet volatility.
virtual Volatility volatilityImpl(const Date &d, Rate strike) const
virtual void performCalculations() const
void updateSlice(const Date &d) const
virtual Real minStrike() const override
ext::shared_ptr< QuantLib::YoYInflationCapFloorEngine > yoyInflationCouponPricer_
ext::shared_ptr< YoYOptionletStripper > yoyOptionletStripper_
Interpolation tempKinterpolation_
KInterpolatedYoYOptionletVolatilitySurface(const Natural settlementDays, const Calendar &, const BusinessDayConvention bdc, const DayCounter &dc, const Period &lag, const ext::shared_ptr< YoYCapFloorTermPriceSurface > &capFloorPrices, const ext::shared_ptr< QuantLib::YoYInflationCapFloorEngine > &pricer, const ext::shared_ptr< YoYOptionletStripper > &yoyOptionletStripper, const Real slope, const Interpolator1D &interpolator=Interpolator1D(), VolatilityType volType=ShiftedLognormal, Real displacement=0.0)
virtual Date maxDate() const override
std::pair< std::vector< Rate >, std::vector< Volatility > > slice_
ext::shared_ptr< YoYCapFloorTermPriceSurface > capFloorPrices_
Interpolator1D factory1D_
std::pair< std::vector< Rate >, std::vector< Volatility > > Dslice(const Date &d) const
virtual Real maxStrike() const override