Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Private Types | List of all members
PiecewisePriceCurve< Interpolator, Bootstrap > Class Template Reference

Piecewise price term structure. More...

#include <qle/termstructures/piecewisepricecurve.hpp>

+ Inheritance diagram for PiecewisePriceCurve< Interpolator, Bootstrap >:
+ Collaboration diagram for PiecewisePriceCurve< Interpolator, Bootstrap >:

Public Types

typedef PiecewisePriceCurve< Interpolator, Bootstrap > this_curve
 
typedef QuantLib::BootstrapHelper< PriceTermStructurehelper
 
typedef PriceTraits traits_type
 
typedef Interpolator interpolator_type
 

Public Member Functions

Constructors
 PiecewisePriceCurve (const QuantLib::Date &referenceDate, const std::vector< QuantLib::ext::shared_ptr< helper > > &instruments, const QuantLib::DayCounter &dayCounter, const QuantLib::Currency &currency, const Interpolator &i=Interpolator(), const Bootstrap< this_curve > &bootstrap=Bootstrap< this_curve >())
 
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...
 
InterpolatedPriceCurve interface
const std::vector< QuantLib::Time > & times () const
 
const std::vector< QuantLib::Real > & prices () const
 
const QuantLib::ext::shared_ptr< helper > & instrument (QuantLib::Size i) const
 Return the i-th instrument. More...
 
- Public Member Functions inherited from InterpolatedPriceCurve< Interpolator >
 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...
 
void update () override
 
QuantLib::Date maxDate () const override
 
QuantLib::Time maxTime () const override
 
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...
 
const std::vector< QuantLib::Time > & times () const
 
const std::vector< QuantLib::Real > & prices () const
 
- 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
 

Private Types

typedef InterpolatedPriceCurve< Interpolator > base_curve
 

Private Member Functions

LazyObject interface
void performCalculations () const override
 

PriceTermStructure implementation

std::vector< QuantLib::ext::shared_ptr< helper > > instruments_
 
Real accuracy_
 
Bootstrap< this_curvebootstrap_
 
class Bootstrap< this_curve >
 
class BootstrapError< this_curve >
 
class PenaltyFunction< this_curve >
 
QuantLib::Real priceImpl (QuantLib::Time t) const override
 Price calculation. More...
 

Additional Inherited Members

- Protected Member Functions inherited from InterpolatedPriceCurve< Interpolator >
void performCalculations () const override
 
QuantLib::Real priceImpl (QuantLib::Time t) const override
 Price calculation. More...
 
 InterpolatedPriceCurve (const QuantLib::Date &referenceDate, const QuantLib::DayCounter &dc, const QuantLib::Currency &currency, const Interpolator &interpolator=Interpolator())
 Used by PiecewisePriceCurve. More...
 
- 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...
 
- Protected Attributes inherited from InterpolatedPriceCurve< Interpolator >
std::vector< QuantLib::Date > dates_
 

Detailed Description

template<class Interpolator, template< class > class Bootstrap = IterativeBootstrap>
class QuantExt::PiecewisePriceCurve< Interpolator, Bootstrap >

Piecewise price term structure.

This term structure is bootstrapped on a number of instruments which are passed as a vector of handles to PriceHelper instances. Their maturities mark the boundaries of the interpolated segments.

Each segment is determined sequentially starting from the earliest period to the latest and is chosen so that the instrument whose maturity marks the end of such segment is correctly repriced on the curve.

Warning:
The bootstrapping algorithm raises an exception if any two instruments have the same maturity date.

Definition at line 99 of file piecewisepricecurve.hpp.

Member Typedef Documentation

◆ base_curve

typedef InterpolatedPriceCurve<Interpolator> base_curve
private

Definition at line 102 of file piecewisepricecurve.hpp.

◆ this_curve

typedef PiecewisePriceCurve<Interpolator, Bootstrap> this_curve

Definition at line 105 of file piecewisepricecurve.hpp.

◆ helper

typedef QuantLib::BootstrapHelper<PriceTermStructure> helper

Definition at line 106 of file piecewisepricecurve.hpp.

◆ traits_type

Definition at line 107 of file piecewisepricecurve.hpp.

◆ interpolator_type

typedef Interpolator interpolator_type

Definition at line 108 of file piecewisepricecurve.hpp.

Constructor & Destructor Documentation

◆ PiecewisePriceCurve()

PiecewisePriceCurve ( const QuantLib::Date &  referenceDate,
const std::vector< QuantLib::ext::shared_ptr< helper > > &  instruments,
const QuantLib::DayCounter &  dayCounter,
const QuantLib::Currency &  currency,
const Interpolator &  i = Interpolator(),
const Bootstrap< this_curve > &  bootstrap = Bootstrap<this_curve>() 
)

Definition at line 162 of file piecewisepricecurve.hpp.

169 : base_curve(referenceDate, dayCounter, currency, i), instruments_(instruments),
170 accuracy_(1e-12), bootstrap_(bootstrap) {
171
172 // Ensure that the instruments are sorted and that they are all alive i.e. pillar > reference date.
173 // Need this because of the way that we have set up PriceTraits.
174 std::sort(instruments_.begin(), instruments_.end(), QuantLib::detail::BootstrapHelperSorter());
175
176 auto it = std::find_if(instruments_.begin(), instruments_.end(),
177 [&referenceDate](const QuantLib::ext::shared_ptr<helper>& inst) { return inst->pillarDate() > referenceDate; });
178 QL_REQUIRE(it != instruments_.end(), "PiecewisePriceCurve: all instruments are expired.");
179 if (it != instruments_.begin()) {
180 instruments_.erase(instruments_.begin(), it);
181 }
182
183 bootstrap_.setup(this);
184}
const QuantLib::Currency & currency() const override
The currency in which prices are expressed.
Definition: pricecurve.hpp:92
Bootstrap< this_curve > bootstrap_
InterpolatedPriceCurve< Interpolator > base_curve
std::vector< QuantLib::ext::shared_ptr< helper > > instruments_

Member Function Documentation

◆ maxDate()

QuantLib::Date maxDate
override

Definition at line 187 of file piecewisepricecurve.hpp.

187 {
188 this->calculate();
189 return base_curve::maxDate();
190}
QuantLib::Date maxDate() const override
Definition: pricecurve.hpp:233

◆ maxTime()

QuantLib::Time maxTime
override

Definition at line 193 of file piecewisepricecurve.hpp.

193 {
194 this->calculate();
195 return base_curve::maxTime();
196}
QuantLib::Time maxTime() const override
Definition: pricecurve.hpp:238

◆ minTime()

QuantLib::Time minTime
overridevirtual

The minimum time for which the curve can return values.

Reimplemented from PriceTermStructure.

Definition at line 199 of file piecewisepricecurve.hpp.

199 {
200 this->calculate();
201 return base_curve::minTime();
202}
QuantLib::Time minTime() const override
The minimum time for which the curve can return values.
Definition: pricecurve.hpp:243

◆ pillarDates()

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

The pillar dates for the PriceTermStructure.

Implements PriceTermStructure.

Definition at line 205 of file piecewisepricecurve.hpp.

205 {
206 this->calculate();
208}
std::vector< QuantLib::Date > pillarDates() const override
The pillar dates for the PriceTermStructure.
Definition: pricecurve.hpp:248

◆ times()

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

Definition at line 211 of file piecewisepricecurve.hpp.

211 {
212 this->calculate();
213 return base_curve::times();
214}
const std::vector< QuantLib::Time > & times() const
Definition: pricecurve.hpp:97

◆ prices()

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

Definition at line 217 of file piecewisepricecurve.hpp.

217 {
218 this->calculate();
219 return base_curve::prices();
220}
const std::vector< QuantLib::Real > & prices() const
Definition: pricecurve.hpp:98

◆ instrument()

const QuantLib::ext::shared_ptr< QuantLib::BootstrapHelper< PriceTermStructure > > & instrument ( QuantLib::Size  i) const

Return the i-th instrument.

Definition at line 224 of file piecewisepricecurve.hpp.

224 {
225 QL_REQUIRE(i < instruments_.size(), "Index (" << i << ") greater than the number of instruments (" <<
226 instruments_.size() << ").");
227 return instruments_[i];
228}

◆ performCalculations()

void performCalculations
overrideprivate

Definition at line 231 of file piecewisepricecurve.hpp.

231 {
232 bootstrap_.calculate();
234}
void performCalculations() const override
Definition: pricecurve.hpp:219

◆ priceImpl()

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

Price calculation.

Implements PriceTermStructure.

Definition at line 237 of file piecewisepricecurve.hpp.

237 {
238 this->calculate();
239 return base_curve::priceImpl(t);
240}
QuantLib::Real priceImpl(QuantLib::Time t) const override
Price calculation.
Definition: pricecurve.hpp:253

Friends And Related Function Documentation

◆ Bootstrap< this_curve >

friend class Bootstrap< this_curve >
friend

Definition at line 153 of file piecewisepricecurve.hpp.

◆ BootstrapError< this_curve >

friend class BootstrapError< this_curve >
friend

Definition at line 153 of file piecewisepricecurve.hpp.

◆ PenaltyFunction< this_curve >

friend class PenaltyFunction< this_curve >
friend

Definition at line 153 of file piecewisepricecurve.hpp.

Member Data Documentation

◆ instruments_

std::vector<QuantLib::ext::shared_ptr<helper> > instruments_
private

Definition at line 152 of file piecewisepricecurve.hpp.

◆ accuracy_

Real accuracy_
private

Definition at line 153 of file piecewisepricecurve.hpp.

◆ bootstrap_

Bootstrap<this_curve> bootstrap_
private

Definition at line 158 of file piecewisepricecurve.hpp.