Physics-informed neural networks for pricing PDEs, with analytical, Monte Carlo, and finite-difference reference pricers.
  • Python 97.8%
  • Cuda 1.9%
  • Makefile 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
rylanmalarchick ace4db3b2a
Ship the pde_pricer package, P4 evidence, and a portfolio demo README.
Move the library under src/pde_pricer with a versioned BS checkpoint CLI,
commit reference and held-out reports, and make README tables regenerate
from those JSON files. Quantum stays a measured negative result.

Co-authored-by: Cursor <[email protected]>
2026-08-28 13:30:51 -04:00
.github/workflows p2 2026-08-26 11:45:24 -04:00
artifacts Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
docs Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
notebooks Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
scripts Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
src/pde_pricer Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
tests Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
.gitignore Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
constraints.txt Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
LICENSE Add comprehensive documentation: README, RESULTS tracking, LICENSE 2026-02-02 21:16:35 -05:00
Makefile p2 2026-08-26 11:45:24 -04:00
pyproject.toml Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00
README.md Ship the pde_pricer package, P4 evidence, and a portfolio demo README. 2026-08-28 13:30:51 -04:00

pde-pricer

Physics-informed neural networks for pricing PDEs, with classical reference pricers (closed form, Monte Carlo, finite difference) and a documented negative-result variational-quantum experiment.

Status

The supported slice is a European BlackScholes PINN: versioned checkpoint, installed CLI (pde-pricer train|price|validate), and a committed artifact under artifacts/bs_european_call/. Basket, Heston, Merton, American, barrier, and Dupire PINNs are research-stage. Their reference engines have independent cross-checks; trained-PINN held-out errors are reported as measured, not as market-grade accuracy.

There is no live market feed, web API, or paid data dependency.

Demo

git clone https://code.rylanmalarchick.com/rylanmalarchick/pde-pricer.git
cd pde-pricer
python -m venv .venv
source .venv/bin/activate
pip install -e ".[classical,dev]" -c constraints.txt

make check

pde-pricer validate --checkpoint artifacts/bs_european_call/checkpoint.pt \
  --S-min 70 --S-max 130 --max-mae 0.25 --max-vega-mae 8
pde-pricer price --checkpoint artifacts/bs_european_call/checkpoint.pt \
  --S 100 --t 0 --sigma 0.2 --greeks

python scripts/summarize_artifacts.py

make check is format, lint, typecheck, the default (fast) pytest suite, and a wheel smoke test that the CUDA kernel source is packaged. validate should print a passing grid report matching artifacts/bs_european_call/validation.json. summarize_artifacts.py reprints the tables below from those JSON files.

Results

Tables are generated by python scripts/summarize_artifacts.py. Do not edit them by hand.

European BlackScholes PINN (supported slice)

Artifact Grid Price MAE Rel MAE Vega MAE Pass
artifacts/bs_european_call/ S∈[70,130] (31 pts) 0.072 1.54% 4.36 yes

Reproduce training: see artifacts/bs_european_call/README.md.

Reference engines

Engine Check Max abs error
Heston quadrature vs COS (4 regimes) 4.98e-06
Merton adaptive Poisson tail vs 200-term sum 1.66e-11
Basket pathwise delta vs CRN bump 8.20e-05
Dupire inverse local-vol MAE (valid cells) 0.0146
Dupire reprice MAE 7.33e-04

Regenerate: python scripts/validate_advanced_references.py and python scripts/calibrate_local_vol.py.

Research-stage PINNs (held-out, 3 seeds × 3000 epochs)

PINN Price rel MAE % Delta MAE Residual RMS
heston 5.27 ± 1.11 0.0335 143.76
merton 3.96 ± 1.44 0.0207 0.96
american 45.16 ± 0.00 0.1278 n/a
basket 7.85 ± 2.94 0.0059 0.71

Heston price error is single-digit while the PDE residual stays large. American did not leave the payoff-only initialization (identical metrics across seeds; residual omitted). See artifacts/p4_heldout_reports/.

Quantum ablation (parameter-matched basket)

Arm Params Mean test MAE
quantum hybrid 219 19.83
classical (matched) 219 13.36
paired t p-value 0.44
quantum advantage false

Three seeds, equal budget. The hybrid is retained as a negative result, not a headline. python scripts/ablate_quantum_basket.py (needs the quantum extra).

Models in the tree

Model PDE type Dimension Notes
Black-Scholes PDE 2D Closed form + FD + supported PINN
Basket PDE 6D (5 assets + time) Monte Carlo reference
Merton PIDE 2D Poisson jumps, tail-controlled sum
Heston PDE 3D Stochastic variance; COS cross-check
American Free boundary 2D CRR/PSOR references; PINN research-stage
Barrier PDE 2D Down-and-out and up-and-out closed forms

Install extras

classical (Torch + plotting), quantum (PennyLane), notebook, gpu, dev, all. Core install is NumPy/SciPy only; CPU analytical / MC / FD import without Torch.

# Optional: retrain research-stage PINNs (long; GPU recommended)
python scripts/evaluate_heldout.py --seeds 0 1 2 --epochs 3000 --device cuda

# Optional: other training scripts
python scripts/train_basket.py --epochs 5000 --n_interior 15000 --eval
python scripts/train_merton.py --epochs 3000 --eval
python scripts/train_heston.py --epochs 3000 --eval
python scripts/train_american.py --epochs 3000 --eval
python scripts/train_calibration.py --epochs 2000
pip install -e ".[quantum]" -c constraints.txt
python scripts/train_hybrid.py --epochs 300 --n-qubits 4 --n-layers 2

Project Structure

pde-pricer/
├── src/pde_pricer/
│   ├── cli.py               # pde-pricer train|price|validate
│   ├── checkpoint.py        # versioned European BS checkpoint schema
│   ├── pde/                 # PDE definitions
│   ├── classical/           # PINN architectures
│   ├── quantum/             # VQC integration (experimental)
│   ├── pricing/             # MC, FD, analytical engines
│   │   ├── mc_gpu.py        # CUDA Monte Carlo, pathwise Greeks
│   │   └── csrc/mc_gpu.cu   # fused European and basket kernels
│   ├── data/
│   └── validation/          # Greeks, grids, held-out reports, ablation
├── artifacts/              # committed checkpoints and JSON reports
├── tests/
├── scripts/
├── notebooks/
├── Makefile                 # make check / test-fast / smoke
├── constraints.txt
└── docs/
    ├── theory.md
    └── architecture.md

Mathematical Background

Forward Problem: Multi-Asset Black-Scholes

\frac{\partial V}{\partial t} + \sum_i rS_i\frac{\partial V}{\partial S_i} + \frac{1}{2}\sum_{i,j} \rho_{ij}\sigma_i\sigma_j S_i S_j \frac{\partial^2 V}{\partial S_i \partial S_j} - rV = 0

Inverse Problem: Dupire Calibration

Given market prices C(K,T), recover local volatility \sigma(K,T):

\sigma^2(K,T) = \frac{2\left(\frac{\partial C}{\partial T} + rK\frac{\partial C}{\partial K}\right)}{K^2 \frac{\partial^2 C}{\partial K^2}}

Jump-Diffusion (Merton)

\frac{\partial V}{\partial t} + (r-\lambda\kappa)S\frac{\partial V}{\partial S} + \frac{1}{2}\sigma^2 S^2 \frac{\partial^2 V}{\partial S^2} - rV + \lambda\int_0^\infty [V(SJ,t) - V(S,t)]g(J)dJ = 0

Full derivations: docs/theory.md.

Testing

make check          # format + lint + typecheck + fast tests + wheel smoke
make test-fast      # default suite (not slow/gpu/quantum)
make test-slow      # longer numerical harness
make test-all       # everything except gpu

References

  • Raissi et al. "Physics-informed neural networks" (2019). arXiv:1711.10561
  • Stamatopoulos et al. "Option Pricing using Quantum Computers" (2020). arXiv:1905.02666
  • Dupire. "Pricing with a Smile" (Risk, 1994)
  • Schuld & Petruccione. "Machine Learning with Quantum Computers" (Springer, 2021)

License

MIT License. See LICENSE.