Skip to content

Abhinav-Kumar2/options_pricing_model

Repository files navigation

Options Pricing Model + PnL Simulator

Introduction

This project implements a comprehensive options pricing and backtesting framework that supports multiple numerical methods for valuing European and American-style options. Built as a command-line tool, it enables quantitative analysis of options strategies by combining classical financial models with historical market data.

The simulator supports four pricing methodologies: the analytical Black-Scholes model for European options, the Cox-Ross-Rubinstein (CRR) binomial tree for American options, trinomial lattices for enhanced accuracy, and Monte Carlo simulation with Longstaff-Schwartz for path-dependent valuation. Users can backtest trading strategies across different time periods, analyze profit and loss dynamics, and visualize results through integrated plotting capabilities.

Key features include flexible position management (long/short), configurable contract sizes, custom execution dates, and comprehensive logging for reproducible analysis.

Files of interest

Installation

# Clone this repository
git clone https://github.com/Abhinav-Kumar2/options_pricing_model.git

# Create a virtual environment
python -m venv venv
source venv/bin/activate 

# Install dependencies
pip install -r libraries.txt

Quick usage

Basic command pattern: python main.py --ticker --option_type <call|put> --strike strike_price --start YYYY-MM-DD --end YYYY-MM-DD --expiry_days [options]

Common options

  • --pricing_model {black_scholes,binomial,trinomial,monte_carlo} (default: black_scholes) — see cli.py
  • --steps N — number of steps for binomial/trinomial (and LSM time steps)
  • --simulations N — Monte Carlo simulations (monte_carlo)
  • --american — enable American option logic (binomial/trinomial/monte_carlo LSM)
  • --position {long,short}, --contracts N, --execution_date YYYY-MM-DD

Examples (one command per model)

  • Black‑Scholes (default):

    python main.py --ticker AAPL --option_type call --strike 150 --start 2023-01-01 --end 2024-01-01 --expiry_days 30 --position long --contracts 1 --execution_date 2023-01-10 --pricing_model black_scholes

  • Binomial (CRR)

    python main.py --ticker AAPL --option_type put --strike 150 --start 2023-01-01 --end 2024-01-01 --expiry_days 60 --position short -contracts 1 --execution_date 2023-01-10 --pricing_model binomial --steps 500 --american

  • Trinomial

    python main.py --ticker AAPL --option_type put --strike 150 --start 2023-01-01 --end 2024-01-01 --expiry_days 60 --position short --contracts 1 --execution_date 2023-01-10 --pricing_model trinomial --steps 500 --american

  • Monte Carlo (European)

    python main.py --ticker AAPL --option_type call --strike 150 --start 2023-01-01 --end 2024-01-01 --expiry_days 30 --position short --contracts 1 --execution_date 2023-01-10 --pricing_model monte_carlo --simulations 200000

  • Monte Carlo (American — LSM)

    python main.py --ticker AAPL --option_type put --strike 150 --start 2023-01-01 --end 2024-01-01 --expiry_days 120 --position short --contracts 1 --execution_date 2023-01-10 --pricing_model monte_carlo --american --simulations 100000 --steps 252

Plots

alt text

Output

Notes

  • If you pass --execution_date, PnL calculation starts from the first date >= execution_date (see backtesting/backtester.py).
  • For Monte Carlo, increase --simulations to reduce noise; for American options set --american.

License

MIT

About

Options Pricing Model based on Black-Scholes, Binomial, Trinomial and Monte Carlo along with a PnL Simulator.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages