### RUN THIS CELL AND CLICK ON BUTTON "INIT NOTEBOOK"
# %load_ext autoreload
# %autoreload 2
import ipywidgets as widgets
import custom_widgets as cw
from IPython.display import display, HTML, Javascript, clear_output
cw.load_js_extensions()
toggle_code = cw.ToggleCodeCellsWidget()
toggle_code.code_shown = True
init_nb = cw.InitNotebook()
box = widgets.HBox([init_nb, toggle_code])
box.width = '25%'
box.layout.justify_content = 'space-around'
box
## Works in nbviewer as independent from backend
## button in cell below in notebook and in nav bar in nbviewer
from code_toggle import toggle_code_cells
toggle_code_cells(init_code_shown=True)
from blackscholes_widget import BlackScholesWidget
bsw = BlackScholesWidget()
clear_output()
bsw.form
Input | Symbol | |
---|---|---|
Spot in currency | $$S$$ | |
Strike in the same unit as Spot | $$K$$ | |
Maturity in years | $$T$$ | |
Volatility in % e.g. 15%=0.15 | $$\sigma$$ | |
Risk free interest rate in % e.g. 1.5%=0.015 | $$r$$ | |
Continuous dividend rate in % e.g. 2%=0.02 | $$q$$ |
Option | Call | Put |
---|---|---|
$$Payoff$$ | $$Max(0, S-K)$$ | $$Max(0, K-S)$$ |
$$Value=V$$ | $$Se^{-qT}N(d_1)-Ke^{-rT}N(d_2)$$ | $$Ke^{-rT}N(-d_2)-Se^{-qT}N(-d_1)$$ |
$$\Delta=\frac{\partial V}{\partial S}$$ | $$e^{-qT}N(d_1)$$ | $$-e^{-qT}N(-d_1)$$ |
$$\Gamma=\frac{\partial \Delta}{\partial S}$$ | $$e^{-qT}\frac{N'(d_1)}{S\sigma\sqrt{T}}$$ | $$e^{-qT}\frac{N'(d_1)}{S\sigma\sqrt{T}}$$ |
$$\nu=\frac{\partial V}{\partial \sigma}$$ | $$Se^{-qT}N'(d_1)\sqrt{T}=Ke^{-rT}N'(d_2)\sqrt{T}$$ | $$Se^{-qT}N'(d_1)\sqrt{T}=Ke^{-rT}N'(d_2)\sqrt{T}$$ |
$$\Theta=-\frac{\partial V}{\partial T}$$ | $$-e^{qT}\frac{SN'(d_1)\sigma}{2\sqrt{T}}-rKe^{-rT}N(d_2)+qSe^{-qT}N(d_1)$$ | $$-e^{qT}\frac{SN'(d_1)\sigma}{2\sqrt{T}}+rKe^{-rT}N(-d_2)-qSe^{-qT}N(-d_1)$$ |
$$\rho=\frac{\partial V}{\partial r}$$ | $$KTe^{-rT}N(d_2)$$ | $$-KTe^{-rT}N(-d_2)$$ |
$$Voma=\frac{\partial\nu}{\partial \sigma}$$ | $$Se^{-qT}N'(d_1)\sqrt{T}\frac{d_1 d_2}{\sigma}$$ | $$Se^{-qT}N'(d_1)\sqrt{T}\frac{d_1 d_2}{\sigma}$$ |