25#ifndef quantlib_bsm_lattice_hpp
26#define quantlib_bsm_lattice_hpp
52 return tree_->underlying(i, index);
55 return tree_->descendant(i, index, branch);
58 return tree_->probability(i, index, branch);
73 const ext::shared_ptr<T>& tree,
78 tree_(tree), riskFreeRate_(riskFreeRate), dt_(end/steps),
79 discount_(
std::exp(-riskFreeRate*(dt_))),
80 pd_(tree->probability(0, 0, 0)), pu_(tree->probability(0, 0, 1)) {}
84 Array& newValues)
const {
85 for (
Size j=0; j<size(i); j++)
86 newValues[j] = (
pd_*values[j] + pu_*values[j+1])*discount_;
1-D array used in linear algebra.
Simple binomial lattice approximating the Black-Scholes model.
Size descendant(Size i, Size index, Size branch) const
BlackScholesLattice(const ext::shared_ptr< T > &tree, Rate riskFreeRate, Time end, Size steps)
Real probability(Size i, Size index, Size branch) const
ext::shared_ptr< T > tree_
Real underlying(Size i, Size index) const
DiscountFactor discount(Size, Size) const
void stepback(Size i, const Array &values, Array &newValues) const
Rate riskFreeRate() const
One-dimensional tree-based lattice.
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
One-dimensional lattice class.