A Python-based options pricing tool that uses Monte Carlo simulation to estimate European call and put option prices, validates them against the Black-Scholes analytical model, and computes the full suite of Options Greeks — all visualized through an interactive dark-themed chart.
Monte Carlo methods use repeated random sampling to estimate numerical results that are deterministic in principle but too complex to solve analytically in practice. In the context of options pricing:
- The underlying stock price is modelled as a Geometric Brownian Motion (GBM):
- Thousands of possible future price paths are simulated by discretising the SDE above.
- At expiration, the payoff of each path is calculated:
-
Call:
$\max(S_T - K, , 0)$ -
Put:
$\max(K - S_T, , 0)$
-
Call:
- The option price is the discounted average of all simulated payoffs:
Where:
| Symbol | Definition |
|---|---|
| Stock price at time |
|
| Drift (expected return) of the stock | |
| Volatility (annualised standard deviation of log-returns) | |
| Increment of a Wiener process (Brownian motion) | |
| Simulated stock price at expiry for the |
|
| Strike price of the option | |
| Risk-free interest rate (annualised, continuously compounded) | |
| Time to maturity (in years) | |
| Total number of simulated paths | |
| Discount factor to bring future payoffs to present value |
Monte Carlo is especially powerful because it scales to exotic options and multi-asset derivatives where closed-form solutions do not exist.
The Black-Scholes-Merton (BSM) model provides an analytical (closed-form) solution for European option prices under specific assumptions:
| Assumption | Description |
|---|---|
| Log-normal prices | Stock prices follow a GBM |
| Constant volatility |
|
| No dividends | The underlying pays no dividends |
| Risk-free rate | A constant, known, risk-free interest rate |
| No arbitrage | Markets are frictionless and efficient |
The closed-form pricing formulas are:
Where:
| Symbol | Definition |
|---|---|
| Call option price | |
| Put option price | |
| Current stock (spot) price | |
| Strike price | |
| Risk-free interest rate | |
| Volatility | |
| Time to maturity | |
| Cumulative distribution function (CDF) of the standard normal distribution | |
| Intermediate variables that capture the moneyness, time, volatility, and rate | |
| Discount factor |
This project uses the BSM price as a benchmark to validate the accuracy of the Monte Carlo estimates.
Greeks measure the sensitivity of an option's price to changes in underlying parameters. This simulator computes the following:
| Greek | Symbol | Measures Sensitivity To | Formula (Call) |
|---|---|---|---|
| Delta | Underlying price | ||
| Gamma | Delta's rate of change | ||
| Vega | Volatility (per 1%) | ||
| Theta | Time decay (per day) |
|
|
| Rho | Risk-free rate (per 1%) |
The simulator prompts for the following parameters at runtime. Press Enter to accept the default value.
| Symbol | Parameter | Description | Default | Unit |
|---|---|---|---|---|
S0 |
Stock Price | Current spot price of the underlying asset | 100.0 |
Currency (e.g. USD) |
K |
Strike Price | Price at which the option can be exercised | 100.0 |
Currency |
σ |
Volatility | Annualised standard deviation of the asset's log-returns | 0.20 |
Decimal (20%) |
r |
Risk-Free Rate | Annualised continuously-compounded risk-free interest rate | 0.05 |
Decimal (5%) |
T |
Time to Maturity | Remaining life of the option | 1.0 |
Years |
| — | Time Steps | Number of discrete intervals to divide T into for path simulation |
252 |
Count (≈ trading days/year) |
| — | Simulations | Number of random GBM paths to generate | 10000 |
Count |
Tip: The default values represent a typical at-the-money (ATM) European option scenario. Increase the number of simulations for higher accuracy at the cost of longer runtime.
┌─────────────────────────────────────────────────────────────────┐
│ 1. USER INPUT │
│ Collect parameters with sensible defaults: │
│ S0, K, σ, r, T, time steps, number of simulations │
├─────────────────────────────────────────────────────────────────┤
│ 2. GBM PATH SIMULATION (utils.simulate_gbm_paths) │
│ Generate N vectorised stock-price paths via GBM │
│ using cumulative log-returns for performance │
├─────────────────────────────────────────────────────────────────┤
│ 3. MONTE CARLO PRICING (utils.monte_carlo_price) │
│ Compute discounted average payoff across all paths │
│ → MC Call Price, MC Put Price │
├─────────────────────────────────────────────────────────────────┤
│ 4. BLACK-SCHOLES PRICING (utils.black_scholes) │
│ Analytical closed-form solution as benchmark │
│ → BS Call Price, BS Put Price │
├─────────────────────────────────────────────────────────────────┤
│ 5. GREEKS COMPUTATION (utils.compute_greeks) │
│ Δ (Delta), Γ (Gamma), ν (Vega), Θ (Theta), ρ (Rho) │
│ for both call and put options │
├─────────────────────────────────────────────────────────────────┤
│ 6. CONSOLE OUTPUT │
│ Formatted comparison table: MC vs BS prices + Greeks │
├─────────────────────────────────────────────────────────────────┤
│ 7. VISUALIZATION │
│ Dark-themed matplotlib chart with: │
│ • 50 sample GBM paths │
│ • Strike & spot price reference lines │
│ • Parameter, price comparison & Greeks annotation boxes │
└─────────────────────────────────────────────────────────────────┘
monte-carlo-options-pricing-simulator/
├── main.py # Entry point — orchestrates input, simulation, output & plot
├── utils.py # Core math — GBM simulation, BS pricing, MC pricing, Greeks
├── requirements.txt # Python dependencies
└── README.md # Project Documentation
- Python 3.8+ (tested on 3.10+)
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/drunktrader/monte-carlo-options-pricing-simulator.git cd monte-carlo-options-pricing-simulator -
Create a virtual environment (recommended)
python -m venv venv # Windows venv\Scripts\activate # macOS / Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
python main.pyYou will be prompted to enter option parameters. Press Enter to accept the default values shown in brackets:
Stock Price (S0) [100.0] :
Strike Price (K) [100.0] :
Volatility (sigma) [0.20] :
Risk-Free Rate (r) [0.05] :
Time to Maturity (T) [1.0] :
Number of Time Steps [252] :
Number of Simulations [10000] :
============================================================
Option Price Comparison:
Method Call Price Put Price
Monte Carlo 10.438291 5.563102
Black-Scholes 10.450584 5.573526
Call Price Difference (MC - BS): -0.0123
Put Price Difference (MC - BS): -0.0104
============================================================
Options Greeks (Black-Scholes):
Delta (Call): 0.6368
Delta (Put): -0.3632
Gamma: 0.0188
Vega: 0.3752
Theta (Call): -0.0174 (per day)
Theta (Put): -0.0041 (per day)
Rho (Call): 0.5323
Rho (Put): -0.4189
============================================================
A matplotlib window will then display 50 sample GBM paths with annotated pricing and Greeks information.
| Package | Purpose |
|---|---|
numpy |
Vectorised numerical computation & random number generation |
scipy |
Normal distribution CDF/PDF for Black-Scholes & Greeks |
matplotlib |
Dark-themed stock price path visualization |
This project is open-source. Feel free to use, modify, and distribute.