Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
InterpolatedPriceCurve< Interpolator > Class Template Reference

Interpolated price curve. More...

#include <qle/termstructures/pricecurve.hpp>

+ Inheritance diagram for InterpolatedPriceCurve< Interpolator >:
+ Collaboration diagram for InterpolatedPriceCurve< Interpolator >:

Public Member Functions

Constructors
 InterpolatedPriceCurve (const std::vector< QuantLib::Period > &tenors, const std::vector< QuantLib::Real > &prices, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Curve constructed from periods and prices. No conventions are applied in getting to a date from a period. More...
 
 InterpolatedPriceCurve (const std::vector< QuantLib::Period > &tenors, const std::vector< QuantLib::Handle< QuantLib::Quote > > &quotes, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Curve constructed from periods and quotes. No conventions are applied in getting to a date from a period. More...
 
 InterpolatedPriceCurve (const QuantLib::Date &referenceDate, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &prices, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Curve constructed from dates and prices. More...
 
 InterpolatedPriceCurve (const QuantLib::Date &referenceDate, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Handle< QuantLib::Quote > > &quotes, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Curve constructed from dates and quotes. More...
 
Observer interface
void update () override
 
TermStructure interface
QuantLib::Date maxDate () const override
 
QuantLib::Time maxTime () const override
 
PriceTermStructure interface
QuantLib::Time minTime () const override
 The minimum time for which the curve can return values. More...
 
std::vector< QuantLib::Date > pillarDates () const override
 The pillar dates for the PriceTermStructure. More...
 
const QuantLib::Currency & currency () const override
 The currency in which prices are expressed. More...
 
- Public Member Functions inherited from PriceTermStructure
 PriceTermStructure (const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 PriceTermStructure (const QuantLib::Date &referenceDate, const QuantLib::Calendar &cal=QuantLib::Calendar(), const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
 PriceTermStructure (QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, const QuantLib::DayCounter &dc=QuantLib::DayCounter())
 
QuantLib::Real price (QuantLib::Time t, bool extrapolate=false) const
 
QuantLib::Real price (const QuantLib::Date &d, bool extrapolate=false) const
 
void update () override
 

Protected Member Functions

LazyObject interface
void performCalculations () const override
 
- Protected Member Functions inherited from PriceTermStructure
void checkRange (QuantLib::Time t, bool extrapolate) const
 Extra time range check for minimum time, then calls TermStructure::checkRange. More...
 

PriceTermStructure implementation

std::vector< QuantLib::Date > dates_
 
const QuantLib::Currency currency_
 
std::vector< QuantLib::Handle< QuantLib::Quote > > quotes_
 
std::vector< QuantLib::Period > tenors_
 
QuantLib::Real priceImpl (QuantLib::Time t) const override
 Price calculation. More...
 
void initialise ()
 
void populateDatesFromTenors () const
 
void convertDatesToTimes ()
 
void getPricesFromQuotes () const
 

Inspectors

const std::vector< QuantLib::Time > & times () const
 
const std::vector< QuantLib::Real > & prices () const
 
 InterpolatedPriceCurve (const QuantLib::Date &referenceDate, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Used by PiecewisePriceCurve. More...
 

Detailed Description

template<class Interpolator>
class QuantExt::InterpolatedPriceCurve< Interpolator >

Interpolated price curve.

Class representing a curve of projected prices in the future.

Warning:
for consistency, if curve is constructed by inferring times from dates using a given day counter, pass the same day counter to the constructor

Definition at line 48 of file pricecurve.hpp.

Constructor & Destructor Documentation

◆ InterpolatedPriceCurve() [1/5]

InterpolatedPriceCurve ( const std::vector< QuantLib::Period > &  tenors,
const std::vector< QuantLib::Real > &  prices,
const QuantLib::DayCounter &  dc,
const QuantLib::Currency &  currency,
const Interpolator &  interpolator = Interpolator() 
)

Curve constructed from periods and prices. No conventions are applied in getting to a date from a period.

Definition at line 131 of file pricecurve.hpp.

136 : PriceTermStructure(0, QuantLib::NullCalendar(), dc), QuantLib::InterpolatedCurve<Interpolator>(
137 std::vector<QuantLib::Time>(tenors.size()), prices,
138 interpolator),
139 dates_(tenors.size()), currency_(currency), tenors_(tenors) {
140
141 QL_REQUIRE(boost::algorithm::is_sorted(tenors_.begin(), tenors_.end()), "Tenors must be sorted");
143 initialise();
144}
const QuantLib::Currency currency_
Definition: pricecurve.hpp:120
const QuantLib::Currency & currency() const override
The currency in which prices are expressed.
Definition: pricecurve.hpp:92
std::vector< QuantLib::Date > dates_
Definition: pricecurve.hpp:117
std::vector< QuantLib::Period > tenors_
Definition: pricecurve.hpp:122
const std::vector< QuantLib::Real > & prices() const
Definition: pricecurve.hpp:98
PriceTermStructure(const QuantLib::DayCounter &dc=QuantLib::DayCounter())
+ Here is the call graph for this function:

◆ InterpolatedPriceCurve() [2/5]

InterpolatedPriceCurve ( const std::vector< QuantLib::Period > &  tenors,
const std::vector< QuantLib::Handle< QuantLib::Quote > > &  quotes,
const QuantLib::DayCounter &  dc,
const QuantLib::Currency &  currency,
const Interpolator &  interpolator = Interpolator() 
)

Curve constructed from periods and quotes. No conventions are applied in getting to a date from a period.

Definition at line 147 of file pricecurve.hpp.

150 : PriceTermStructure(0, QuantLib::NullCalendar(), dc), QuantLib::InterpolatedCurve<Interpolator>(
151 std::vector<QuantLib::Time>(tenors.size()),
152 std::vector<QuantLib::Real>(quotes.size()),
153 interpolator),
154 dates_(tenors.size()), currency_(currency), quotes_(quotes), tenors_(tenors) {
155
156 QL_REQUIRE(boost::algorithm::is_sorted(tenors_.begin(), tenors_.end()), "Tenors must be sorted");
158 initialise();
159
160 // Observe the quotes
161 for (QuantLib::Size i = 0; i < quotes_.size(); ++i) {
162 registerWith(quotes[i]);
163 }
164}
std::vector< QuantLib::Handle< QuantLib::Quote > > quotes_
Definition: pricecurve.hpp:121
+ Here is the call graph for this function:

◆ InterpolatedPriceCurve() [3/5]

InterpolatedPriceCurve ( const QuantLib::Date &  referenceDate,
const std::vector< QuantLib::Date > &  dates,
const std::vector< QuantLib::Real > &  prices,
const QuantLib::DayCounter &  dc,
const QuantLib::Currency &  currency,
const Interpolator &  interpolator = Interpolator() 
)

Curve constructed from dates and prices.

Definition at line 167 of file pricecurve.hpp.

173 : PriceTermStructure(referenceDate, QuantLib::NullCalendar(), dc), QuantLib::InterpolatedCurve<Interpolator>(
174 std::vector<QuantLib::Time>(dates.size()),
175 prices, interpolator),
176 dates_(dates), currency_(currency) {
177
179 initialise();
180}
+ Here is the call graph for this function:

◆ InterpolatedPriceCurve() [4/5]

InterpolatedPriceCurve ( const QuantLib::Date &  referenceDate,
const std::vector< QuantLib::Date > &  dates,
const std::vector< QuantLib::Handle< QuantLib::Quote > > &  quotes,
const QuantLib::DayCounter &  dc,
const QuantLib::Currency &  currency,
const Interpolator &  interpolator = Interpolator() 
)

Curve constructed from dates and quotes.

Definition at line 183 of file pricecurve.hpp.

187 : PriceTermStructure(referenceDate, QuantLib::NullCalendar(), dc), QuantLib::InterpolatedCurve<Interpolator>(
188 std::vector<QuantLib::Time>(dates.size()),
189 std::vector<QuantLib::Real>(quotes.size()),
190 interpolator),
191 dates_(dates), currency_(currency), quotes_(quotes) {
192
194 initialise();
195
196 // Observe the quotes
197 for (QuantLib::Size i = 0; i < quotes_.size(); ++i) {
198 registerWith(quotes[i]);
199 }
200}
+ Here is the call graph for this function:

◆ InterpolatedPriceCurve() [5/5]

InterpolatedPriceCurve ( const QuantLib::Date &  referenceDate,
const QuantLib::DayCounter &  dc,
const QuantLib::Currency &  currency,
const Interpolator &  interpolator = Interpolator() 
)
protected

Used by PiecewisePriceCurve.

Definition at line 203 of file pricecurve.hpp.

206 : PriceTermStructure(referenceDate, QuantLib::NullCalendar(), dc),
207 QuantLib::InterpolatedCurve<Interpolator>(interpolator), currency_(currency) {}

Member Function Documentation

◆ update()

void update
override

Definition at line 209 of file pricecurve.hpp.

209 {
210
211 QuantLib::LazyObject::update();
212
213 // TermStructure::update() update part
214 if (moving_) {
215 updated_ = false;
216 }
217}

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 233 of file pricecurve.hpp.

233 {
234 calculate();
235 return dates_.back();
236}

◆ maxTime()

QuantLib::Time maxTime
override

Definition at line 238 of file pricecurve.hpp.

238 {
239 calculate();
240 return this->times_.back();
241}

◆ minTime()

QuantLib::Time minTime
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from PriceTermStructure.

Definition at line 243 of file pricecurve.hpp.

243 {
244 calculate();
245 return this->times_.front();
246}

◆ pillarDates()

std::vector< QuantLib::Date > pillarDates ( ) const
overridevirtual

The pillar dates for the PriceTermStructure.

Implements PriceTermStructure.

Definition at line 248 of file pricecurve.hpp.

248 {
249 calculate();
250 return dates_;
251}

◆ currency()

const QuantLib::Currency & currency ( ) const
overridevirtual

The currency in which prices are expressed.

Implements PriceTermStructure.

Definition at line 92 of file pricecurve.hpp.

92{ return currency_; }

◆ times()

const std::vector< QuantLib::Time > & times ( ) const

Definition at line 97 of file pricecurve.hpp.

97{ return this->times_; }

◆ prices()

const std::vector< QuantLib::Real > & prices ( ) const

Definition at line 98 of file pricecurve.hpp.

98{ return this->data_; }

◆ performCalculations()

void performCalculations
overrideprotected

Definition at line 219 of file pricecurve.hpp.

219 {
220 // Calculations need to be performed if the curve is tenor based
221 if (!tenors_.empty()) {
223 this->interpolation_.update();
224 }
225
226 // Calculations need to be performed if the curve depends on quotes
227 if (!quotes_.empty()) {
229 this->interpolation_.update();
230 }
231}

◆ priceImpl()

QuantLib::Real priceImpl ( QuantLib::Time  ) const
overrideprotectedvirtual

Price calculation.

Implements PriceTermStructure.

Definition at line 253 of file pricecurve.hpp.

253 {
254 // Return interpolated/extrapolated price
255 calculate();
256 return this->interpolation_(t, true);
257}

◆ initialise()

void initialise
private

Definition at line 259 of file pricecurve.hpp.

259 {
260
261 QL_REQUIRE(this->data_.size() >= Interpolator::requiredPoints, "not enough times for the interpolation method");
262
263 // If we are quotes based, get prices from quotes
264 if (!quotes_.empty()) {
266 }
267
268 QL_REQUIRE(this->data_.size() == this->times_.size(), "Number of times must equal number of prices");
269
270 QuantLib::InterpolatedCurve<Interpolator>::setupInterpolation();
271 this->interpolation_.update();
272}
+ Here is the caller graph for this function:

◆ populateDatesFromTenors()

void populateDatesFromTenors
private

Definition at line 274 of file pricecurve.hpp.

274 {
275 QuantLib::Date asof = QuantLib::Settings::instance().evaluationDate();
276 for (QuantLib::Size i = 0; i < dates_.size(); ++i) {
277 dates_[i] = asof + tenors_[i];
278 this->times_[i] = timeFromReference(dates_[i]);
279 }
280}
+ Here is the caller graph for this function:

◆ convertDatesToTimes()

void convertDatesToTimes
private

Definition at line 282 of file pricecurve.hpp.

282 {
283
284 QL_REQUIRE(!dates_.empty(), "Dates cannot be empty for InterpolatedPriceCurve");
285 this->times_[0] = timeFromReference(dates_[0]);
286 for (QuantLib::Size i = 1; i < dates_.size(); ++i) {
287 QL_REQUIRE(dates_[i] > dates_[i - 1], "invalid date (" << dates_[i] << ", vs " << dates_[i - 1] << ")");
288 this->times_[i] = timeFromReference(dates_[i]);
289 QL_REQUIRE(!QuantLib::close(this->times_[i], this->times_[i - 1]), "two dates correspond to the same time "
290 "under this curve's day count convention");
291 }
292}
+ Here is the caller graph for this function:

◆ getPricesFromQuotes()

void getPricesFromQuotes
private

Definition at line 294 of file pricecurve.hpp.

294 {
295
296 for (QuantLib::Size i = 0; i < quotes_.size(); ++i) {
297 QL_REQUIRE(!this->quotes_[i].empty(), "price quote at index " << i << " is empty");
298 this->data_[i] = quotes_[i]->value();
299 }
300}

Member Data Documentation

◆ dates_

std::vector<QuantLib::Date> dates_
mutableprotected

Definition at line 117 of file pricecurve.hpp.

◆ currency_

const QuantLib::Currency currency_
private

Definition at line 120 of file pricecurve.hpp.

◆ quotes_

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

Definition at line 121 of file pricecurve.hpp.

◆ tenors_

std::vector<QuantLib::Period> tenors_
private

Definition at line 122 of file pricecurve.hpp.