Bases: LatticeTechnique
Kamrad-Ritchken trinomial lattice technique.
Source code in src/quantfin/techniques/topm.py
| class TOPMTechnique(LatticeTechnique):
"""Kamrad-Ritchken trinomial lattice technique."""
def _price_and_get_nodes(
self,
option: Option,
stock: Stock,
model: BaseModel,
rate: Rate,
) -> dict[str, Any]:
"""
Prices the option using the TOPM kernel.
This method extracts the necessary numerical parameters from the input
objects and passes them to the low-level `_topm_pricer` kernel.
Parameters
----------
option : Option
The option contract to be priced.
stock : Stock
The underlying asset's properties.
model : BaseModel
The financial model, used to get volatility.
rate : Rate
The risk-free rate structure.
Returns
-------
dict[str, Any]
A dictionary from the kernel containing the price and node values.
"""
sigma = model.params.get("sigma", stock.volatility)
return _topm_pricer(
S0=stock.spot,
K=option.strike,
T=option.maturity,
r=rate.get_rate(option.maturity),
q=stock.dividend,
vol=sigma,
N=self.steps,
is_call=(option.option_type is OptionType.CALL),
is_am=self.is_american,
)
|