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 &i) : YoYOptionletVolatilitySurface(settlementDays, cal, bdc, dc, lag, frequency, indexIsInterpolated), InterpolatedCurve<Interpolator1D>(i), dates_(d), 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++ ){ this->times_.push_back( this->timeFromReference(dates_[i]) ); this->data_.push_back(v[i]), nodes_.push_back( std::make_pair( dates_[i], this->data_[i]) ); } this->setupInterpolation(); // set the base vol level to that predicted by the interpolation // this is allowed by the extrapolation Time baseTime = this->timeFromReference(baseDate()); setBaseLevel(this->interpolation_(baseTime,true)); }
void InflationTermStructure::checkRange(Time t, bool extrapolate) const { QL_REQUIRE(t >= timeFromReference(baseDate()), "time (" << t << ") is before base date"); QL_REQUIRE(extrapolate || allowsExtrapolation() || t <= maxTime(), "time (" << t << ") is past max curve time (" << maxTime() << ")"); }
void InflationTermStructure::checkRange(const Date& d, bool extrapolate) const { QL_REQUIRE(d >= baseDate(), "date (" << d << ") is before base date"); QL_REQUIRE(extrapolate || allowsExtrapolation() || d <= maxDate(), "date (" << d << ") is past max curve date (" << maxDate() << ")"); }
void YoYOptionletVolatilitySurface::checkRange(Time t, Rate strike, bool extrapolate) const { QL_REQUIRE(t >= timeFromReference(baseDate()), "time (" << t << ") is before base date"); QL_REQUIRE(extrapolate || allowsExtrapolation() || t <= maxTime(), "time (" << t << ") is past max curve time (" << maxTime() << ")"); QL_REQUIRE(extrapolate || allowsExtrapolation() || (strike >= minStrike() && strike <= maxStrike()), "strike (" << strike << ") is outside the curve domain [" << minStrike() << "," << maxStrike()<< "] at time = " << t); }
void YoYOptionletVolatilitySurface::checkRange(const Date& d, Rate strike, bool extrapolate) const { QL_REQUIRE(d >= baseDate(), "date (" << d << ") is before base date"); QL_REQUIRE(extrapolate || allowsExtrapolation() || d <= maxDate(), "date (" << d << ") is past max curve date (" << maxDate() << ")"); QL_REQUIRE(extrapolate || allowsExtrapolation() || (strike >= minStrike() && strike <= maxStrike()), "strike (" << strike << ") is outside the curve domain [" << minStrike() << "," << maxStrike()<< "]] at date = " << d); }
//! needed for total variance calculations Time YoYOptionletVolatilitySurface::timeFromBase(const Date &maturityDate, const Period& obsLag) const { Period useLag = obsLag; if (obsLag==Period(-1,Days)) { useLag = observationLag(); } Date useDate; if (indexIsInterpolated()) { useDate = maturityDate - useLag; } else { useDate = inflationPeriod(maturityDate - useLag, frequency()).first; } // This assumes that the inflation term structure starts // as late as possible given the inflation index definition, // which is the usual case. return dayCounter().yearFraction(baseDate(), useDate); }