Research-grade, reproducible code for pricing and hedging high-dimensional American basket options. Baselines include LSMC under correlated GBM and a paper-faithful two-head RNN-BSDE; we extend to correlated Heston with a learned stock driver (α) to improve hedging in incomplete markets.
- Two paradigms, one repo
- LSMC (Longstaff–Schwartz) for a transparent Monte-Carlo baseline.
- Deep RNN-BSDE (two heads: price Y, delta Δ) for scalable pricing & greeks along the time grid.
- Correlated Heston extension: adds a third head to learn the stock Brownian driver α and converts it to shares for hedging when delta alone is insufficient.
- Calibration → Training pipeline: helpers to fit per-asset Heston parameters + cross-asset correlation; exported as CSV for training.
- Hedging focus: daily P&L attribution (gamma/theta drift vs realized variance, vega/vanna terms, financing/borrow) and delta-hedge evaluation on simulated paths.
- Reproducible: deterministic seeds, minimal dependencies, CPU-friendly defaults (GPU optional).
american-basket-option/
├─ data/ # Model checkpoints & calibrated CSVs (gitignored)
├─ heston_calib/ # Heston calibration helpers + scripts
├─ results_notebook/ # Result exploration / plotting utilities
├─ heston_calibrator_top30.py
├─ longstaff_schwartz.py # LSMC baseline
├─ gbm_rnn_model.py # GBM RNN-BSDE (price + delta)
├─ heston_rnn_model.py # Heston RNN-BSDE (price + delta + alpha)
├─ __init__.py
├─ README.md
└─ license
Tested with Python 3.10+.
# (Recommended) Create an isolated environment
python -m venv .venv
# macOS/Linux
source .venv/bin/activate
# Windows
# .venv\Scripts\activate
# Core scientific stack
pip install numpy pandas matplotlib scikit-learn torch tqdmTip: On CPU, start with modest path counts (e.g.,
n_paths=5_000) for quick runs, then scale.
python longstaff_schwartz.pyOutputs an American price via polynomial regression on simulated correlated GBM paths.
python rnn_model.py- Price head (Y) learns continuation.
- Delta head (Δ) learns the BSDE driver term (paper-style).
- Training tricks: batch-mean look-ahead labels, mild terminal smoothing, optional sequence reversal for stability.
python heston_rnn_model.py- Heads: price, delta (aux), and α (stock driver).
- Inputs per step: ([S_n, \sqrt{v_n}, g(S_n)]) with
g= signed moneyness feature for the basket payoff. - α labels: ridge/OLS of discounted continuation increments on standardized stock shocks.
- Hedging: in the continuation region, map learned α → shares; at exercise, use payoff gradient.
Console prints include estimates for (Y_0), average (\Delta_0), average (\alpha_0), and a suggested hedge vector.
Place CSVs in data/:
-
heston_parameters.csvwith columns:Ticker,Spot_Price,v0,kappa,theta,sigma,rho -
heston_correlation_matrix.csv— a symmetric (d \times d) matrix (ones on diagonal).
If your scripts produce different filenames, adjust the constants/paths in heston_rnn_model.py.