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

#include <qle/termstructures/spreadedinflationcurve.hpp>

+ Inheritance diagram for SpreadedZeroInflationCurve:
+ Collaboration diagram for SpreadedZeroInflationCurve:

Public Member Functions

 SpreadedZeroInflationCurve (const Handle< ZeroInflationTermStructure > &referenceCurve, const std::vector< Time > &times, const std::vector< Handle< Quote > > &quotes)
 times should be consistent with reference ts day counter More...
 
Date maxDate () const override
 
void update () override
 
const Date & referenceDate () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
Date baseDate () const override
 

Protected Member Functions

void performCalculations () const override
 
Rate zeroRateImpl (Time t) const override
 

Private Attributes

Handle< ZeroInflationTermStructure > referenceCurve_
 
std::vector< Time > times_
 
std::vector< Handle< Quote > > quotes_
 
std::vector< Real > data_
 
QuantLib::ext::shared_ptr< Interpolation > interpolation_
 

Detailed Description

Definition at line 35 of file spreadedinflationcurve.hpp.

Constructor & Destructor Documentation

◆ SpreadedZeroInflationCurve()

SpreadedZeroInflationCurve ( const Handle< ZeroInflationTermStructure > &  referenceCurve,
const std::vector< Time > &  times,
const std::vector< Handle< Quote > > &  quotes 
)

times should be consistent with reference ts day counter

Definition at line 24 of file spreadedinflationcurve.cpp.

27 : ZeroInflationTermStructure(referenceCurve->dayCounter(), referenceCurve->baseRate(),
28 referenceCurve->observationLag(), referenceCurve->frequency(),
29 referenceCurve->seasonality()),
30 referenceCurve_(referenceCurve), times_(times), quotes_(quotes), data_(times_.size(), 1.0) {
31 QL_REQUIRE(times_.size() > 1, "SpreadedZeroInflationCurve: at least two times required");
32 QL_REQUIRE(times_.size() == quotes.size(),
33 "SpreadedZeroInflationCurve: size of time and quote vectors do not match");
34 for (Size i = 0; i < quotes.size(); ++i) {
35 registerWith(quotes_[i]);
36 }
37 interpolation_ = QuantLib::ext::make_shared<FlatExtrapolation>(
38 QuantLib::ext::make_shared<LinearInterpolation>(times_.begin(), times_.end(), data_.begin()));
39 interpolation_->enableExtrapolation();
40 registerWith(referenceCurve_);
41}
std::vector< Handle< Quote > > quotes_
Handle< ZeroInflationTermStructure > referenceCurve_
QuantLib::ext::shared_ptr< Interpolation > interpolation_

Member Function Documentation

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 45 of file spreadedinflationcurve.cpp.

45{ return referenceCurve_->maxDate(); }

◆ update()

void update ( )
override

Definition at line 47 of file spreadedinflationcurve.cpp.

47 {
48 LazyObject::update();
49 TermStructure::update();
50}

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 52 of file spreadedinflationcurve.cpp.

52{ return referenceCurve_->referenceDate(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 54 of file spreadedinflationcurve.cpp.

54{ return referenceCurve_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 56 of file spreadedinflationcurve.cpp.

56{ return referenceCurve_->settlementDays(); }

◆ baseDate()

Date baseDate ( ) const
override

Definition at line 43 of file spreadedinflationcurve.cpp.

43{ return referenceCurve_->baseDate(); }

◆ performCalculations()

void performCalculations ( ) const
overrideprotected

Definition at line 58 of file spreadedinflationcurve.cpp.

58 {
59 for (Size i = 0; i < times_.size(); ++i) {
60 QL_REQUIRE(!quotes_[i].empty(), "SpreadedZeroInflationCurve: quote at index " << i << " is empty");
61 data_[i] = quotes_[i]->value();
62 }
63 interpolation_->update();
64}

◆ zeroRateImpl()

Real zeroRateImpl ( Time  t) const
overrideprotected

Definition at line 66 of file spreadedinflationcurve.cpp.

66 {
67 calculate();
68 return referenceCurve_->zeroRate(t) + (*interpolation_)(t);
69}

Member Data Documentation

◆ referenceCurve_

Handle<ZeroInflationTermStructure> referenceCurve_
private

Definition at line 55 of file spreadedinflationcurve.hpp.

◆ times_

std::vector<Time> times_
private

Definition at line 56 of file spreadedinflationcurve.hpp.

◆ quotes_

std::vector<Handle<Quote> > quotes_
private

Definition at line 57 of file spreadedinflationcurve.hpp.

◆ data_

std::vector<Real> data_
mutableprivate

Definition at line 58 of file spreadedinflationcurve.hpp.

◆ interpolation_

QuantLib::ext::shared_ptr<Interpolation> interpolation_
private

Definition at line 59 of file spreadedinflationcurve.hpp.