Skip to content

jay-odedra/option-pricing-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Differentiable Option Pricing with JAX and PyTorch

This project explores several approaches to pricing European options, starting from the analytical Black-Scholes model and progressing to Monte Carlo simulation and neural network surrogates.

The aim was to build a compact project that combines quantitative finance, differentiable programming, numerical methods, and modern machine learning tools.


Overview

The project is organised as a sequence of notebooks that gradually build in complexity:

  • Implement the Black-Scholes model and analytical Greeks
  • Reimplement the model in JAX and compute Greeks using automatic differentiation
  • Price options using Monte Carlo simulation
  • Train a neural network to learn the pricing function
  • Recover Greeks directly from the trained neural network using PyTorch Autograd

Notebooks

01 - Black-Scholes Baseline

  • Implement European call and put pricing
  • Compute analytical Delta, Gamma, and Vega
  • Verify put-call parity
  • Visualise option prices and Greeks

02 - JAX Autodiff Greeks

  • Reimplement Black-Scholes in JAX
  • Compute Greeks using jax.grad
  • Vectorise calculations using vmap
  • Accelerate computation using jit
  • Compare analytical and autodiff Greeks

03 - JAX Monte Carlo Pricing

  • Simulate terminal stock prices under Geometric Brownian Motion
  • Estimate option prices using Monte Carlo simulation
  • Compare Monte Carlo prices against Black-Scholes
  • Study convergence as the number of paths increases
  • Benchmark JIT performance

04 - PyTorch Neural Surrogate

  • Generate a synthetic option pricing dataset
  • Train a neural network to approximate the Black-Scholes pricing function
  • Evaluate predictive performance on unseen data
  • Analyse prediction errors and model behaviour

05 - Neural Greeks

  • Compute Delta, Gamma, and Vega using PyTorch Autograd
  • Compare neural and analytical Greeks
  • Analyse error distributions
  • Investigate performance in high-Gamma regions

Main Results

  • JAX autodiff Greeks matched analytical Black-Scholes Greeks to numerical precision
  • JIT compilation provided significant performance improvements for large computations
  • Monte Carlo estimates converged towards analytical Black-Scholes prices
  • The neural network learned the pricing surface with low prediction error
  • Neural Delta and Vega closely matched analytical sensitivities
  • Gamma proved more challenging, particularly for at-the-money options near expiry

Technologies

  • Python
  • NumPy
  • SciPy
  • Pandas
  • Matplotlib
  • JAX
  • PyTorch
  • Scikit-Learn

Future Extensions

Possible extensions include:

  • Joint training on prices and Greeks
  • Physics-Informed Neural Networks (PINNs)
  • Heston stochastic volatility models
  • Implied volatility calibration
  • Volatility surface modelling
  • Real option-chain data

Built as a practical exploration of quantitative finance, automatic differentiation, and machine learning for option pricing.

About

Option pricing and neural surrogates with JAX and PyTorch: Black-Scholes, autodiff Greeks, Monte Carlo simulation, and neural Greeks via autograd.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors