Skip to content

sricursion/mc-option

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Option Pricer

A lightweight Python Monte Carlo engine for vanilla European options. It simulates geometric Brownian motion paths with optional variance reduction and provides pricing, confidence intervals, and delta estimation.

Features

  • Vectorized GBM simulation with configurable paths/steps.
  • Variance reduction: antithetic variates and control variate using the known expectation of (S_T).
  • Pricing returns estimate, standard error, and 95% confidence interval.
  • Delta via bump-and-revalue for robustness.
  • Black-Scholes closed form for validation.
  • Tests covering price accuracy, deterministic zero-vol edge case, and delta sanity.

Installation

pip install -r requirements.txt

(Requires Python 3.10+ and NumPy.)

Quickstart

python monte_carlo_option_pricing.py

Example:

from mc_pricing import MonteCarloPricer, OptionSpec, black_scholes_price

spec = OptionSpec(
    spot=100.0,
    strike=100.0,
    rate=0.05,
    vol=0.2,
    maturity=1.0,
    is_call=True,
)

pricer = MonteCarloPricer(
    spec,
    n_paths=50_000,
    n_steps=50,
    antithetic=True,
    control_variate=True,
    seed=123,
)

price, std_err, ci = pricer.price()
print(f"MC price: {price:.4f} (SE={std_err:.4f}) CI={ci}")
print(f"Black-Scholes: {black_scholes_price(spec):.4f}")
print(f"Delta (MC bump): {pricer.delta():.4f}")

Running Tests

pytest -q

Project Structure

  • mc_pricing/pricer.py: Core Monte Carlo pricer, option spec, Black-Scholes helper.
  • monte_carlo_option_pricing.py: CLI example.
  • examples/monte_carlo_demo.ipynb: Notebook demo.
  • tests/: Unit tests for price accuracy and Greeks.

Notes

  • Set seed for reproducibility.
  • n_paths and n_steps trade off precision vs runtime; more paths tighten the CI.
  • control_variate can materially reduce variance for vanilla European payoffs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages