Stochastic Volatility Modeling Basics 2024

One of the interesting and newer developments in Quantitative Finance is Stochastic Volatility Modeling. One of the prominent models is the Heston Model, which introduces a stochastic process for the volatility of an asset. Unlike the Black-Scholes model, where volatility is constant, the Heston model assumes volatility itself follows a stochastic process.

Key Components of the Heston Model

The Heston model assumes the following two stochastic differential equations (SDEs) for the asset price \( S_t \) and its variance \( v_t \):

\[
dS_t = \mu S_t dt + \sqrt{v_t} S_t dW_t^S
\]
\[
dv_t = \kappa (\theta - v_t) dt + \sigma \sqrt{v_t} dW_t^v
\]

Where:

  • \( S_t \) is the asset price at time \( t \),
  • \( \mu \) is the drift rate of the asset,
  • \( v_t \) is the variance (the square of volatility),
  • \( \kappa \) is the rate at which \( v_t \) reverts to its long-term mean \( \theta \),
  • \( \sigma \) is the volatility of volatility (vol of vol),
  • \( dW_t^S \) and \( dW_t^v \) are Wiener processes, possibly correlated with correlation \( \rho \).

Python Code Example: Simulating the Heston Model

Let’s write a Python code to simulate asset prices and volatility under the Heston Model using the Euler-Maruyama method.

import numpy as np
import matplotlib.pyplot as plt

# Heston model parameters
S0 = 100      # Initial stock price
v0 = 0.04     # Initial variance
mu = 0.05     # Drift of the asset price
kappa = 2.0   # Rate of mean reversion for variance
theta = 0.04  # Long term mean of variance
sigma = 0.3   # Volatility of variance (vol of vol)
rho = -0.7    # Correlation between asset price and variance
T = 1.0       # Time horizon (1 year)
dt = 1/252    # Time step (daily)
N = int(T/dt) # Number of time steps
M = 1000      # Number of simulation paths

# Simulating correlated Brownian motions
np.random.seed(42)
dW1 = np.random.normal(0, np.sqrt(dt), (N, M))  # Brownian motion for stock
dW2 = np.random.normal(0, np.sqrt(dt), (N, M))  # Brownian motion for variance
dW2 = rho * dW1 + np.sqrt(1 - rho**2) * dW2     # Correlated with dW1

# Arrays to store the simulated paths
S = np.zeros((N, M))
v = np.zeros((N, M))

# Initial values
S[0] = S0
v[0] = v0

# Euler-Maruyama method for the Heston model
for t in range(1, N):
    v[t] = np.abs(v[t-1] + kappa * (theta - v[t-1]) * dt + sigma * np.sqrt(v[t-1]) * dW2[t])
    S[t] = S[t-1] * np.exp((mu - 0.5 * v[t-1]) * dt + np.sqrt(v[t-1]) * dW1[t])

# Plotting the results
plt.figure(figsize=(10, 6))
plt.plot(S[:, :10])  # Plot 10 sample paths of the asset price
plt.title("Simulated Asset Price Paths under the Heston Model")
plt.xlabel("Time Step")
plt.ylabel("Asset Price")
plt.grid(True)
plt.show()

Explanation of the Code:

  1. Model Parameters: We define the parameters for the Heston model such as initial stock price \( S_0 \), initial variance \( v_0 \), mean reversion speed \( \kappa \), long-term variance \( \theta \), and volatility of volatility \( \sigma \).
  2. Simulating Brownian Motions: We generate two Brownian motions, \( dW_1 \) for the asset price and \( dW_2 \) for the variance. These Brownian motions are correlated with correlation \( \rho \).
  3. Euler-Maruyama Approximation: We discretize the stochastic differential equations for the asset price and variance using the Euler-Maruyama method, iterating over time steps.
  4. Plot: Finally, we plot a few simulated paths of the asset price under the Heston model.

Heston Model Formula Summary:

  • Variance Process:
    \[
    dv_t = \kappa (\theta - v_t) dt + \sigma \sqrt{v_t} dW_t^v
    \]
    This is a mean-reverting process where \( v_t \) tends to revert to \( \theta \) with speed \( \kappa \) and volatility \( \sigma \).
  • Asset Price Process:
    \[
    dS_t = \mu S_t dt + \sqrt{v_t} S_t dW_t^S
    \]
    The asset price dynamics are driven by stochastic volatility \( v_t \).

This model allows for more realistic modeling of markets, especially capturing features like volatility clustering and the volatility smile observed in options markets.

Read more