User guide
Models
The models that are currently implemented in fyne
are the Black-Scholes,
Heston and Wishart models. In order to make notation clear, especially with the
naming of the parameters, we state below the discounted underlying price
dynamics of the models under the risk-neutral measure.
- Black-Scholes
\[ dS_t = \sigma S_t dW_t \]
- Heston
- Wishart
Pricing
Each model has its own pricing formula. The available pricing functions are:
fyne.blackscholes.formula
fyne.heston.formula
These functions return the price of the option in monetary units. If
implied volatility is needed, it can be evaluated with
fyne.blackscholes.implied_vol
{.interpreted-text role="func"}.
Example
In this example, we compute the implied volatility smile according to the Heston model.
import numpy as np
import pandas as pd
import plotly.express as px
from fyne import blackscholes, heston
underlying_price = 100.0
vol = 0.0457
params = (5.07, 0.0457, 0.48, -0.767)
strikes, expiries = np.broadcast_arrays(
np.linspace(80.0, 120.0, 40)[:, None],
[0.1, 0.3, 1.0],
)
option_prices = heston.formula(
underlying_price, strikes, expiries, vol, *params
)
implied_vols = blackscholes.implied_vol(
underlying_price, strikes, expiries, option_prices
)
data = pd.DataFrame(
{
"expirie": expiries.ravel(),
"strike": strikes.ravel(),
"implied_vol": implied_vols.ravel(),
}
)
fig = px.line(
data,
x="strike",
y="implied_vol",
color="expirie",
title="Heston volatility smile",
markers=True,
)
fig.write_html(
"docs/heston_smile.html",
full_html=False,
include_plotlyjs="cdn",
)
Greeks
Greeks are usually associated to the derivatives of the Black-Scholes
formula. However, Greeks can be computed according to other models as
well. The following are the available Greeks in fyne
:
fyne.blackscholes.delta
fyne.blackscholes.vega
fyne.heston.delta
fyne.heston.vega
Calibration
In fyne
we distinguish two types of calibration:
- Cross-sectional
- Calibration from options prices at a single point in time
- Panel
- Calibration from options prices at a multiple points in time
Besides, calibration can recover the full parameter set and unobservable state variables or just the unobservable state variables.
The available calibration functions are the following:
fyne.heston.calibration_crosssectional
fyne.heston.calibration_panel
fyne.heston.calibration_vol