multi-method-bs-pricing
A Python package for pricing European and American options via the Black-Scholes equations using five independent methods: analytic (Black-Scholes formulas), binomial tree, Monte Carlo, finite differences, and a physics-informed neural network. Each method supports continuous dividend yield and computation of the Greeks.
Installation
pip install multi-method-bs-pricing
The PINN pricer requires TensorFlow, which is an optional extra:
pip install "multi-method-bs-pricing[pinn]"
Example
from bspricepal import Option, analytic_bs_pricer, binomial_pricer, mc_pricer, fd_pricer
option = Option(
S0=100.0, # spot
K=105.0, # strike
T=1.0, # years to expiry
r=0.05, # risk-free rate
sigma=0.2, # volatility
div_yield=0.0,
option_type="call", # "call" | "put"
exercise="european", # "european" | "american"
)
print(analytic_bs_pricer(option))
print(binomial_pricer(option, n_steps=500))
print(mc_pricer(option, n_paths=100000, n_steps=100))
print(fd_pricer(option, n_space=400, n_steps=400))
Greeks
Exact solution for European options:
from bspricepal import analytic_bs_greeks
print(analytic_bs_greeks(option))
Finite difference approximation for any pricer, particularly for American options:
from bspricepal import all_greeks, delta, binomial_pricer
print(all_greeks(binomial_pricer, option, n_steps=500))
print(delta(binomial_pricer, option, h=1e-2, n_steps=500))
Individual Greeks available: delta, gamma, vega, rho, theta.
API
| Function | Notes |
|---|---|
analytic_bs_pricer(option) |
Closed form; European only |
analytic_bs_greeks(option) |
Closed form; European only |
binomial_pricer(option, n_steps=10) |
Binomial tree; European and American |
mc_pricer(option, n_paths, n_steps=10, rng=None) |
Monte Carlo; European and American (Longstaff-Schwartz) |
fd_pricer(option, n_space, n_steps, xmin=-3, xmax=3) |
Finite difference; European and American (PSOR) |
pinn_pricer(option, **kwargs) |
Physics-informed neural network: European and American |
all_greeks(pricer, option, **kwargs) |
Finite-difference Greeks for any pricer |
Release files for multi-method-bs-pricing 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multi_method_bs_pricing-0.1.0.tar.gz | 154.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multi_method_bs_pricing-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 165.7 kB
Release files / multi_method_bs_pricing-0.1.0.tar.gz
| Download URL | multi_method_bs_pricing-0.1.0.tar.gz |
|---|---|
| Size | 154.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2926869a61cb1bac240a00cb69802553da8c1addb2eeaebb8bb1a9da9e0e3fd
|
|
BLAKE2b-256 checksum How to use checksums |
28b7278b86b80f004bb6e8ea0b9ed292aa89423a37c5363985480faf417b6766
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / multi_method_bs_pricing-0.1.0-py3-none-any.whl
| Download URL | multi_method_bs_pricing-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cf0c97ced330f199273be9c568494da722dc126845441ed0725de4fcbe331d6
|
|
BLAKE2b-256 checksum How to use checksums |
116c33520df386d034a72c283b2a7063a4ed83c07851e4c722a87dd6ca900ec2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|