Math & Implementation Notes

Options Lab

Back to App

Black-Scholes Model

The Black-Scholes model prices European options with continuous dividend yield:

C = S·e^(-qT)·N(d₁) - K·e^(-rT)·N(d₂)
P = K·e^(-rT)·N(-d₂) - S·e^(-qT)·N(-d₁)
d₁ = [ln(S/K) + (r - q + σ²/2)T] / (σ√T)
d₂ = d₁ - σ√T

Parameters: S = spot, K = strike, r = risk-free rate, q = dividend yield, σ = volatility, T = time to expiry (years)

Greeks

  • Delta (Δ): ∂V/∂S — Sensitivity to underlying price
  • Gamma (Γ): ∂²V/∂S² — Rate of change of delta
  • Vega (ν): ∂V/∂σ — Sensitivity to volatility (per 1%)
  • Theta (Θ): -∂V/∂T — Time decay (per day)
  • Rho (ρ): ∂V/∂r — Sensitivity to interest rate (per 1%)

Note: Vega and Rho are scaled to represent 1% moves for interpretability.

Normal CDF Implementation

We use the Abramowitz & Stegun approximation (formula 26.2.17) for the standard normal CDF, accurate to ~10⁻⁷:

N(x) ≈ 1 - n(x)(a₁t + a₂t² + a₃t³ + a₄t⁴ + a₅t⁵)
where t = 1/(1 + px), p = 0.2316419

Implied Volatility Solver

The IV solver finds σ such that BS(σ) = market price. We use:

  1. Newton-Raphson: σₙ₊₁ = σₙ - (BS(σₙ) - P) / Vega(σₙ)
  2. Bisection fallback: If NR diverges or vega too small

Initial guess uses Brenner-Subrahmanyam approximation for ATM options. Convergence tolerance: 10⁻⁶, max iterations: 50 (NR) / 100 (bisection).

Binomial American Pricing (CRR)

Cox-Ross-Rubinstein binomial tree with early exercise:

u = e^(σ√Δt), d = 1/u
p = (e^((r-q)Δt) - d) / (u - d)

V = max(intrinsic, e^(-rΔt)[p·Vᵤ + (1-p)·Vᵈ])

Backward induction from terminal nodes, taking max of continuation value and intrinsic value at each node (early exercise check).

Greeks computed via finite difference bumps (±1% for delta/gamma, etc.).

Put-Call Parity

For European options with dividends:

C - P = S·e^(-qT) - K·e^(-rT)

The parity check compares observed (C - P) against the theoretical value. Deviations may indicate arbitrage opportunities or data quality issues.

Strategy Payoff

Expiry payoff: Sum of intrinsic values minus net premium paid.

Call intrinsic = max(0, S - K)
Put intrinsic = max(0, K - S)
P&L = Σ(position × intrinsic) - net_premium

Scenario P&L: Model-based repricing using BS at various (spot, vol, time) scenarios. The heatmap shows mark-to-model P&L.

Edge Case Handling

  • T → 0: Return intrinsic value, Greeks → 0 or ±1
  • σ → 0: Option → discounted intrinsic value
  • Deep ITM/OTM: d₁, d₂ clamped to avoid CDF overflow
  • IV solver bounds: σ ∈ [10⁻⁶, 5.0] (0.0001% to 500%)

References

  • • Black, F. & Scholes, M. (1973). "The Pricing of Options and Corporate Liabilities"
  • • Cox, J., Ross, S., & Rubinstein, M. (1979). "Option Pricing: A Simplified Approach"
  • • Hull, J. "Options, Futures, and Other Derivatives"
  • • Abramowitz, M. & Stegun, I. "Handbook of Mathematical Functions"