InterpolatedYoYOptionletVolatilityCurve<Interpolator1D>:: InterpolatedYoYOptionletVolatilityCurve(Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc, const DayCounter& dc, const Period &lag, Frequency frequency, bool indexIsInterpolated, const std::vector<Date> &d, const std::vector<Volatility> &v, Rate minStrike, Rate maxStrike, const Interpolator1D &interpolator) : YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag, frequency, indexIsInterpolated), dates_(d), data_(v), interpolator_(interpolator), minStrike_(minStrike), maxStrike_(maxStrike) { QL_REQUIRE(d.size() == v.size(), "must have same number of dates and vols: " << d.size() << " vs " << v.size()); QL_REQUIRE(d.size() > 1, "must have at least two dates: " << d.size()); for (Size i = 0; i < d.size(); i++ ){ times_.push_back( this->timeFromReference(dates_[i]) ); nodes_.push_back( std::make_pair( dates_[i], data_[i]) ); } interpolation_ = interpolator_.interpolate(times_.begin(), times_.end(), data_.begin() ); // set the base vol level to that predicted by the interpolation // this is allowed by the extrapolation Time baseTime = this->timeFromReference(baseDate()); setBaseLevel(interpolation_(baseTime,true)); }
Real value(Real x) const { return std::exp(interpolation_(x, true)); }
Real InterpolatedSmileSection<Interpolator>::volatilityImpl(Real strike) const { calculate(); return interpolation_(strike, true); }
Real InterpolatedSmileSection<Interpolator>::varianceImpl(Real strike) const { calculate(); Real v = interpolation_(strike, true); return v*v*exerciseTime(); }
Real operator()(Time t) { return interpolation_(t, true); }
inline Volatility InterpolatedYoYOptionletVolatilityCurve<Interpolator1D>:: volatilityImpl(const Time t, Rate) const { return interpolation_(t); }