comp_methods is a Python library dedicated to computational methods for pricing financial derivatives, specifically focusing on American Options. It implements various numerical techniques such as Binomial Trees and Finite Difference Methods.
- Binomial Tree Model: Cox-Ross-Rubinstein (CRR) implementation for American and European options.
- Finite Difference Methods:
- Explicit Method
- Implicit Method
- Crank-Nicolson Method
- Greeks Calculation: Tools to compute Delta, Gamma, Theta, etc.
- Visualization: Utilities for plotting convergence and option price surfaces.
To use this library, clone the repository and install the required dependencies:
git clone https://github.com/yourusername/American_Options.git
cd American_Options
pip install -r requirements.txtHere is a simple example of how to price an American Put option using the Binomial Tree method:
from comp_methods import BinomialTree
# Parameters: S0, K, T, r, sigma, N
S0 = 100 # Initial stock price
K = 100 # Strike price
T = 1.0 # Time to maturity (1 year)
r = 0.05 # Risk-free rate
sigma = 0.2 # Volatility
N = 100 # Number of time steps
model = BinomialTree(S0, K, T, r, sigma, N, option_type='put', style='american')
price = model.price()
print(f"American Put Option Price: {price:.4f}")comp_methods/: Main package containing the implementations.tests/: Unit tests for the algorithms.notebooks/: Jupyter notebooks with examples and analysis.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.