From 16495ab73718aff583e5eb456179617f3e465adc Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 23 Sep 2024 14:44:56 +0200 Subject: [PATCH] Deprecate indexIsInterpolated parameter in YoY curves --- .../inflation/yoycapfloortermpricesurface.hpp | 5 +- .../inflation/inflationtraits.hpp | 2 + .../interpolatedyoyinflationcurve.hpp | 80 ++++++++++++++++--- .../inflation/piecewiseyoyinflationcurve.hpp | 32 ++++++-- ql/termstructures/inflationtermstructure.cpp | 57 ++++++++++--- ql/termstructures/inflationtermstructure.hpp | 66 ++++++++++++--- test-suite/inflation.cpp | 3 +- test-suite/inflationcapfloor.cpp | 3 +- test-suite/inflationcapflooredcoupon.cpp | 3 +- test-suite/inflationvolatility.cpp | 19 +++-- 10 files changed, 211 insertions(+), 59 deletions(-) diff --git a/ql/experimental/inflation/yoycapfloortermpricesurface.hpp b/ql/experimental/inflation/yoycapfloortermpricesurface.hpp index 92aa0a5f66c..820bde7df8d 100644 --- a/ql/experimental/inflation/yoycapfloortermpricesurface.hpp +++ b/ql/experimental/inflation/yoycapfloortermpricesurface.hpp @@ -606,8 +606,6 @@ namespace QuantLib { } Date baseDate = - yoyIndex()->interpolated() ? - nominalTS_->referenceDate() - observationLag() : inflationPeriod(nominalTS_->referenceDate() - observationLag(), yoyIndex()->frequency()).first; // usually this base rate is known @@ -619,8 +617,7 @@ namespace QuantLib { auto pYITS = ext::make_shared>( nominalTS_->referenceDate(), baseDate, baseYoYRate, - yoyIndex()->frequency(), yoyIndex()->interpolated(), - dayCounter(), YYhelpers); + yoyIndex()->frequency(), dayCounter(), YYhelpers); pYITS->recalculate(); yoy_ = pYITS; // store diff --git a/ql/termstructures/inflation/inflationtraits.hpp b/ql/termstructures/inflation/inflationtraits.hpp index 52b89e767f8..1c972e3de6b 100644 --- a/ql/termstructures/inflation/inflationtraits.hpp +++ b/ql/termstructures/inflation/inflationtraits.hpp @@ -117,6 +117,7 @@ namespace QuantLib { // start of curve data static Date initialDate(const YoYInflationTermStructure* t) { + QL_DEPRECATED_DISABLE_WARNING if (t->hasExplicitBaseDate()) { return t->baseDate(); } else if (t->indexIsInterpolated()) { @@ -125,6 +126,7 @@ namespace QuantLib { return inflationPeriod(t->referenceDate() - t->observationLag(), t->frequency()).first; } + QL_DEPRECATED_ENABLE_WARNING } // value at reference date diff --git a/ql/termstructures/inflation/interpolatedyoyinflationcurve.hpp b/ql/termstructures/inflation/interpolatedyoyinflationcurve.hpp index 1d97ace3b8e..8cb04c33587 100644 --- a/ql/termstructures/inflation/interpolatedyoyinflationcurve.hpp +++ b/ql/termstructures/inflation/interpolatedyoyinflationcurve.hpp @@ -44,6 +44,18 @@ namespace QuantLib { : public YoYInflationTermStructure, protected InterpolatedCurve { public: + InterpolatedYoYInflationCurve(const Date& referenceDate, + std::vector dates, + const std::vector& rates, + Frequency frequency, + const DayCounter& dayCounter, + const ext::shared_ptr& seasonality = {}, + const Interpolator& interpolator = Interpolator()); + + /*! \deprecated Use the overload without indexIsInterpolated. + Deprecated in version 1.37. + */ + [[deprecated("Use the overload without indexIsInterpolated")]] InterpolatedYoYInflationCurve(const Date& referenceDate, std::vector dates, const std::vector& rates, @@ -53,11 +65,11 @@ namespace QuantLib { const ext::shared_ptr& seasonality = {}, const Interpolator& interpolator = Interpolator()); - /*! \deprecated Use the other overload and pass the base date directly - as the first date in the vector instead of using a lag. + /*! \deprecated Use the overload without lag and indexIsInterpolated and + pass the base date as the first date in the vector. Deprecated in version 1.34. */ - QL_DEPRECATED + [[deprecated("Use the overload without lag and indexIsInterpolated and pass the base date as the first date in the vector")]] InterpolatedYoYInflationCurve(const Date& referenceDate, const Calendar& calendar, const DayCounter& dayCounter, @@ -94,6 +106,18 @@ namespace QuantLib { (or can't) provide the points for interpolation on construction. */ + InterpolatedYoYInflationCurve(const Date& referenceDate, + Date baseDate, + Rate baseYoYRate, + Frequency frequency, + const DayCounter& dayCounter, + const ext::shared_ptr& seasonality = {}, + const Interpolator& interpolator = Interpolator()); + + /*! \deprecated Use the overload without indexIsInterpolated. + Deprecated in version 1.37. + */ + [[deprecated("Use the overload without indexIsInterpolated")]] InterpolatedYoYInflationCurve(const Date& referenceDate, Date baseDate, Rate baseYoYRate, @@ -103,11 +127,11 @@ namespace QuantLib { const ext::shared_ptr& seasonality = {}, const Interpolator& interpolator = Interpolator()); - /*! \deprecated Use the other overload and pass the base date directly - instead of using a lag. + /*! \deprecated Use the overload without lag and indexIsInterpolated and + pass the base date as the first date in the vector. Deprecated in version 1.34. */ - QL_DEPRECATED + [[deprecated("Use the overload without lag and indexIsInterpolated and pass the base date as the first date in the vector")]] InterpolatedYoYInflationCurve(const Date& referenceDate, const Calendar& calendar, const DayCounter& dayCounter, @@ -130,12 +154,11 @@ namespace QuantLib { std::vector dates, const std::vector& rates, Frequency frequency, - bool indexIsInterpolated, const DayCounter& dayCounter, const ext::shared_ptr& seasonality, const Interpolator& interpolator) - : YoYInflationTermStructure(referenceDate, dates.at(0), rates[0], frequency, - indexIsInterpolated, dayCounter, seasonality), + : YoYInflationTermStructure(referenceDate, dates.at(0), rates[0], + frequency, dayCounter, seasonality), InterpolatedCurve(std::vector