OLIVER SCOTT
Projects / Research · Derivatives

Options pricing and implied volatility

PythonNumPySciPypytest
AbstractI priced European and American options four ways and checked each against the others: closed-form Black-Scholes-Merton, a Cox-Ross-Rubinstein lattice, and Monte Carlo with antithetic and control-variate variance reduction. An implied-volatility solver combines Newton's method with a bisection fallback. A test suite pins every method to parity, textbook values and finite differences.
7.4117BSM call (S 100, K 105, T 0.75, σ 25%)
4.2×variance reduction, control variate
81 µsper implied-vol solve, max error 7e-07
$0.34early-exercise premium, American put

01Methods

  • Closed form with continuous dividend yield and analytic delta, gamma, vega, theta, rho.
  • CRR lattice, vectorised over each layer, with an early-exercise check for American options.
  • Monte Carlo under GBM: plain; antithetic pairs; and ST as a control variate, whose discounted mean is known exactly (S·e−qT).
  • Implied vol: Newton steps on vega from σ = 20%, falling back to bisection when vega vanishes or a step leaves (0.01%, 500%).

02Convergence and variance reduction

Lattice error by steps and Monte Carlo standard error by paths
Fig. 1 Left: the lattice error oscillates between odd and even step counts and shrinks to $0.0004 at 800 steps. Right: Monte Carlo standard error falls as 1/√n; the control variate shifts the whole line down, equal to 4.2× fewer paths for the same accuracy.

At 256,000 paths the standard error is $0.0264 plain, $0.0221 antithetic and $0.0129 with the control variate. Antithetic helps less here because the payoff is far from linear in the shock.

03Greeks

Delta gamma vega curves
Fig. 2 Delta, gamma and vega across spot for three expiries. Gamma concentrates at the strike as expiry nears; vega shrinks with time.

04Implied volatility edge case

Over 2,034 strike, volatility and expiry combinations the solver recovers σ to within 7e-07. It skips 198 cases on purpose: deep in- or out-of-the-money options at low volatility are worth their intrinsic value to machine precision, so no volatility can be recovered from the price. The first test run failed on exactly these cases, which is how I found them.

def implied_vol(price, S, K, T, r, q=0.0, kind="call"):
    # reject prices outside no-arbitrage bounds, then Newton on vega
    sig = 0.2
    for _ in range(max_iter):
        diff = bs_price(S, K, T, r, sig, q, kind) - price
        if abs(diff) < tol: return sig
        v = bs_greeks(S, K, T, r, sig, q, kind)["vega"]
        if v < 1e-8: break          # flat region: fall back to bisection
        sig -= diff / v

Swapping SciPy's distribution objects for scipy.special.ndtr cut the solve time from 2.7 ms to 81 µs.

05What I'd do next

  • Heston pricing via characteristic functions and the Carr-Madan FFT.
  • Fit an SVI smile to real option quotes and check for static arbitrage.
  • Delta-hedging P&L under misspecified volatility.