A Monte Carlo option pricing engine with path simulation written in Rust and a Python interface for pricing, Greeks, and visualization.
Built as a learning project to explore the intersection of quantitative finance and systems programming.
- Path simulation in Rust – fast, parallelized Monte Carlo simulation using Geometric Brownian Motion
- European Call & Put pricing – with discounted payoff averaging
- Greeks – Delta and Gamma via central finite differences
- Black-Scholes validation – analytical benchmark to verify MC results
- Visualizations – simulated paths, end-price distribution, payoff distribution, Delta curve
- Benchmark – 16x speedup over pure Python (using 4 threads, Rayon)
mc-option-pricing/
├── src/
│ └── lib.rs # Rust: Path simulation (PyO3 + Rayon)
├── mc_option_pricing/
│ ├── pricing.py # European Call & Put pricing
│ ├── black_scholes.py # Analytical Black-Scholes formulas
│ ├── greeks.py # Delta & Gamma via finite differences
│ └── python_sim.py # Pure Python simulation (benchmark baseline)
├── notebooks/
│ └── demo.ipynb # Visualizations & examples
├── Cargo.toml
└── pyproject.toml
Stock prices are simulated using GBM:
where
The fair price of a European Call option is the discounted expected payoff under the risk-neutral measure:
Requirements: Python 3.8+, Rust toolchain
# Clone the repository
git clone https://github.com/NiklasK3R/mc-option-pricing.git
cd mc-option-pricing
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt
# Compile Rust extension and install package
maturin develop# Price an at-the-money call option
python -m mc_option_pricing
# Custom parameters
python -m mc_option_pricing --start 100 --strike 110 --sigma 0.3 --maturity 0.5 --type both
# All options
python -m mc_option_pricing --helpAt-the-money call option (S=100, K=100, r=5%, σ=20%, T=1yr):
| Method | Price |
|---|---|
| Black-Scholes | 10.4506 |
| Monte Carlo | 10.4281 |
| Difference | 0.0225 |
- Rust – path simulation engine
- PyO3 – Rust/Python bindings
- Rayon – data parallelism in Rust
- maturin – build system for Rust Python extensions
- Python – pricing logic, Greeks, visualization
- matplotlib / numpy – plots and numerical utilities
MIT