Heston Monte Carlo pricer
Implement heston_call(S, K, T, r, v0, kappa, theta, xi, rho, steps, n, seed) — a European call under Heston stochastic volatility by Euler simulation with full truncation. Call random.seed(seed); for each path and step draw z1 = random.gauss(0, 1) then w = random.gauss(0, 1), set z2 = rho·z1 + sqrt(1 - rho²)·w, update v = max(v + kappa·(theta - v)·dt + xi·sqrt(max(v, 0))·sqrt(dt)·z2, 0) and S = S·exp((r - v/2)·dt + sqrt(v)·sqrt(dt)·z1) using the variance from the START of the step. Discount the mean payoff.
Five parameters and a correlation buy you a volatility smile that Black-Scholes cannot draw; the workbench's Heston surrogate is trained on this exact simulation. Return the price rounded to 4 decimal places.
S=100.0, K=100.0, T=1.0, r=0.02, v0=0.04, kappa=1.5, theta=0.04, xi=0.3, rho=0.0, steps=20, n=400, seed=7
9.2308
S=100.0, K=100.0, T=1.0, r=0.02, v0=0.04, kappa=1.5, theta=0.04, xi=0.3, rho=-0.7, steps=20, n=400, seed=7
9.1822
Same parameters with rho = −0.7: the skew appears.
- -1 < rho < 1
- kappa, theta, xi > 0
- steps ≤ 40, n ≤ 1_000 (it has to run in your head, not on a cluster)
S=100.0, K=100.0, T=1.0, r=0.02, v0=0.04, kappa=1.5, theta=0.04, xi=0.3, rho=0.0, steps=20, n=400, seed=7
9.2308
the judge calls heston_call() with exactly these inputs · outputs are compared to 6 decimal places