Skip to content

Commit

Permalink
Deprecate passing interpolation flag to YoY indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Sep 20, 2024
1 parent 8cf8518 commit 0c04b23
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 11 deletions.
21 changes: 21 additions & 0 deletions ql/experimental/inflation/genericindexes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
YYGenericCPI(Frequency frequency,
bool revised,
bool interpolated,
Expand All @@ -70,6 +89,8 @@ namespace QuantLib {
lag,
ccy,
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ namespace QuantLib {
RelinkableHandle<YoYInflationTermStructure> hYoY(
YoYCapFloorTermPriceSurface_->YoYTS());
ext::shared_ptr<YoYInflationIndex> anIndex(
new YYGenericCPI(frequency_, false,
new YYGenericCPI(frequency_,
false, lag_,
Currency(), hYoY));

Expand Down
19 changes: 19 additions & 0 deletions ql/indexes/inflation/aucpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
YYAUCPI(Frequency frequency,
bool revised,
bool interpolated,
Expand All @@ -56,6 +73,8 @@ namespace QuantLib {
Period(2, Months),
AUDCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
34 changes: 34 additions & 0 deletions ql/indexes/inflation/euhicp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYEUHICP(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYEUHICPXT(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -88,6 +120,8 @@ namespace QuantLib {
Period(1, Months),
EURCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
17 changes: 17 additions & 0 deletions ql/indexes/inflation/frhicp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYFRHICP(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -53,6 +68,8 @@ namespace QuantLib {
Period(1, Months),
EURCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
17 changes: 17 additions & 0 deletions ql/indexes/inflation/ukrpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYUKRPI(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -53,6 +68,8 @@ namespace QuantLib {
Period(1, Months),
GBPCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
17 changes: 17 additions & 0 deletions ql/indexes/inflation/uscpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYUSCPI(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -58,6 +73,8 @@ namespace QuantLib {
Period(1, Months),
USDCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
18 changes: 18 additions & 0 deletions ql/indexes/inflation/zacpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<YoYInflationTermStructure>& 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.36.
*/
[[deprecated("Use the overload without the interpolated parameter")]]
explicit YYZACPI(
bool interpolated,
const Handle<YoYInflationTermStructure>& ts = {})
Expand All @@ -53,6 +69,8 @@ namespace QuantLib {
Period(1, Months),
ZARCurrency(),
ts) {}

QL_DEPRECATED_ENABLE_WARNING
};

}
Expand Down
27 changes: 23 additions & 4 deletions ql/indexes/inflationindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,30 +241,47 @@ namespace QuantLib {


YoYInflationIndex::YoYInflationIndex(const ext::shared_ptr<ZeroInflationIndex>& underlyingIndex,
bool interpolated,
Handle<YoYInflationTermStructure> 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<ZeroInflationIndex>& underlyingIndex,
bool interpolated,
Handle<YoYInflationTermStructure> 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<YoYInflationTermStructure> 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<YoYInflationTermStructure> yoyInflation)
: YoYInflationIndex(familyName, region, revised, frequency, availabilityLag, currency, yoyInflation) {
interpolated_ = interpolated;
}


Rate YoYInflationIndex::fixing(const Date& fixingDate,
bool /*forecastTodaysFixing*/) const {
Expand Down Expand Up @@ -358,13 +375,15 @@ namespace QuantLib {

ext::shared_ptr<YoYInflationIndex> YoYInflationIndex::clone(
const Handle<YoYInflationTermStructure>& h) const {
QL_DEPRECATED_DISABLE_WARNING
if (ratio_) {
return ext::make_shared<YoYInflationIndex>(underlyingIndex_, interpolated_, h);
} else {
return ext::make_shared<YoYInflationIndex>(familyName_, region_, revised_,
interpolated_, frequency_,
availabilityLag_, currency_, h);
}
QL_DEPRECATED_ENABLE_WARNING
}


Expand Down
22 changes: 21 additions & 1 deletion ql/indexes/inflationindex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ZeroInflationIndex>& underlyingIndex,
Handle<YoYInflationTermStructure> ts = {});

/*! \deprecated Use the similar overload without the interpolated parameter.
Deprecated in version 1.36.
*/
[[deprecated("Use the similar overload without the interpolated parameter")]]
YoYInflationIndex(
const ext::shared_ptr<ZeroInflationIndex>& underlyingIndex,
bool interpolated,
Expand All @@ -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<YoYInflationTermStructure> ts = {});

/*! \deprecated Use the similar overload without the interpolated parameter.
Deprecated in version 1.36.
*/
[[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<YoYInflationTermStructure> ts = {});
//@}

//! \name Index interface
Expand Down
Loading

0 comments on commit 0c04b23

Please sign in to comment.