qdpmc.model.market_process.Heston¶
- class qdpmc.model.market_process.Heston(r, q, rho, theta, kappa, xi, default_v0, day_counter=252)[source]¶
Bases:
object
A stochastic-volatility model due to Heston (1993).
\[\begin{split}\begin{align*} \mathrm{d}S_t&=(r - q)S_t\mathrm{d}t + \sqrt{v_t} S_t \mathrm{d}W_t \\ \mathrm{d}v_t&=\kappa(\theta-v_t)\mathrm{d}t + \xi \sqrt{v_t} \mathrm{d}Z_t \end{align*}\end{split}\]When passing a Heston process into the Monte Carlo engine, products will be valued by discounting the payoff at the risk-free (parameter r) rate.
- Parameters
r (scalar) – The risk-free rate. It is used as the continuous discount rate.
q (scalar) – The continuous yield of the underlying asset. Notice that (r-q) is the drift of the price of the underlying asset under a risk-neutral measure.
rho (scalar) – The correlation between the two standard Brownian motions. This must be greater than -1 and less than 1.
theta (scalar) – The long-term mean of v.
kappa (scalar) – The mean-reverting intensity. The larger it is, the quicker v reverts to theta.
xi (scalar) – The volatility of v.
default_v0 (scalar) – The default starting value of the variance.
day_counter (
int
) – Number of days per year. This affects the discount factor.
Methods
__init__
(r, q, rho, theta, kappa, xi, default_v0)A stochastic-volatility model due to Heston (1993).
generate_path
(t[, v0, gamma1, gamma2, …])Generate a set of projections.
generate_path_given_uz
(t, u, z[, v0, …])Project variance and log return given random numbers.
Attributes
coordinator
- generate_path(t, v0=None, gamma1=0.5, gamma2=0.5, batch_size=100, seed=None, grid_points_in_time=None)[source]¶
Generate a set of projections.
- Parameters
t (scalar) – The time index through which the path are generated. Note that t=1 represents a 1-year horizon. Notice that t * self.day_counter should be an integer.
v0 (scalar) – The initial value of v. If is None, it is set to default_v0. Default is None.
gamma1 (scalar) – Controls the finite-difference scheme when simulating the log return. Central scheme corresponds to gamma1=gamma2=0.5.
gamma2 (scalar) – Controls the finite-difference scheme when simulating the log return. Central scheme corresponds to gamma1=gamma2=0.5.
batch_size (
int
) – How many paths to generate at a time.seed (
int
) – The random seed. If None, it will be chosen randomly. Default is None.grid_points_in_time (
int
) – Number of grid points in time. If None, daily simulation is assumed. Default is None
- Returns
v (
numpy.ndarray
) – Projections of variance.x (
numpy.ndarray
) – Projections of log return.