Skip to main content

Monte Carlo Option Pricing with Educational Visualizations

Project description

OptionMC: Monte Carlo Option Pricing

PyPI version License: MIT

A Python package for pricing European options using Monte Carlo simulation, featuring variance reduction techniques and educational visualizations.

Features

  • European call and put option pricing with Monte Carlo simulation
  • Variance reduction using antithetic variates
  • Comparison with Black-Scholes analytical solutions
  • Publication-quality visualizations:
    • Price convergence analysis
    • Stock price and payoff distributions
    • Parameter sensitivity analysis
  • Command-line interface for quick pricing
  • Comprehensive examples for educational purposes

Installation

pip install optionmc

Quick Start

from optionmc.models import OptionPricing

# Create option pricing model
model = OptionPricing(
    S0=100,     # Initial stock price
    E=100,      # Strike price
    T=1.0,      # Time to maturity (1 year)
    rf=0.05,    # Risk-free rate (5%)
    sigma=0.2,  # Volatility (20%)
    iterations=100000  # Number of simulations
)

# Calculate option prices
call_price = model.call_option_simulation()
put_price = model.put_option_simulation()

# Get analytical solutions for comparison
bs_call, bs_put = model.bs_analytical_price()

# Print results
print(f"Call Option Price: ${call_price:.4f} (Black-Scholes: ${bs_call:.4f})")
print(f"Put Option Price: ${put_price:.4f} (Black-Scholes: ${bs_put:.4f})")

Command Line Usage

# Basic option pricing
optionmc price --s0 100 --strike 95 --volatility 0.25 --time 0.5

# Using antithetic variates for variance reduction
optionmc price --method antithetic --iterations 500000

Example Visualizations

OptionMC generates publication-quality visualizations:

  • Convergence analysis showing how Monte Carlo estimates approach analytical solutions
  • Stock price and payoff distributions for both call and put options
  • Sensitivity analysis for parameters like volatility and time to maturity

Documentation

For detailed usage examples, see the examples/ directory:

  1. Basic Option Pricing - Core functionality demonstration
  2. Variance Reduction - Comparison of standard MC vs. antithetic variates
  3. Parameter Sensitivity - Analysis of how option prices respond to parameter changes
  4. Moneyness Analysis - Exploring pricing accuracy for different strike prices

Mathematical Background

OptionMC implements the standard Monte Carlo approach for option pricing:

  1. Simulate stock price paths using Geometric Brownian Motion
  2. Calculate option payoffs at maturity
  3. Average the discounted payoffs to get the option price

For European options, the payoff functions are:

  • Call option: max(S - K, 0)
  • Put option: max(K - S, 0)

Where S is the stock price at maturity and K is the strike price.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Sandy Herho (sandy.herho@email.ucr.edu)

Citation

If you use this package in your research, please cite it as:

Herho, S. (2025). OptionMC: A Python package for Monte Carlo option pricing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optionmc-0.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optionmc-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file optionmc-0.1.0.tar.gz.

File metadata

  • Download URL: optionmc-0.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for optionmc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c4b38c37d0dfa1b8285a510151228d2302389dbb6bdb023bef3c66a6bb688b7
MD5 387ae91a81d9ff69c7f669d03d46a726
BLAKE2b-256 0fe545284a9d0e9401d23b69f4ec75e98881cbc6d6b4a17d61a8096ed0041213

See more details on using hashes here.

File details

Details for the file optionmc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: optionmc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for optionmc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f75ceae56658f8583f2fe285eb38ecbc98938ed871fda52e77e5430d3b0b780a
MD5 7aa5bb1c6bd3d4faa68cfb224a157c9e
BLAKE2b-256 b479ec65331ff714c8ac6c3656e9b7af732b78dfba9b276e82eca77a114b05b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page