Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ZeroInflationIndexWrapper Class Reference

Wrapper that changes the interpolation of an underlying ZC inflation index. More...

#include <qle/indexes/inflationindexwrapper.hpp>

+ Inheritance diagram for ZeroInflationIndexWrapper:
+ Collaboration diagram for ZeroInflationIndexWrapper:

Public Member Functions

 ZeroInflationIndexWrapper (const QuantLib::ext::shared_ptr< ZeroInflationIndex > source)
 
QL_DEPRECATED ZeroInflationIndexWrapper (const QuantLib::ext::shared_ptr< ZeroInflationIndex > source, const CPI::InterpolationType interpolation)
 
Rate fixing (const Date &fixingDate, bool forecastTodaysFixing=false) const override
 

Private Member Functions

Rate forecastFixing (const Date &fixingDate) const
 

Private Attributes

const QuantLib::ext::shared_ptr< ZeroInflationIndex > source_
 
QL_DEPRECATED const CPI::InterpolationType interpolation_
 

Detailed Description

Wrapper that changes the interpolation of an underlying ZC inflation index.

The (possible) change in the interpolation is not reflected in the index class itself, only the fixing methods behave consistently

Definition at line 39 of file inflationindexwrapper.hpp.

Constructor & Destructor Documentation

◆ ZeroInflationIndexWrapper() [1/2]

QL_DEPRECATED_DISABLE_WARNING ZeroInflationIndexWrapper ( const QuantLib::ext::shared_ptr< ZeroInflationIndex >  source)

Definition at line 26 of file inflationindexwrapper.cpp.

27 : ZeroInflationIndex(source->familyName(), source->region(), source->revised(), source->frequency(), source->availabilityLag(), source->currency(),
28 source->zeroInflationTermStructure()),
29 source_(source), interpolation_(QuantLib::CPI::InterpolationType::Flat) {}
const QuantLib::ext::shared_ptr< ZeroInflationIndex > source_
QL_DEPRECATED const CPI::InterpolationType interpolation_

◆ ZeroInflationIndexWrapper() [2/2]

ZeroInflationIndexWrapper ( const QuantLib::ext::shared_ptr< ZeroInflationIndex >  source,
const CPI::InterpolationType  interpolation 
)

Definition at line 31 of file inflationindexwrapper.cpp.

33 : ZeroInflationIndex(source->familyName(), source->region(), source->revised(), source->interpolated(),
34 source->frequency(), source->availabilityLag(), source->currency(),
35 source->zeroInflationTermStructure()),
36 source_(source), interpolation_(interpolation) {}

Member Function Documentation

◆ fixing()

QL_DEPRECATED_ENABLE_WARNING Rate fixing ( const Date &  fixingDate,
bool  forecastTodaysFixing = false 
) const
override
Warning:
the forecastTodaysFixing parameter (required by the Index interface) is currently ignored.

Definition at line 39 of file inflationindexwrapper.cpp.

39 {
40
41 // duplicated logic from CPICashFlow::amount()
42
43 // what interpolation do we use? Index / flat / linear
44 QL_DEPRECATED_DISABLE_WARNING
45 if (interpolation_ == CPI::AsIndex) {
46 return source_->fixing(fixingDate);
47 } else {
48 std::pair<Date, Date> dd = inflationPeriod(fixingDate, frequency());
49 Real indexStart = source_->fixing(dd.first);
50 if (interpolation_ == CPI::Linear) {
51 Real indexEnd = source_->fixing(dd.second + Period(1, Days));
52 // linear interpolation
53 return indexStart + (indexEnd - indexStart) * (fixingDate - dd.first) /
54 ((dd.second + Period(1, Days)) -
55 dd.first); // can't get to next period's value within current period
56 } else {
57 // no interpolation, i.e. flat = constant, so use start-of-period value
58 return indexStart;
59 }
60 }
61 QL_DEPRECATED_ENABLE_WARNING
62}

◆ forecastFixing()

Rate forecastFixing ( const Date &  fixingDate) const
private

Member Data Documentation

◆ source_

const QuantLib::ext::shared_ptr<ZeroInflationIndex> source_
private

Definition at line 51 of file inflationindexwrapper.hpp.

◆ interpolation_

QL_DEPRECATED const CPI::InterpolationType interpolation_
private

Definition at line 52 of file inflationindexwrapper.hpp.