A mesh-free deep learning framework for solving Black-Scholes type PDEs with applications to option pricing, stochastic volatility, and high-dimensional basket options.
Traditional numerical methods for option pricing (finite difference, finite elements) suffer from the curse of dimensionality - memory and computation scale exponentially with the number of underlying assets. FINN solves this by embedding the governing PDE directly into a neural network loss function, achieving O(1) memory complexity regardless of dimension.
Key Results:
- 5D basket option: FD needs 74.5 GB → FINN needs 0.3 MB (247,000× improvement)
- 10D basket option: FD is impossible → FINN works seamlessly
- Inverse calibration: Recovers volatility with 0.05% error
-
Fourier Feature Networks (
finn_fourier.py)- Random Fourier feature encoding for better high-frequency learning
- Adaptive activation functions with learnable scaling
-
Deep BSDE Comparison (
deep_bsde.py)- First systematic comparison: FINN vs Deep BSDE for Black-Scholes
-
High-Dimensional Scaling (
finn_high_dim.py)- Dimension-agnostic architecture supporting 5D, 10D, 20D+ baskets
- Residual connections and layer normalization for stability
-
Heston Stochastic Volatility (
finn_heston.py)- 2D PDE solver for stochastic variance models
- Validated against semi-analytical characteristic function method
black_scholes_finn/
├── src/ # Core modules
│ ├── finn.py # 1D Black-Scholes FINN
│ ├── finn_2d.py # 2D basket option
│ ├── finn_fourier.py # Fourier feature networks
│ ├── finn_heston.py # Heston stochastic volatility
│ ├── finn_high_dim.py # N-dimensional scaling
│ ├── finn_extreme_high_dim.py # 50D/100D with sparse attention
│ ├── deep_bsde.py # Deep BSDE baseline
│ ├── inverse_calibration.py # Volatility calibration
│ ├── analytical.py # Black-Scholes formulas
│ ├── finite_difference.py # Crank-Nicolson solver
│ └── monte_carlo.py # MC simulation
├── notebooks/
│ ├── 01_analytical_solution.ipynb # Verify formulas
│ ├── 02_pinn_training.ipynb # Train 1D FINN
│ ├── 03_convergence_analysis.ipynb # Convergence studies
│ ├── 04_method_comparison.ipynb # FINN vs FD vs MC
│ ├── 05_results_visualization.ipynb # Generate figures
│ ├── 06_2d_basket_option.ipynb # 2D basket with correlation
│ ├── 07_inverse_calibration.ipynb # Learn σ from prices
│ ├── 08_heston_stochastic_vol.ipynb # Heston model
│ ├── 09_novel_architectures.ipynb # FourierFINN vs DeepBSDE
│ ├── 10_high_dim_scaling.ipynb # 5D, 10D experiments
│ └── 11_extreme_high_dim.ipynb # Dimension scaling analysis
├── figures/ # Generated plots
├── results/ # Saved models
└── requirements.txt
git clone <repo-url>
cd black_scholes_finn
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtimport torch
from src.finn import BlackScholesFINN
from src.training import train_finn
# Create model
model = BlackScholesFINN(K=100, r=0.05, sigma=0.2, T=1.0, S_max=200)
# Train
result = train_finn(model, n_collocation=5000, adam_epochs=5000)
# Price an option
S = torch.tensor([[100.0]])
t = torch.tensor([[0.0]])
price = model(S, t)
print(f"Option price: {price.item():.4f}")No grid required. FINN samples random collocation points and enforces the PDE everywhere through automatic differentiation.
L = λ_pde·||PDE residual||² + λ_ic·||terminal condition||² + λ_bc·||boundary||²
Supports Apple Silicon (MPS), NVIDIA CUDA, and CPU. Automatic device selection:
device = torch.device('mps' if torch.backends.mps.is_available()
else ('cuda' if torch.cuda.is_available() else 'cpu'))| Model | Error | Training Time | Notes |
|---|---|---|---|
| 1D European | 0.21% L2 | 3-4 min | vs analytical |
| 2D Basket | 0.14 MAE | 10-15 min | vs Monte Carlo |
| Inverse Calibration | 0.05% σ | 2-3 min | 21 options |
| 5D Basket | ~0.5 MAE | 15-20 min | vs Monte Carlo |
| Heston | 0.08% | 5-8 min | vs semi-analytical |
jupyter notebook
# Run notebooks 01-10 in order
# Total time: ~45-60 min (first run) or ~10 min (with saved models)- Python 3.10+
- PyTorch 2.0+
- NumPy, SciPy, Matplotlib
- Jupyter
If you use this code in your research:
@software{finn2024,
title={FINN: Finance-Informed Neural Networks for Option Pricing},
author={Mangroliya Vaibhav},
year={2025},
url={https://github.com/Vaibhavkkm/finn-option-pricing}
}MIT License
- Course: Advanced Discretization Methods
- Framework inspired by Physics-Informed Neural Networks (Raissi et al., 2019)