QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TreeLattice< Impl > Class Template Reference

Tree-based lattice-method base class. More...

#include <lattice.hpp>

+ Inheritance diagram for TreeLattice< Impl >:
+ Collaboration diagram for TreeLattice< Impl >:

Public Member Functions

 TreeLattice (const TimeGrid &timeGrid, Size n)
 
- Public Member Functions inherited from Lattice
 Lattice (TimeGrid timeGrid)
 
virtual ~Lattice ()=default
 
const TimeGridtimeGrid () const
 
virtual Array grid (Time) const =0
 

Lattice interface

std::vector< ArraystatePrices_
 
Size n_
 
Size statePricesLimit_
 
void initialize (DiscretizedAsset &, Time t) const override
 initialize an asset at the given time. More...
 
void rollback (DiscretizedAsset &, Time to) const override
 
void partialRollback (DiscretizedAsset &, Time to) const override
 
Real presentValue (DiscretizedAsset &) const override
 Computes the present value of an asset using Arrow-Debrew prices. More...
 
const ArraystatePrices (Size i) const
 
void stepback (Size i, const Array &values, Array &newValues) const
 
void computeStatePrices (Size until) const
 

Additional Inherited Members

- Protected Member Functions inherited from CuriouslyRecurringTemplate< Impl >
 CuriouslyRecurringTemplate ()=default
 
 ~CuriouslyRecurringTemplate ()=default
 
Impl & impl ()
 
const Impl & impl () const
 
- Protected Attributes inherited from Lattice
TimeGrid t_
 

Detailed Description

template<class Impl>
class QuantLib::TreeLattice< Impl >

Tree-based lattice-method base class.

This class defines a lattice method that is able to rollback (with discount) a discretized asset object. It will be based on one or more trees.

Derived classes must implement the following interface:

public:
DiscountFactor discount(Size i, Size index) const;
Size descendant(Size i, Size index, Size branch) const;
Real probability(Size i, Size index, Size branch) const;
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
std::size_t Size
size of a container
Definition: types.hpp:58

and may implement the following:

public:
void stepback(Size i,
const Array& values,
Array& newValues) const;
1-D array used in linear algebra.
Definition: array.hpp:52
void stepback(Size i, const Array &values, Array &newValues) const
Definition: lattice.hpp:167

Definition at line 57 of file lattice.hpp.

Constructor & Destructor Documentation

◆ TreeLattice()

TreeLattice ( const TimeGrid timeGrid,
Size  n 
)

Definition at line 60 of file lattice.hpp.

Member Function Documentation

◆ initialize()

void initialize ( DiscretizedAsset ,
Time  time 
) const
overridevirtual

initialize an asset at the given time.

Implements Lattice.

Definition at line 127 of file lattice.hpp.

+ Here is the call graph for this function:

◆ rollback()

void rollback ( DiscretizedAsset ,
Time  to 
) const
overridevirtual

Roll back an asset until the given time, performing any needed adjustment.

Implements Lattice.

Reimplemented in TsiveriotisFernandesLattice< T >.

Definition at line 134 of file lattice.hpp.

+ Here is the call graph for this function:

◆ partialRollback()

void partialRollback ( DiscretizedAsset ,
Time  to 
) const
overridevirtual

Roll back an asset until the given time, but do not perform the final adjustment.

Warning:
In version 0.3.7 and earlier, this method was called rollAlmostBack method and performed pre-adjustment. This is no longer true; when migrating your code, you'll have to replace calls such as:
method->rollAlmostBack(asset,t);
const DefaultType & t

with the two statements:

method->partialRollback(asset,t);
asset->preAdjustValues();

Implements Lattice.

Reimplemented in TsiveriotisFernandesLattice< T >.

Definition at line 140 of file lattice.hpp.

+ Here is the call graph for this function:

◆ presentValue()

Real presentValue ( DiscretizedAsset asset) const
overridevirtual

Computes the present value of an asset using Arrow-Debrew prices.

Implements Lattice.

Definition at line 121 of file lattice.hpp.

+ Here is the call graph for this function:

◆ statePrices()

const Array & statePrices ( Size  i) const

Definition at line 114 of file lattice.hpp.

◆ stepback()

void stepback ( Size  i,
const Array values,
Array newValues 
) const

Definition at line 167 of file lattice.hpp.

◆ computeStatePrices()

void computeStatePrices ( Size  until) const
protected

Definition at line 98 of file lattice.hpp.

Member Data Documentation

◆ statePrices_

std::vector<Array> statePrices_
mutableprotected

Definition at line 87 of file lattice.hpp.

◆ n_

Size n_
private

Definition at line 90 of file lattice.hpp.

◆ statePricesLimit_

Size statePricesLimit_
mutableprivate

Definition at line 91 of file lattice.hpp.