Skip to content

Latest commit

 

History

History
102 lines (75 loc) · 3.37 KB

File metadata and controls

102 lines (75 loc) · 3.37 KB

Monte Carlo Option Pricing Simulator

License: MIT Python 3.8+

A professional-grade financial simulator for pricing European Call and Put options using Monte Carlo Methods and Geometric Brownian Motion (GBM). This tool compares stochastic simulations with the analytical Black-Scholes-Merton model, providing visual insights into option pricing dynamics.


📊 Simulation Workflow

The following diagram illustrates the Monte Carlo simulation process implemented in this project:

graph TD
    A[Start: Input Parameters] --> B[Generate N Random Paths]
    B --> C{Geometric Brownian Motion}
    C --> D[Calculate Stock Price at Maturity S_T]
    D --> E[Compute Option Payoff: max(S_T - K, 0)]
    E --> F[Average Payoffs over N Simulations]
    F --> G[Discount to Present Value using e^-rT]
    G --> H[Final Monte Carlo Price]
    H --> I[Compare with Black-Scholes Price]
    I --> J[Visualize Results]
Loading

🧠 Mathematical Foundation

1. Geometric Brownian Motion (GBM)

We model the underlying asset price $S_t$ using the stochastic differential equation (SDE): $$ dS_t = \mu S_t dt + \sigma S_t dW_t $$

The solution to this SDE gives the terminal stock price at time $T$: $$ S_T = S_0 \exp \left( (r - \frac{1}{2}\sigma^2)T + \sigma \sqrt{T} Z \right) $$

Where:

  • $S_T$: Terminal stock price
  • $S_0$: Initial stock price
  • $r$: Risk-free interest rate
  • $\sigma$: Volatility of the underlying asset
  • $Z$: Standard normal random variable $\sim N(0,1)$
  • $T$: Time to maturity (years)

2. Monte Carlo Option Pricing

The fair price of an option is the discounted expected value of its future payoff under the risk-neutral measure: $$ V_0 = e^{-rT} \mathbb{E}^{\mathbb{Q}} [ \text{Payoff}(S_T) ] $$

For a European Call: $\text{Payoff} = \max(S_T - K, 0)$
For a European Put: $\text{Payoff} = \max(K - S_T, 0)$

3. Black-Scholes Analytical Model

To validate our simulation, we use the Black-Scholes-Merton formula: $$ C = S_0 N(d_1) - K e^{-rT} N(d_2) $$ $$ P = K e^{-rT} N(-d_2) - S_0 N(-d_1) $$

With the components defined as: $$ d_1 = \frac{\ln(S_0/K) + (r + \frac{1}{2}\sigma^2)T}{\sigma\sqrt{T}} $$ $$ d_2 = d_1 - \sigma\sqrt{T} $$


🚀 Features

  • High-Performance Simulation: Efficient path generation using NumPy.
  • Analytical Comparison: Real-time validation against Black-Scholes.
  • Dynamic Visualization: Animated plots showing convergence and price distribution.
  • Themed UI: Professional dark-mode aesthetics for financial reporting.

🛠️ Installation & Usage

  1. Clone the Repository:

    git clone https://github.com/vsrupeshkumar/Binomial-Tree-Pricing.git
    cd Binomial-Tree-Pricing
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run Simulator:

    python main.py

📁 Project Structure

  • main.py: Core logic for simulation execution and plotting.
  • utils.py: Mathematical utility functions (GBM, BS-formulas).
  • requirements.txt: Necessary libraries (NumPy, Matplotlib, SciPy).

⚖️ License

Distributed under the MIT License. See LICENSE for more information.

Developer: vsrupeshkumar