-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove dependence on qis from stochvolmodels
- Loading branch information
Showing
28 changed files
with
143 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
illustrations of gmm vols | ||
""" | ||
import numpy as np | ||
import pandas as pd | ||
import qis as qis | ||
import seaborn as sns | ||
import matplotlib.pyplot as plt | ||
from typing import List | ||
from stochvolmodels import GmmParams, OptionChain, GmmPricer | ||
|
||
|
||
def plot_gmm_pdfs(params: GmmParams, | ||
option_chain0: OptionChain, | ||
nstdev: float = 10.0, | ||
titles: List[str] = None, | ||
axs: List[plt.Subplot] = None | ||
) -> plt.Figure: | ||
""" | ||
plot gmm pdf and model fit | ||
""" | ||
stdev = nstdev * params.get_get_avg_vol() * np.sqrt(params.ttm) | ||
x = np.linspace(-stdev, stdev, 3000) | ||
state_pdfs, agg_pdf = params.compute_state_pdfs(x=x) | ||
|
||
columns = [] | ||
for idx in range(len(params.gmm_weights)): | ||
columns.append( | ||
f"state-{idx + 1}: mean={params.gmm_mus[idx]:0.2f}, vol={params.gmm_vols[idx]:0.2f}, weight={params.gmm_weights[idx]:0.2f}") | ||
|
||
state_pdfs = pd.DataFrame(state_pdfs, index=x, columns=columns) | ||
agg_pdf = pd.Series(agg_pdf, index=x, name='Aggregate PDF') | ||
df = pd.concat([agg_pdf, state_pdfs], axis=1) | ||
|
||
kwargs = dict(fontsize=14, framealpha=0.80) | ||
|
||
if axs is None: | ||
with sns.axes_style("darkgrid"): | ||
fig, axs = plt.subplots(1, 2, figsize=(16, 4.5)) | ||
else: | ||
fig = None | ||
|
||
qis.plot_line(df=df, | ||
linestyles=['--'] + ['-'] * len(params.gmm_weights), | ||
y_limits=(0.0, None), | ||
xvar_format='{:,.2f}', | ||
xlabel='log-price', | ||
first_color_fixed=True, | ||
ax=axs[0], | ||
**kwargs) | ||
axs[0].get_lines()[0].set_linewidth(4.0) | ||
axs[0].get_legend().get_lines()[0].set_linewidth(4.0) | ||
qis.set_title(ax=axs[0], title='(A) State PDF and Aggregate Risk-Neutral PDF', **kwargs) | ||
|
||
gmm_pricer = GmmPricer() | ||
gmm_pricer.plot_model_ivols_vs_bid_ask(option_chain=option_chain0, params=params, | ||
is_log_strike_xaxis=True, | ||
axs=[axs[1]], | ||
**kwargs) | ||
return fig |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "stochvolmodels" | ||
version = "1.0.24" | ||
version = "1.0.26" | ||
description = "Implementation of stochastic volatility models for option pricing" | ||
license = "LICENSE.txt" | ||
authors = ["Artur Sepp <[email protected]>"] | ||
|
@@ -37,13 +37,10 @@ python = ">=3.8" | |
numba = ">=0.55" | ||
numpy = ">=1.22.4" | ||
scipy = ">=1.3" | ||
statsmodels = ">=0.13.0" | ||
pandas = ">=0.19" | ||
matplotlib = ">=3.5.2" | ||
seaborn = ">=0.11.2" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.0.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ def read_file(file): | |
|
||
setup( | ||
name='stochvolmodels', | ||
version='1.0.24', | ||
version='1.0.26', | ||
author='Artur Sepp, Parviz Rakhmonov', | ||
author_email='[email protected], [email protected]', | ||
url='https://github.com/ArturSepp/StochVolModels', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.