Skip to main content

Monte Carlo Option Pricing for Educational Purposes

Project description

OptionMC: Monte Carlo Option Pricing

PyPI version License: MIT DOI

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.3.tar.gz (16.9 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.3-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: optionmc-0.1.3.tar.gz
  • Upload date:
  • Size: 16.9 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.3.tar.gz
Algorithm Hash digest
SHA256 56bb509cec64c739b8126d21311143c37a083bbdf452d202a0c87c30ecfa6657
MD5 30b4d0dc0f89299caf858e8f91f95f05
BLAKE2b-256 94a6b24aad5d4ffd3a222406eed6d1b588ea1e0e51325a6e557f776a3b5918dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: optionmc-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.4 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e3668256f1b44c0e286afea70df5c011e51451d64755ea357e8a43c7f1ce20b9
MD5 f3d526c4a6aa827a89ac2d2a0b8d4f6a
BLAKE2b-256 8755a5827711c007155baabe0252ab6cec4fa2a8a182ff6efa0abb9f12133368

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