1. Quickstart
Ok, let's skip the fluff and explain how you can quickly get started.
0. Install the library
The library is tested for Python version 3.8 up to 3.10.
pip install blackscholes
1. Define 5 inputs for computing Black Scholes:
S = 55.0 # Asset price
K = 50.0 # Strike price
T = 1.0 # 1 Year to maturity
r = 0.0025 # 0.25% Risk-free rate
sigma = 0.15 # 15% Volatility
q = 0.0 # 0% Annual Dividend Yield
2. Initialize class for call and/or puts
# 2. Initialize class for call and/or puts
from blackscholes import BlackScholesCall, BlackScholesPut
call = BlackScholesCall(S, K, T, r, sigma, q)
put = BlackScholesPut(S, K, T, r, sigma, q)
3. Get the attributes you want
# Fair str_method estimate
call.price()
## 6.339408
call.get_core_greeks() # Dictionary with 5 most important Greeks
## {"delta": 0.766407808509462,
## "gamma": 0.03712496688031454,
## "vega": 16.84545372194272,
## "theta": -1.3529415670754943,
## "rho": 35.813015171916085,
## }
call.get_all_greeks()
## {"delta": 0.766407808509462,
## "spot_delta": 0.7683262250522389,
## "gamma": 0.03712496688031454,
## "vega": 16.84545372194272,
## "theta": -1.3529415670754943,
## "epsilon": -42.15242946802041,
## "rho": 35.813015171916085,
## "lambda": 6.6492624553539255,
## "vanna": -1.178299396409533,
## "charm": 0.0832677717846717,
## "vomma": 47.11869947977544,
## "veta": 11.752499520643353,
## "phi": 0.04492120992518061,
## "speed": -0.003946801873134375,
## "zomma": -0.14365691533482322,
## "color": -0.011224141490466934,
## "ultima": -827.4229433648609,
## "dual_delta": 0.7162603034383217,
## "dual_gamma": 0.0449212099251806,
## }
call.get_itm_proxies() # Dictionary with in-the-money proxies
## {"naive_itm": 0.7180531943767934, "dual_delta": 0.7162603034383217}
call.delta() # Get Delta Greek
## 0.766407808509462