Skip to content

Commit bd930f3

Browse files
committed
yoy ratio index use same name as underlying cpi index
the ratio index doesnt need own fixings, the historical fixings are computed from underlying cpi index
1 parent 705225d commit bd930f3

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

ql/indexes/inflationindex.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ namespace QuantLib {
330330
YoYInflationIndex::YoYInflationIndex(const ext::shared_ptr<ZeroInflationIndex>& underlyingIndex,
331331
bool interpolated,
332332
Handle<YoYInflationTermStructure> yoyInflation)
333-
: InflationIndex("YYR_" + underlyingIndex->familyName(), underlyingIndex->region(),
333+
: InflationIndex(underlyingIndex->familyName(), underlyingIndex->region(),
334334
underlyingIndex->revised(), underlyingIndex->frequency(),
335335
underlyingIndex->availabilityLag(), underlyingIndex->currency()),
336336
interpolated_(interpolated), ratio_(true), underlyingIndex_(underlyingIndex),
@@ -433,10 +433,13 @@ namespace QuantLib {
433433

434434
ext::shared_ptr<YoYInflationIndex> YoYInflationIndex::clone(
435435
const Handle<YoYInflationTermStructure>& h) const {
436-
return ext::make_shared<YoYInflationIndex>(
437-
familyName_, region_, revised_,
438-
interpolated_, ratio_, frequency_,
439-
availabilityLag_, currency_, h);
436+
if (ratio_) {
437+
return ext::make_shared<YoYInflationIndex>(underlyingIndex_, interpolated_, h);
438+
} else {
439+
return ext::make_shared<YoYInflationIndex>(familyName_, region_, revised_,
440+
interpolated_, frequency_,
441+
availabilityLag_, currency_, h);
442+
}
440443
}
441444

442445

ql/indexes/inflationindex.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ namespace QuantLib {
263263
year-on-year values; if `ratio` is true, they must be the
264264
past fixings of the underlying index.
265265
266-
Deprecated in QL version 1.31 but needed in ORE
266+
\deprecated Use one of the other constructors instead.
267+
Deprecated in version 1.31.
267268
*/
269+
QL_DEPRECATED
268270
YoYInflationIndex(
269271
const std::string& familyName,
270272
const Region& region,

test-suite/inflation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void InflationTest::testRatioYYIndex() {
792792
auto ukrpi = ext::make_shared<UKRPI>();
793793

794794
YoYInflationIndex yyeuhicpr(euhicp, true);
795-
if (yyeuhicpr.name() != "EU YYR_HICP"
795+
if (yyeuhicpr.name() != "EU HICP"
796796
|| yyeuhicpr.frequency() != Monthly
797797
|| yyeuhicpr.revised()
798798
|| !yyeuhicpr.interpolated()
@@ -808,7 +808,7 @@ void InflationTest::testRatioYYIndex() {
808808
}
809809

810810
YoYInflationIndex yyukrpir(ukrpi, false);
811-
if (yyukrpir.name() != "UK YYR_RPI"
811+
if (yyukrpir.name() != "UK RPI"
812812
|| yyukrpir.frequency() != Monthly
813813
|| yyukrpir.revised()
814814
|| yyukrpir.interpolated()

0 commit comments

Comments
 (0)