25#ifndef quantlib_one_factor_model_hpp
26#define quantlib_one_factor_model_hpp
34 class StochasticProcess1D;
47 virtual ext::shared_ptr<ShortRateDynamics>
dynamics()
const = 0;
50 ext::shared_ptr<Lattice>
tree(
const TimeGrid& grid)
const override;
67 const ext::shared_ptr<StochasticProcess1D>&
process() {
80 ext::shared_ptr<ShortRateDynamics>
dynamics,
84 ext::shared_ptr<ShortRateDynamics>
dynamics,
85 const ext::shared_ptr<TermStructureFittingParameter::NumericalImpl>& phi,
89 return tree_->size(i);
97 return tree_->underlying(i, index);
100 return tree_->descendant(i, index, branch);
103 return tree_->probability(i, index, branch);
110 ext::shared_ptr<TrinomialTree>
tree_;
137 return A(now, maturity)*std::exp(-
B(now, maturity)*rate);
1-D array used in linear algebra.
const TimeGrid & timeGrid() const
Single-factor affine base class.
Real discountBond(Time now, Time maturity, Array factors) const override
OneFactorAffineModel(Size nArguments)
DiscountFactor discount(Time t) const override
Implied discount curve.
virtual Real A(Time t, Time T) const =0
Real discountBond(Time now, Time maturity, Rate rate) const
virtual Real B(Time t, Time T) const =0
Base class describing the short-rate dynamics.
virtual Rate shortRate(Time t, Real variable) const =0
Compute short rate from state variable.
ext::shared_ptr< StochasticProcess1D > process_
virtual Real variable(Time t, Rate r) const =0
Compute state variable from short rate.
ShortRateDynamics(ext::shared_ptr< StochasticProcess1D > process)
const ext::shared_ptr< StochasticProcess1D > & process()
Returns the risk-neutral dynamics of the state variable.
virtual ~ShortRateDynamics()=default
Recombining trinomial tree discretizing the state variable.
ext::shared_ptr< ShortRateDynamics > dynamics_
Size descendant(Size i, Size index, Size branch) const
DiscountFactor discount(Size i, Size index) const
void setSpread(Spread spread)
ext::shared_ptr< TrinomialTree > tree_
Real probability(Size i, Size index, Size branch) const
Real underlying(Size i, Size index) const
Single-factor short-rate model abstract class.
~OneFactorModel() override=default
ext::shared_ptr< Lattice > tree(const TimeGrid &grid) const override
Return by default a trinomial recombining tree.
virtual ext::shared_ptr< ShortRateDynamics > dynamics() const =0
returns the short-rate dynamics
Abstract short-rate model class.
One-dimensional tree-based lattice.
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
Real Spread
spreads on interest rates
std::size_t Size
size of a container
One-dimensional lattice class.
Abstract interest rate model class.
ext::shared_ptr< YieldTermStructure > r