From a9ef7ba2258cc7fb780d941ce7e55307b6176ffc Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 28 Jan 2025 12:43:14 +0100 Subject: [PATCH 1/4] Deprecate passing interpolation flag to YoY indexes --- ql/experimental/inflation/genericindexes.hpp | 21 ++++++++++ .../interpolatedyoyoptionletstripper.hpp | 2 +- ql/indexes/inflation/aucpi.hpp | 19 ++++++++++ ql/indexes/inflation/euhicp.hpp | 34 +++++++++++++++++ ql/indexes/inflation/frhicp.hpp | 17 +++++++++ ql/indexes/inflation/ukrpi.hpp | 17 +++++++++ ql/indexes/inflation/uscpi.hpp | 17 +++++++++ ql/indexes/inflation/zacpi.hpp | 18 +++++++++ ql/indexes/inflationindex.cpp | 37 ++++++++++++++---- ql/indexes/inflationindex.hpp | 22 ++++++++++- test-suite/inflation.cpp | 38 +++++++++++++------ test-suite/inflationcapfloor.cpp | 3 +- test-suite/inflationcapflooredcoupon.cpp | 3 +- test-suite/inflationvolatility.cpp | 8 +++- 14 files changed, 228 insertions(+), 28 deletions(-) diff --git a/ql/experimental/inflation/genericindexes.hpp b/ql/experimental/inflation/genericindexes.hpp index 41311c727fb..0cd238ad1ef 100644 --- a/ql/experimental/inflation/genericindexes.hpp +++ b/ql/experimental/inflation/genericindexes.hpp @@ -56,6 +56,25 @@ namespace QuantLib { //! Quoted year-on-year Generic CPI (i.e. not a ratio) class YYGenericCPI : public YoYInflationIndex { public: + YYGenericCPI(Frequency frequency, + bool revised, + const Period &lag, + const Currency &ccy, + const Handle& ts = {}) + : YoYInflationIndex("YY_CPI", + GenericRegion(), + revised, + frequency, + lag, + ccy, + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] YYGenericCPI(Frequency frequency, bool revised, bool interpolated, @@ -70,6 +89,8 @@ namespace QuantLib { lag, ccy, ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/experimental/inflation/interpolatedyoyoptionletstripper.hpp b/ql/experimental/inflation/interpolatedyoyoptionletstripper.hpp index 3c6047432fb..7687e6d61da 100644 --- a/ql/experimental/inflation/interpolatedyoyoptionletstripper.hpp +++ b/ql/experimental/inflation/interpolatedyoyoptionletstripper.hpp @@ -184,7 +184,7 @@ namespace QuantLib { RelinkableHandle hYoY( YoYCapFloorTermPriceSurface_->YoYTS()); ext::shared_ptr anIndex( - new YYGenericCPI(frequency_, false, + new YYGenericCPI(frequency_, false, lag_, Currency(), hYoY)); diff --git a/ql/indexes/inflation/aucpi.hpp b/ql/indexes/inflation/aucpi.hpp index 9cff08c7c75..f39eaff3f56 100644 --- a/ql/indexes/inflation/aucpi.hpp +++ b/ql/indexes/inflation/aucpi.hpp @@ -44,6 +44,23 @@ namespace QuantLib { //! Quoted year-on-year AU CPI (i.e. not a ratio) class YYAUCPI : public YoYInflationIndex { public: + YYAUCPI(Frequency frequency, + bool revised, + const Handle& ts = {}) + : YoYInflationIndex("YY_CPI", + AustraliaRegion(), + revised, + frequency, + Period(2, Months), + AUDCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] YYAUCPI(Frequency frequency, bool revised, bool interpolated, @@ -56,6 +73,8 @@ namespace QuantLib { Period(2, Months), AUDCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflation/euhicp.hpp b/ql/indexes/inflation/euhicp.hpp index 41f2f890d02..fb33c96389d 100644 --- a/ql/indexes/inflation/euhicp.hpp +++ b/ql/indexes/inflation/euhicp.hpp @@ -61,6 +61,21 @@ namespace QuantLib { //! Quoted year-on-year EU HICP (i.e. not a ratio of EU HICP) class YYEUHICP : public YoYInflationIndex { public: + explicit YYEUHICP(const Handle& ts = {}) + : YoYInflationIndex("YY_HICP", + EURegion(), + false, + Monthly, + Period(1, Months), + EURCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYEUHICP( bool interpolated, const Handle& ts = {}) @@ -72,11 +87,28 @@ namespace QuantLib { Period(1, Months), EURCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; //! Quoted year-on-year EU HICPXT class YYEUHICPXT : public YoYInflationIndex { public: + explicit YYEUHICPXT(const Handle& ts = {}) + : YoYInflationIndex("YY_HICPXT", + EURegion(), + false, + Monthly, + Period(1, Months), + EURCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYEUHICPXT( bool interpolated, const Handle& ts = {}) @@ -88,6 +120,8 @@ namespace QuantLib { Period(1, Months), EURCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflation/frhicp.hpp b/ql/indexes/inflation/frhicp.hpp index a459ed27ca2..af59489a59c 100644 --- a/ql/indexes/inflation/frhicp.hpp +++ b/ql/indexes/inflation/frhicp.hpp @@ -42,6 +42,21 @@ namespace QuantLib { //! Quoted year-on-year FR HICP (i.e. not a ratio) class YYFRHICP : public YoYInflationIndex { public: + explicit YYFRHICP(const Handle& ts = {}) + : YoYInflationIndex("YY_HICP", + FranceRegion(), + false, + Monthly, + Period(1, Months), + EURCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYFRHICP( bool interpolated, const Handle& ts = {}) @@ -53,6 +68,8 @@ namespace QuantLib { Period(1, Months), EURCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflation/ukrpi.hpp b/ql/indexes/inflation/ukrpi.hpp index e24b12e6952..405774e9756 100644 --- a/ql/indexes/inflation/ukrpi.hpp +++ b/ql/indexes/inflation/ukrpi.hpp @@ -42,6 +42,21 @@ namespace QuantLib { //! Quoted year-on-year UK RPI (i.e. not a ratio of UK RPI) class YYUKRPI : public YoYInflationIndex { public: + explicit YYUKRPI(const Handle& ts = {}) + : YoYInflationIndex("YY_RPI", + UKRegion(), + false, + Monthly, + Period(1, Months), + GBPCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYUKRPI( bool interpolated, const Handle& ts = {}) @@ -53,6 +68,8 @@ namespace QuantLib { Period(1, Months), GBPCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflation/uscpi.hpp b/ql/indexes/inflation/uscpi.hpp index d8ffa1243f7..c3f78475739 100644 --- a/ql/indexes/inflation/uscpi.hpp +++ b/ql/indexes/inflation/uscpi.hpp @@ -47,6 +47,21 @@ namespace QuantLib { //! Quoted year-on-year US CPI (i.e. not a ratio of US CPI) class YYUSCPI : public YoYInflationIndex { public: + explicit YYUSCPI(const Handle& ts = {}) + : YoYInflationIndex("YY_CPI", + USRegion(), + false, + Monthly, + Period(1, Months), + USDCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYUSCPI( bool interpolated, const Handle& ts = {}) @@ -58,6 +73,8 @@ namespace QuantLib { Period(1, Months), USDCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflation/zacpi.hpp b/ql/indexes/inflation/zacpi.hpp index c5b966a5d20..34318c396d2 100644 --- a/ql/indexes/inflation/zacpi.hpp +++ b/ql/indexes/inflation/zacpi.hpp @@ -42,6 +42,22 @@ namespace QuantLib { //! Quoted year-on-year South African CPI (i.e. not a ratio of ZA CPI) class YYZACPI : public YoYInflationIndex { public: + explicit YYZACPI( + const Handle& ts = {}) + : YoYInflationIndex("YY_CPI", + ZARegion(), + false, + Monthly, + Period(1, Months), + ZARCurrency(), + ts) {} + + QL_DEPRECATED_DISABLE_WARNING + + /*! \deprecated Use the overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the overload without the interpolated parameter")]] explicit YYZACPI( bool interpolated, const Handle& ts = {}) @@ -53,6 +69,8 @@ namespace QuantLib { Period(1, Months), ZARCurrency(), ts) {} + + QL_DEPRECATED_ENABLE_WARNING }; } diff --git a/ql/indexes/inflationindex.cpp b/ql/indexes/inflationindex.cpp index 5cb89e02067..cac3b8c2ab9 100644 --- a/ql/indexes/inflationindex.cpp +++ b/ql/indexes/inflationindex.cpp @@ -241,30 +241,47 @@ namespace QuantLib { YoYInflationIndex::YoYInflationIndex(const ext::shared_ptr& underlyingIndex, - bool interpolated, Handle yoyInflation) : InflationIndex("YYR_" + underlyingIndex->familyName(), underlyingIndex->region(), underlyingIndex->revised(), underlyingIndex->frequency(), underlyingIndex->availabilityLag(), underlyingIndex->currency()), - interpolated_(interpolated), ratio_(true), underlyingIndex_(underlyingIndex), + interpolated_(false), ratio_(true), underlyingIndex_(underlyingIndex), yoyInflation_(std::move(yoyInflation)) { registerWith(underlyingIndex_); registerWith(yoyInflation_); } + YoYInflationIndex::YoYInflationIndex(const ext::shared_ptr& underlyingIndex, + bool interpolated, + Handle yoyInflation) + : YoYInflationIndex(underlyingIndex, yoyInflation) { + interpolated_ = interpolated; + } + YoYInflationIndex::YoYInflationIndex(const std::string& familyName, const Region& region, bool revised, - bool interpolated, Frequency frequency, const Period& availabilityLag, const Currency& currency, Handle yoyInflation) : InflationIndex(familyName, region, revised, frequency, availabilityLag, currency), - interpolated_(interpolated), ratio_(false), yoyInflation_(std::move(yoyInflation)) { + interpolated_(false), ratio_(false), yoyInflation_(std::move(yoyInflation)) { registerWith(yoyInflation_); } + YoYInflationIndex::YoYInflationIndex(const std::string& familyName, + const Region& region, + bool revised, + bool interpolated, + Frequency frequency, + const Period& availabilityLag, + const Currency& currency, + Handle yoyInflation) + : YoYInflationIndex(familyName, region, revised, frequency, availabilityLag, currency, yoyInflation) { + interpolated_ = interpolated; + } + Rate YoYInflationIndex::fixing(const Date& fixingDate, bool /*forecastTodaysFixing*/) const { @@ -369,13 +386,17 @@ namespace QuantLib { ext::shared_ptr YoYInflationIndex::clone( const Handle& h) const { + QL_DEPRECATED_DISABLE_WARNING if (ratio_) { - return ext::make_shared(underlyingIndex_, interpolated_, h); + return ext::shared_ptr( + new YoYInflationIndex(underlyingIndex_, interpolated_, h)); } else { - return ext::make_shared(familyName_, region_, revised_, - interpolated_, frequency_, - availabilityLag_, currency_, h); + return ext::shared_ptr( + new YoYInflationIndex(familyName_, region_, revised_, + interpolated_, frequency_, + availabilityLag_, currency_, h)); } + QL_DEPRECATED_ENABLE_WARNING } diff --git a/ql/indexes/inflationindex.hpp b/ql/indexes/inflationindex.hpp index aa938966aaa..829c0108bd4 100644 --- a/ql/indexes/inflationindex.hpp +++ b/ql/indexes/inflationindex.hpp @@ -195,6 +195,14 @@ namespace QuantLib { past fixings of its own; they will be calculated as a ratio from the past fixings stored in the underlying index. */ + YoYInflationIndex( + const ext::shared_ptr& underlyingIndex, + Handle ts = {}); + + /*! \deprecated Use the similar overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the similar overload without the interpolated parameter")]] YoYInflationIndex( const ext::shared_ptr& underlyingIndex, bool interpolated, @@ -209,12 +217,24 @@ namespace QuantLib { const std::string& familyName, const Region& region, bool revised, - bool interpolated, Frequency frequency, const Period& availabilityLag, const Currency& currency, Handle ts = {}); + /*! \deprecated Use the similar overload without the interpolated parameter. + Deprecated in version 1.38. + */ + [[deprecated("Use the similar overload without the interpolated parameter")]] + YoYInflationIndex( + const std::string& familyName, + const Region& region, + bool revised, + bool interpolated, + Frequency frequency, + const Period& availabilityLag, + const Currency& currency, + Handle ts = {}); //@} //! \name Index interface diff --git a/test-suite/inflation.cpp b/test-suite/inflation.cpp index 65372c74fb1..46884f29e79 100644 --- a/test-suite/inflation.cpp +++ b/test-suite/inflation.cpp @@ -819,6 +819,8 @@ BOOST_AUTO_TEST_CASE(testInterpolatedZeroTermStructure) { BOOST_AUTO_TEST_CASE(testQuotedYYIndex) { BOOST_TEST_MESSAGE("Testing quoted year-on-year inflation indices..."); + QL_DEPRECATED_DISABLE_WARNING + YYEUHICP yyeuhicp(true); if (yyeuhicp.name() != "EU YY_HICP" || yyeuhicp.frequency() != Monthly @@ -835,7 +837,9 @@ BOOST_AUTO_TEST_CASE(testQuotedYYIndex) { << yyeuhicp.availabilityLag() << ")"); } - YYUKRPI yyukrpi(false); + QL_DEPRECATED_ENABLE_WARNING + + YYUKRPI yyukrpi; if (yyukrpi.name() != "UK YY_RPI" || yyukrpi.frequency() != Monthly || yyukrpi.revised() @@ -857,8 +861,11 @@ BOOST_AUTO_TEST_CASE(testQuotedYYIndexFutureFixing) { // we create indexes without a term structure, so // they won't be able to forecast fixings - YYEUHICP quoted_flat(false); + YYEUHICP quoted_flat; + + QL_DEPRECATED_DISABLE_WARNING YYEUHICP quoted_linear(true); + QL_DEPRECATED_ENABLE_WARNING // let's say we're at some point in April 2024... Settings::instance().evaluationDate() = {10, April, 2024}; @@ -907,7 +914,9 @@ BOOST_AUTO_TEST_CASE(testRatioYYIndex) { auto euhicp = ext::make_shared(); auto ukrpi = ext::make_shared(); + QL_DEPRECATED_DISABLE_WARNING YoYInflationIndex yyeuhicpr(euhicp, true); + QL_DEPRECATED_ENABLE_WARNING if (yyeuhicpr.name() != "EU YYR_HICP" || yyeuhicpr.frequency() != Monthly || yyeuhicpr.revised() @@ -923,7 +932,7 @@ BOOST_AUTO_TEST_CASE(testRatioYYIndex) { << yyeuhicpr.availabilityLag() << ")"); } - YoYInflationIndex yyukrpir(ukrpi, false); + YoYInflationIndex yyukrpir(ukrpi); if (yyukrpir.name() != "UK YYR_RPI" || yyukrpir.frequency() != Monthly || yyukrpir.revised() @@ -966,8 +975,11 @@ BOOST_AUTO_TEST_CASE(testRatioYYIndex) { ukrpi->addFixing(rpiSchedule[i], fixData[i]); } - auto iir = ext::make_shared(ukrpi, false); - auto iirYES = ext::make_shared(ukrpi, true); + auto iir = ext::make_shared(ukrpi); + QL_DEPRECATED_DISABLE_WARNING + auto iirYES = ext::shared_ptr( + new YoYInflationIndex(ukrpi, true)); + QL_DEPRECATED_ENABLE_WARNING Date todayMinusLag = evaluationDate - iir->availabilityLag(); std::pair lim = inflationPeriod(todayMinusLag, iir->frequency()); @@ -1025,8 +1037,10 @@ BOOST_AUTO_TEST_CASE(testRatioYYIndexFutureFixing) { // we create indexes without a term structure, so // they won't be able to forecast fixings auto euhicp = ext::make_shared(); - YoYInflationIndex ratio_flat(euhicp, false); + YoYInflationIndex ratio_flat(euhicp); + QL_DEPRECATED_DISABLE_WARNING YoYInflationIndex ratio_linear(euhicp, true); + QL_DEPRECATED_ENABLE_WARNING // let's say we're at some point in April 2024... Settings::instance().evaluationDate() = {10, April, 2024}; @@ -1101,9 +1115,8 @@ BOOST_AUTO_TEST_CASE(testYYTermStructure) { }; RelinkableHandle hy; - bool interp = false; auto rpi = ext::make_shared(); - auto iir = ext::make_shared(rpi, interp, hy); + auto iir = ext::make_shared(rpi, hy); for (Size i=0; iaddFixing(rpiSchedule[i], fixData[i]); } @@ -1257,9 +1270,8 @@ BOOST_AUTO_TEST_CASE(testYYTermStructureWithLag) { 207.3 }; RelinkableHandle hy; - bool interp = false; auto rpi = ext::make_shared(); - auto iir = ext::make_shared(rpi, interp, hy); + auto iir = ext::make_shared(rpi, hy); for (Size i=0; iaddFixing(rpiSchedule[i], fixData[i]); } @@ -1568,8 +1580,10 @@ BOOST_AUTO_TEST_CASE(testCpiYoYQuotedFlatInterpolation) { Settings::instance().evaluationDate() = Date(10, February, 2022); - auto testIndex1 = ext::make_shared(false); - auto testIndex2 = ext::make_shared(true); + auto testIndex1 = ext::make_shared(); + QL_DEPRECATED_DISABLE_WARNING + auto testIndex2 = ext::shared_ptr(new YYUKRPI(true)); + QL_DEPRECATED_ENABLE_WARNING testIndex1->addFixing(Date(1, November, 2020), 0.02935); testIndex1->addFixing(Date(1, December, 2020), 0.02954); diff --git a/test-suite/inflationcapfloor.cpp b/test-suite/inflationcapfloor.cpp index c980a031517..eebe6bf5573 100644 --- a/test-suite/inflationcapfloor.cpp +++ b/test-suite/inflationcapfloor.cpp @@ -140,8 +140,7 @@ struct CommonVars { rpi->addFixing(rpiSchedule[i], fixData[i]); } // link from yoy index to yoy TS - bool interp = false; - iir = ext::make_shared(rpi, interp, hy); + iir = ext::make_shared(rpi, hy); ext::shared_ptr nominalFF( new FlatForward(evaluationDate, 0.05, ActualActual(ActualActual::ISDA))); diff --git a/test-suite/inflationcapflooredcoupon.cpp b/test-suite/inflationcapflooredcoupon.cpp index 3728b3e8bd3..b54a5449b8b 100644 --- a/test-suite/inflationcapflooredcoupon.cpp +++ b/test-suite/inflationcapflooredcoupon.cpp @@ -148,8 +148,7 @@ struct CommonVars { rpi->addFixing(rpiSchedule[i], fixData[i]); } // link from yoy index to yoy TS - bool interp = false; - iir = ext::make_shared(rpi, interp, hy); + iir = ext::make_shared(rpi, hy); ext::shared_ptr nominalFF( new FlatForward(evaluationDate, 0.05, ActualActual(ActualActual::ISDA))); diff --git a/test-suite/inflationvolatility.cpp b/test-suite/inflationvolatility.cpp index 5e9daa5f612..83be069dc1e 100644 --- a/test-suite/inflationvolatility.cpp +++ b/test-suite/inflationvolatility.cpp @@ -94,8 +94,12 @@ void setup() { Date eval = Date(Day(23), Month(11), Year(2007)); Settings::instance().evaluationDate() = eval; - yoyIndexUK = ext::make_shared(ext::make_shared(), true, yoyUK); - yoyIndexEU = ext::make_shared(ext::make_shared(), true, yoyEU); + QL_DEPRECATED_DISABLE_WARNING + yoyIndexUK = ext::shared_ptr( + new YoYInflationIndex(ext::make_shared(), true, yoyUK)); + yoyIndexEU = ext::shared_ptr( + new YoYInflationIndex(ext::make_shared(), true, yoyEU)); + QL_DEPRECATED_ENABLE_WARNING // nominal yield curve (interpolated; times assume year parts have 365 days) Real timesEUR[] = {0.0109589, 0.0684932, 0.263014, 0.317808, 0.567123, 0.816438, From d8bd0886c6af0fed5de8fec3552415564fa087cc Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 28 Jan 2025 13:22:19 +0100 Subject: [PATCH 2/4] Avoid deprecation warnings --- test-suite/inflation.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test-suite/inflation.cpp b/test-suite/inflation.cpp index 46884f29e79..28d6e84108d 100644 --- a/test-suite/inflation.cpp +++ b/test-suite/inflation.cpp @@ -1616,8 +1616,10 @@ BOOST_AUTO_TEST_CASE(testCpiYoYQuotedLinearInterpolation) { Settings::instance().evaluationDate() = Date(10, February, 2022); - auto testIndex1 = ext::make_shared(false); - auto testIndex2 = ext::make_shared(true); + auto testIndex1 = ext::make_shared(); + QL_DEPRECATED_DISABLE_WARNING + auto testIndex2 = ext::shared_ptr(new YYUKRPI(true)); + QL_DEPRECATED_ENABLE_WARNING testIndex1->addFixing(Date(1, November, 2020), 0.02935); testIndex1->addFixing(Date(1, December, 2020), 0.02954); @@ -1671,8 +1673,11 @@ BOOST_AUTO_TEST_CASE(testCpiYoYRatioFlatInterpolation) { auto underlying = ext::make_shared(); - auto testIndex1 = ext::make_shared(underlying, false); - auto testIndex2 = ext::make_shared(underlying, true); + auto testIndex1 = ext::make_shared(underlying); + QL_DEPRECATED_DISABLE_WARNING + auto testIndex2 = ext::shared_ptr( + new YoYInflationIndex(underlying, true)); + QL_DEPRECATED_ENABLE_WARNING underlying->addFixing(Date(1, November, 2019), 291.0); underlying->addFixing(Date(1, December, 2019), 291.9); @@ -1713,8 +1718,11 @@ BOOST_AUTO_TEST_CASE(testCpiYoYRatioLinearInterpolation) { auto underlying = ext::make_shared(); - auto testIndex1 = ext::make_shared(underlying, false); - auto testIndex2 = ext::make_shared(underlying, true); + auto testIndex1 = ext::make_shared(underlying); + QL_DEPRECATED_DISABLE_WARNING + auto testIndex2 = ext::shared_ptr( + new YoYInflationIndex(underlying, true)); + QL_DEPRECATED_ENABLE_WARNING underlying->addFixing(Date(1, November, 2019), 291.0); underlying->addFixing(Date(1, December, 2019), 291.9); From e8e615985be338ea333e9550fe93faad72a7033b Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 28 Jan 2025 15:24:11 +0100 Subject: [PATCH 3/4] Use non-interpolated index in test --- test-suite/inflationvolatility.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/test-suite/inflationvolatility.cpp b/test-suite/inflationvolatility.cpp index 83be069dc1e..74fd8ad53d7 100644 --- a/test-suite/inflationvolatility.cpp +++ b/test-suite/inflationvolatility.cpp @@ -94,12 +94,8 @@ void setup() { Date eval = Date(Day(23), Month(11), Year(2007)); Settings::instance().evaluationDate() = eval; - QL_DEPRECATED_DISABLE_WARNING - yoyIndexUK = ext::shared_ptr( - new YoYInflationIndex(ext::make_shared(), true, yoyUK)); - yoyIndexEU = ext::shared_ptr( - new YoYInflationIndex(ext::make_shared(), true, yoyEU)); - QL_DEPRECATED_ENABLE_WARNING + yoyIndexUK = ext::make_shared(ext::make_shared(), yoyUK); + yoyIndexEU = ext::make_shared(ext::make_shared(), yoyEU); // nominal yield curve (interpolated; times assume year parts have 365 days) Real timesEUR[] = {0.0109589, 0.0684932, 0.263014, 0.317808, 0.567123, 0.816438, @@ -322,14 +318,14 @@ BOOST_AUTO_TEST_CASE(testYoYPriceSurfaceToVol) { // now use it for something ... like stating what the T=const lines look like const Real volATyear1[] = { - 0.0128, 0.0093, 0.0083, 0.0073, 0.0064, + 0.0129, 0.0094, 0.0083, 0.0073, 0.0064, 0.0058, 0.0042, 0.0046, 0.0053, 0.0064, 0.0098 }; const Real volATyear3[] = { - 0.0079, 0.0058, 0.0051, 0.0045, 0.0039, - 0.0035, 0.0026, 0.0028, 0.0033, 0.0039, - 0.0060 + 0.0080, 0.0058, 0.0051, 0.0045, 0.0040, + 0.0035, 0.0026, 0.0028, 0.0033, 0.0040, + 0.0061 }; Date d = yoySurf->baseDate() + Period(1,Years); From 165405cc8053b57c441463f65e49fc878177b697 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 28 Jan 2025 17:41:56 +0100 Subject: [PATCH 4/4] Make constructor explicit --- ql/indexes/inflationindex.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/indexes/inflationindex.hpp b/ql/indexes/inflationindex.hpp index 829c0108bd4..d2195f4b9cc 100644 --- a/ql/indexes/inflationindex.hpp +++ b/ql/indexes/inflationindex.hpp @@ -195,7 +195,7 @@ namespace QuantLib { past fixings of its own; they will be calculated as a ratio from the past fixings stored in the underlying index. */ - YoYInflationIndex( + explicit YoYInflationIndex( const ext::shared_ptr& underlyingIndex, Handle ts = {});