Skip to content

Commit

Permalink
Merge pull request #1149.
Browse files Browse the repository at this point in the history
Deprecate nominal term structure contained in inflation curves
  • Loading branch information
lballabio committed Jul 16, 2021
2 parents 29e05f3 + 5ae8b94 commit 470a070
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ql/cashflows/cpicouponpricer.cpp
Expand Up @@ -122,12 +122,15 @@ namespace QuantLib {
gearing_ = coupon_->fixedRate();
spread_ = coupon_->spread();
paymentDate_ = coupon_->date();

QL_DEPRECATED_DISABLE_WARNING
rateCurve_ =
!nominalTermStructure_.empty() ?
nominalTermStructure_ :
ext::dynamic_pointer_cast<ZeroInflationIndex>(coupon.index())
->zeroInflationTermStructure()
->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING

// past or future fixing is managed in YoYInflationIndex::fixing()
// use yield curve from index (which sets discount)
Expand Down
3 changes: 3 additions & 0 deletions ql/cashflows/inflationcouponpricer.cpp
Expand Up @@ -138,12 +138,15 @@ namespace QuantLib {
gearing_ = coupon_->gearing();
spread_ = coupon_->spread();
paymentDate_ = coupon_->date();

QL_DEPRECATED_DISABLE_WARNING
rateCurve_ =
!nominalTermStructure_.empty() ?
nominalTermStructure_ :
ext::dynamic_pointer_cast<YoYInflationIndex>(coupon.index())
->yoyInflationTermStructure()
->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING

// past or future fixing is managed in YoYInflationIndex::fixing()
// use yield curve from index (which sets discount)
Expand Down
2 changes: 2 additions & 0 deletions ql/instruments/makeyoyinflationcapfloor.cpp
Expand Up @@ -83,7 +83,9 @@ namespace QuantLib {
QL_REQUIRE(!index_->yoyInflationTermStructure().empty(),
"no forecasting yoy term structure set for " <<
index_->name());
QL_DEPRECATED_DISABLE_WARNING
fc = index_->yoyInflationTermStructure()->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING
}
strikeVector[0] = CashFlows::atmRate(leg,**fc,
false, fc->referenceDate());
Expand Down
4 changes: 4 additions & 0 deletions ql/pricingengines/inflation/inflationcapfloorengines.cpp
Expand Up @@ -61,10 +61,14 @@ namespace QuantLib {

Handle<YoYInflationTermStructure> yoyTS
= index()->yoyInflationTermStructure();

QL_DEPRECATED_DISABLE_WARNING
Handle<YieldTermStructure> nominalTS =
!nominalTermStructure_.empty() ?
nominalTermStructure_ :
yoyTS->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING

Date settlement = nominalTS->referenceDate();

for (Size i=0; i<optionlets; ++i) {
Expand Down
5 changes: 5 additions & 0 deletions ql/termstructures/inflation/inflationhelpers.cpp
Expand Up @@ -116,8 +116,10 @@ namespace QuantLib {

ext::shared_ptr<ZeroInflationIndex> new_zii = zii_->clone(zits);

QL_DEPRECATED_DISABLE_WARNING
Handle<YieldTermStructure> nominalTS =
!nominalTermStructure_.empty() ? nominalTermStructure_ : z->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING

Real nominal = 1000000.0; // has to be something but doesn't matter what
Date start = nominalTS->referenceDate();
Expand Down Expand Up @@ -223,8 +225,11 @@ namespace QuantLib {

// The instrument takes a standard discounting swap engine.
// The inflation-related work is done by the coupons.
QL_DEPRECATED_DISABLE_WARNING
Handle<YieldTermStructure> nominalTS =
!nominalTermStructure_.empty() ? nominalTermStructure_ : y->nominalTermStructure();
QL_DEPRECATED_ENABLE_WARNING

yyiis_->setPricingEngine(
ext::shared_ptr<PricingEngine>(new DiscountingSwapEngine(nominalTS)));
}
Expand Down
3 changes: 3 additions & 0 deletions ql/termstructures/inflationtermstructure.cpp
Expand Up @@ -23,6 +23,8 @@

namespace QuantLib {

QL_DEPRECATED_DISABLE_WARNING

InflationTermStructure::InflationTermStructure(
Rate baseRate,
const Period& observationLag,
Expand Down Expand Up @@ -68,6 +70,7 @@ namespace QuantLib {
setSeasonality(seasonality);
}

QL_DEPRECATED_ENABLE_WARNING

void InflationTermStructure::setSeasonality(
const ext::shared_ptr<Seasonality>& seasonality) {
Expand Down
23 changes: 22 additions & 1 deletion ql/termstructures/inflationtermstructure.hpp
Expand Up @@ -30,6 +30,8 @@
namespace QuantLib {
class InflationIndex;

QL_DEPRECATED_DISABLE_WARNING

//! Interface for inflation term structures.
/*! \ingroup inflationtermstructures */
class InflationTermStructure : public TermStructure {
Expand Down Expand Up @@ -69,7 +71,6 @@ namespace QuantLib {
virtual Frequency frequency() const;
virtual bool indexIsInterpolated() const;
virtual Rate baseRate() const;
virtual Handle<YieldTermStructure> nominalTermStructure() const;

//! minimum (base) date
/*! Important in inflation since it starts before nominal
Expand All @@ -84,6 +85,14 @@ namespace QuantLib {
virtual Date baseDate() const = 0;
//@}

/*! \deprecated Don't use this method. Objects such as pricers
or bootstrap helpers that need a nominal curve
should be passed one explicitly.
Deprecated in version 1.24.
*/
QL_DEPRECATED
virtual Handle<YieldTermStructure> nominalTermStructure() const;

//! Functions to set and get seasonality.
/*! Calling setSeasonality with no arguments means unsetting
as the default is used to choose unsetting.
Expand Down Expand Up @@ -114,9 +123,19 @@ namespace QuantLib {
Frequency frequency_;
bool indexIsInterpolated_;
mutable Rate baseRate_;
/*! \deprecated Don't use this data member. If you're
inheriting from InflationTermStructure, don't
have your class take a nominal curve. Objects
such as pricers or bootstrap helpers that need
a nominal curve should be passed one
explicitly.
Deprecated in version 1.24.
*/
QL_DEPRECATED
Handle<YieldTermStructure> nominalTermStructure_;
};

QL_DEPRECATED_ENABLE_WARNING

//! Interface for zero inflation term structures.
// Child classes use templates but do not want that exposed to
Expand Down Expand Up @@ -271,10 +290,12 @@ namespace QuantLib {
return baseRate_;
}

QL_DEPRECATED_DISABLE_WARNING
inline Handle<YieldTermStructure>
InflationTermStructure::nominalTermStructure() const {
return nominalTermStructure_;
}
QL_DEPRECATED_ENABLE_WARNING

inline ext::shared_ptr<Seasonality> InflationTermStructure::seasonality() const {
return seasonality_;
Expand Down

0 comments on commit 470a070

Please sign in to comment.