Skip to main content

Monte Carlo Option Pricing with Educational Visualizations

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.2.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.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: optionmc-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4d5d4ff555e26e1565315963b3ebff13e870219c47839e316018ce4d2ef703c7
MD5 5d90d7a7119cffe37923e939da26fca9
BLAKE2b-256 15d486223ce35e14a5d08167e42b44c9f9163f88f2ea4d4f38b828893febf21d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: optionmc-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c6d91414b736b6e226b04da044b59adff0cc821c7f2780af734fd9179a2ce12
MD5 1533b032b887ddc057b84a3dfe90e6f6
BLAKE2b-256 2e038dedaf7722241bb1888e393c216c4edbf36b057c80e5eda65575402ba361

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