Monte Carlo Option Pricing with Educational Visualizations
Project description
OptionMC: Monte Carlo Option Pricing
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:
- Basic Option Pricing - Core functionality demonstration
- Variance Reduction - Comparison of standard MC vs. antithetic variates
- Parameter Sensitivity - Analysis of how option prices respond to parameter changes
- Moneyness Analysis - Exploring pricing accuracy for different strike prices
Mathematical Background
OptionMC implements the standard Monte Carlo approach for option pricing:
- Simulate stock price paths using Geometric Brownian Motion
- Calculate option payoffs at maturity
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4b38c37d0dfa1b8285a510151228d2302389dbb6bdb023bef3c66a6bb688b7
|
|
| MD5 |
387ae91a81d9ff69c7f669d03d46a726
|
|
| BLAKE2b-256 |
0fe545284a9d0e9401d23b69f4ec75e98881cbc6d6b4a17d61a8096ed0041213
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f75ceae56658f8583f2fe285eb38ecbc98938ed871fda52e77e5430d3b0b780a
|
|
| MD5 |
7aa5bb1c6bd3d4faa68cfb224a157c9e
|
|
| BLAKE2b-256 |
b479ec65331ff714c8ac6c3656e9b7af732b78dfba9b276e82eca77a114b05b7
|