QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | List of all members
FittedBondDiscountCurve Class Reference

Discount curve fitted to a set of fixed-coupon bonds. More...

#include <fittedbonddiscountcurve.hpp>

+ Inheritance diagram for FittedBondDiscountCurve:
+ Collaboration diagram for FittedBondDiscountCurve:

Classes

class  FittingMethod
 Base fitting method used to construct a fitted bond discount curve. More...
 

Public Member Functions

Constructors
 FittedBondDiscountCurve (Natural settlementDays, const Calendar &calendar, std::vector< ext::shared_ptr< BondHelper > > bonds, const DayCounter &dayCounter, const FittingMethod &fittingMethod, Real accuracy=1.0e-10, Size maxEvaluations=10000, Array guess=Array(), Real simplexLambda=1.0, Size maxStationaryStateIterations=100)
 reference date based on current evaluation date More...
 
 FittedBondDiscountCurve (const Date &referenceDate, std::vector< ext::shared_ptr< BondHelper > > bonds, const DayCounter &dayCounter, const FittingMethod &fittingMethod, Real accuracy=1.0e-10, Size maxEvaluations=10000, Array guess=Array(), Real simplexLambda=1.0, Size maxStationaryStateIterations=100)
 curve reference date fixed for life of curve More...
 
Inspectors
Size numberOfBonds () const
 total number of bonds used to fit the yield curve More...
 
Date maxDate () const override
 the latest date for which the curve can return values More...
 
const FittingMethodfitResults () const
 class holding the results of the fit More...
 
- Public Member Functions inherited from YieldTermStructure
 YieldTermStructure (const DayCounter &dc=DayCounter())
 
 YieldTermStructure (const Date &referenceDate, const Calendar &cal=Calendar(), const DayCounter &dc=DayCounter(), std::vector< Handle< Quote > > jumps={}, const std::vector< Date > &jumpDates={})
 
 YieldTermStructure (Natural settlementDays, const Calendar &cal, const DayCounter &dc=DayCounter(), std::vector< Handle< Quote > > jumps={}, const std::vector< Date > &jumpDates={})
 
DiscountFactor discount (const Date &d, bool extrapolate=false) const
 
DiscountFactor discount (Time t, bool extrapolate=false) const
 
InterestRate zeroRate (const Date &d, const DayCounter &resultDayCounter, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
 
InterestRate zeroRate (Time t, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
 
InterestRate forwardRate (const Date &d1, const Date &d2, const DayCounter &resultDayCounter, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
 
InterestRate forwardRate (const Date &d, const Period &p, const DayCounter &resultDayCounter, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
 
InterestRate forwardRate (Time t1, Time t2, Compounding comp, Frequency freq=Annual, bool extrapolate=false) const
 
const std::vector< Date > & jumpDates () const
 
const std::vector< Time > & jumpTimes () const
 
void update () override
 
- Public Member Functions inherited from TermStructure
 TermStructure (DayCounter dc=DayCounter())
 default constructor More...
 
 TermStructure (const Date &referenceDate, Calendar calendar=Calendar(), DayCounter dc=DayCounter())
 initialize with a fixed reference date More...
 
 TermStructure (Natural settlementDays, Calendar, DayCounter dc=DayCounter())
 calculate the reference date based on the global evaluation date More...
 
 ~TermStructure () override=default
 
virtual DayCounter dayCounter () const
 the day counter used for date/time conversion More...
 
Time timeFromReference (const Date &date) const
 date/time conversion More...
 
virtual Time maxTime () const
 the latest time for which the curve can return values More...
 
virtual const DatereferenceDate () const
 the date at which discount = 1.0 and/or variance = 0.0 More...
 
virtual Calendar calendar () const
 the calendar used for reference and/or option date calculation More...
 
virtual Natural settlementDays () const
 the settlementDays used for reference date calculation More...
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Extrapolator
 Extrapolator ()=default
 
virtual ~Extrapolator ()=default
 
void enableExtrapolation (bool b=true)
 enable extrapolation in subsequent calls More...
 
void disableExtrapolation (bool b=true)
 disable extrapolation in subsequent calls More...
 
bool allowsExtrapolation () const
 tells whether extrapolation is enabled More...
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 

Observer interface

Real accuracy_
 
Size maxEvaluations_
 
Real simplexLambda_
 
Size maxStationaryStateIterations_
 
Array guessSolution_
 
Date maxDate_
 
std::vector< ext::shared_ptr< BondHelper > > bondHelpers_
 
Clone< FittingMethodfittingMethod_
 
void update () override
 
void setup ()
 
void performCalculations () const override
 
DiscountFactor discountImpl (Time) const override
 discount factor calculation More...
 

Additional Inherited Members

- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from YieldTermStructure
- Protected Member Functions inherited from TermStructure
void checkRange (const Date &d, bool extrapolate) const
 date-range check More...
 
void checkRange (Time t, bool extrapolate) const
 time-range check More...
 
- Protected Member Functions inherited from LazyObject
virtual void calculate () const
 
- Protected Attributes inherited from TermStructure
bool moving_ = false
 
bool updated_ = true
 
Calendar calendar_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 

Detailed Description

Discount curve fitted to a set of fixed-coupon bonds.

This class fits a discount function \( d(t) \) over a set of bonds, using a user defined fitting method. The discount function is fit in such a way so that all cashflows of all input bonds, when discounted using \( d(t) \), will reproduce the set of input bond prices in an optimized sense. Minimized price errors are weighted by the inverse of their respective bond duration.

The FittedBondDiscountCurve class acts as a generic wrapper, while its inner class FittingMethod provides the implementation details. Developers thus need only derive new fitting methods from the latter.

Warning:
The method can be slow if there are many bonds to fit. Speed also depends on the particular choice of fitting method chosen and its convergence properties under optimization. See also todo list for BondDiscountCurveFittingMethod.

Definition at line 80 of file fittedbonddiscountcurve.hpp.

Constructor & Destructor Documentation

◆ FittedBondDiscountCurve() [1/2]

FittedBondDiscountCurve ( Natural  settlementDays,
const Calendar calendar,
std::vector< ext::shared_ptr< BondHelper > >  bonds,
const DayCounter dayCounter,
const FittingMethod fittingMethod,
Real  accuracy = 1.0e-10,
Size  maxEvaluations = 10000,
Array  guess = Array(),
Real  simplexLambda = 1.0,
Size  maxStationaryStateIterations = 100 
)

reference date based on current evaluation date

Definition at line 49 of file fittedbonddiscountcurve.cpp.

+ Here is the call graph for this function:

◆ FittedBondDiscountCurve() [2/2]

FittedBondDiscountCurve ( const Date referenceDate,
std::vector< ext::shared_ptr< BondHelper > >  bonds,
const DayCounter dayCounter,
const FittingMethod fittingMethod,
Real  accuracy = 1.0e-10,
Size  maxEvaluations = 10000,
Array  guess = Array(),
Real  simplexLambda = 1.0,
Size  maxStationaryStateIterations = 100 
)

curve reference date fixed for life of curve

Definition at line 69 of file fittedbonddiscountcurve.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ numberOfBonds()

Size numberOfBonds ( ) const

total number of bonds used to fit the yield curve

Definition at line 260 of file fittedbonddiscountcurve.hpp.

◆ maxDate()

Date maxDate ( ) const
overridevirtual

the latest date for which the curve can return values

Implements TermStructure.

Definition at line 264 of file fittedbonddiscountcurve.hpp.

+ Here is the call graph for this function:

◆ fitResults()

const FittedBondDiscountCurve::FittingMethod & fitResults ( ) const

class holding the results of the fit

Definition at line 270 of file fittedbonddiscountcurve.hpp.

+ Here is the call graph for this function:

◆ update()

void update ( )
overridevirtual

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Reimplemented from LazyObject.

Definition at line 275 of file fittedbonddiscountcurve.hpp.

+ Here is the call graph for this function:

◆ setup()

void setup ( )
private

Definition at line 280 of file fittedbonddiscountcurve.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprivatevirtual

This method must implement any calculations which must be (re)done in order to calculate the desired results.

Implements LazyObject.

Definition at line 89 of file fittedbonddiscountcurve.cpp.

+ Here is the call graph for this function:

◆ discountImpl()

DiscountFactor discountImpl ( Time  ) const
overrideprivatevirtual

discount factor calculation

Implements YieldTermStructure.

Definition at line 285 of file fittedbonddiscountcurve.hpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ accuracy_

Real accuracy_
private

Definition at line 130 of file fittedbonddiscountcurve.hpp.

◆ maxEvaluations_

Size maxEvaluations_
private

Definition at line 132 of file fittedbonddiscountcurve.hpp.

◆ simplexLambda_

Real simplexLambda_
private

Definition at line 134 of file fittedbonddiscountcurve.hpp.

◆ maxStationaryStateIterations_

Size maxStationaryStateIterations_
private

Definition at line 136 of file fittedbonddiscountcurve.hpp.

◆ guessSolution_

Array guessSolution_
private

Definition at line 138 of file fittedbonddiscountcurve.hpp.

◆ maxDate_

Date maxDate_
mutableprivate

Definition at line 139 of file fittedbonddiscountcurve.hpp.

◆ bondHelpers_

std::vector<ext::shared_ptr<BondHelper> > bondHelpers_
private

Definition at line 140 of file fittedbonddiscountcurve.hpp.

◆ fittingMethod_

Clone<FittingMethod> fittingMethod_
private

Definition at line 141 of file fittedbonddiscountcurve.hpp.