JAX Multi-Asset Basket Option Risk Engine
An automated, high-performance risk-sensitivity engine written in JAX for pricing multi-asset European basket options and extracting exact, full-rank Cross-Gamma matrices via Algorithmic Adjoint Differentiation (AAD).
- Closed-Form Moment-Matching: Replaces computationally expensive Monte Carlo engines with a continuous Milevsky-Posner (2010) Reciprocal Gamma moment-matching model to price basket options across arbitrary dimensions.
- Exact Vector-Valued Sensitivities: Utilizes JAX's reverse-mode automatic differentiation (
jax.gradandjax.hessian) to compute exact Delta vectors and N x N Cross-Gamma matrices without numerical finite difference error. - JIT Compilation & XLA Acceleration: Achieves 100x speedups over classical NumPy/SciPy execution via Accelerated Linear Algebra (XLA) compilation.
- Numerical Stability Benchmarking Suite: Features an automated stress-testing framework comparing JAX AAD against a NumPy Central Finite Difference (CFD) baseline, mapping h-step truncation errors against floating-point cancellation limits.
flowchart LR
S["Input: Asset Vector (S_t)"] --> Engine["Milevsky-Posner Pricing Engine"]
Engine --> Price["Option Price V(S)"]
S --> Grad["jax.grad(V)"]
Grad --> Delta["Delta Vector (Δ)"]
S --> Hessian["jax.hessian(V)"]
Hessian --> Gamma["N x N Cross-Gamma Matrix (Γ)"]
For an
Rather than approximating derivatives via perturbation
| Basket Size ( |
NumPy CFD Price + Hessian (s) | JAX AAD Execution (s) | Speedup Factor |
|---|---|---|---|
| N = 2 | 0.153 s | 0.00029 s | 516x |
| N = 5 | 0.076 s | 0.00001 s | 5,586x |
| N = 10 | 0.385 s | 0.00003 s | 10,655x |
| N = 20 | 1.375 s | 0.00004 s | 31,911x |
| N = 50 | 6.361 s | 0.00010 s | 63,424x |
Central Finite Difference (CFD) requires
| Perturbation Step ( |
Frobenius Error ( |
Failure Mode Observed |
|---|---|---|
| 10⁻¹ | Truncation Error Dominated | |
| 10⁻⁴ | Optimal CFD Window | |
| 10⁻⁸ | Catastrophic Roundoff / Cancellation | |
| 10⁻¹² | Complete Precision Loss / Noise |
git clone https://github.com/Transacttt/JAX-Basket-Option-Risk-Engine.git
cd JAX-Basket-Option-Risk-Engine
pip install -r requirements.txt
python benchmarks.py