Skip to content
All library documents

Implementing Andersen’s Heston Scheme for Asset Paths

Article Quant Q&A · Author: JosephConrad

Summary

The document presents code for simulating the asset component of a Heston model with Andersen’s scheme. The update uses the current and next variance values, model parameters, and a normal draw to produce each asset price. The author reports that option values are about 20% lower than with an Euler asset update, while using Andersen for variance and Euler for the asset gives more plausible values, and asks where the implementation may be wrong.

It also states the Heston dynamics and gives formulas for the scheme’s coefficients. No answer identifying a specific coding error or diagnosing the price gap is included. The reported comparison is therefore a clue from one simulation, not evidence that the asset update is incorrect; correctness also depends on consistent variance simulation, parameter conventions, and implementation details.

Key ideas

  • Andersen’s asset update uses both the variance at the start and end of each time step.
  • The update combines a drift adjustment, variance-dependent terms, and an independent normal shock.
  • The author reports lower option values than with Euler asset simulation, but provides no diagnosis of the discrepancy.
  • The stated model correlates the asset and variance Brownian motions, so simulation conventions matter.

Tags

Full text
# Heston model - Andersen scheme implementation


# Heston model - Andersen scheme implementation












I would like to implement Andersen scheme for Heston simulation. On the following snipped is my code for generating asset path:

```
double dt = option->T / static_cast<double>(size);

double k0, k1, k2, k3, k4, gamma1, gamma2;

gamma1 = 0.5;
gamma2 = 0.5;

k0 = -dt * (rho * kappa * theta) / (epsilon);
k1 = gamma1 * dt * (((kappa * rho) / epsilon) - 0.5) - (rho / epsilon);
k2 = gamma2 * dt * (((kappa * rho) / epsilon) - 0.5) + (rho / epsilon);
k3 = gamma1 * dt * (1 - pow(rho,2));
k4 = gamma2 * dt * (1 - pow(rho,2));

for (int i = 1; i < size; i++) {

    double normalRandom = normalDist(generator);
    spotPath[i] = spotPath[i - 1] * exp(option->r * dt + k0 + k1 * volPath[i - 1] + k2 * volPath[i] +
                                                (sqrt(k3 * volPath[i - 1] + k4 * volPath[i]) * normalRandom));
}
```

Unfortunately, when I simulate this and compare to Euler scheme I got around 20% lower option value. I think that mistake is here (not in simulating volatility path), because when I make Euler scheme for asset and Andersen scheme for volatility, the option value is more less correct. Do you see any mistake in my code?

Edit: My Heston model: $$dS(t) = r S(t) dt + \sqrt{v(t)} S(t) dW^S(t)$$ $$dv(t) = \kappa (\theta - v(t))dt + \varepsilon \sqrt{v(t)} dW^v(t) $$ $$Cov[dW^S(t), dW^v(t)] = \rho dt $$

Andersen scheme (asset path): $$\hat{S}(t + \Delta) = \hat{S}(t) * exp(r \Delta + K_0 + K_1 \hat{v}(t) + K_2 \hat{v}(t+\Delta) + \sqrt{K_3 \hat{v}(t) + K_4 \hat{v}(t+\Delta)} \cdot Z)$$ where: $$K_0 = - \frac{\rho \kappa \theta}{\varepsilon} \Delta$$ $$K_1 = \gamma_1 \Delta \left( \frac{\kappa \rho}{\varepsilon} - \frac{1}{2} \right) - \frac{\rho}{\varepsilon}$$ $$K_2 = \gamma_2 \Delta \left( \frac{\kappa \rho}{\varepsilon} - \frac{1}{2} \right) + \frac{\rho}{\varepsilon}$$ $$K_3 = \gamma_1 \Delta (1 - \rho^2)$$ $$K_4 = \gamma_2 \Delta (1 - \rho^2)$$

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.