Skip to content

Commit 5c5801a

Browse files
committed
Upgraded docs
1 parent 16e9e42 commit 5c5801a

26 files changed

Lines changed: 482 additions & 322 deletions

app/volatility_surface.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import marimo
2+
3+
__generated_with = "0.20.4"
4+
app = marimo.App(width="medium")
5+
6+
7+
@app.cell
8+
def _():
9+
import marimo as mo
10+
from app.utils import nav_menu
11+
nav_menu()
12+
return (mo,)
13+
14+
15+
@app.cell(hide_code=True)
16+
def _(mo):
17+
mo.md(r"""
18+
# Volatility Surface
19+
20+
In this notebook we illustrate the use of the Volatility Surface tool in the library. We use [deribit](https://docs.deribit.com/) options on ETHUSD as example.
21+
22+
The library provide a volatility surface loader for Deribit. This code loads the surface as a [VolSurfaceLoader](api/options/vol_surface/#quantflow.options.surface.VolSurfaceLoader):
23+
24+
```python
25+
from quantflow.data.deribit import Deribit
26+
27+
async with Deribit() as cli:
28+
loader = await cli.volatility_surface_loader("eth", exclude_open_interest=0)
29+
```
30+
""")
31+
return
32+
33+
34+
@app.cell
35+
async def _():
36+
import pandas as pd
37+
from quantflow.data.deribit import Deribit
38+
39+
async with Deribit() as cli:
40+
loader = await cli.volatility_surface_loader("eth", exclude_open_interest=0)
41+
42+
# build the volatility surface
43+
surface = loader.surface()
44+
# calculate black implied volatilities
45+
surface.bs()
46+
# display inputs
47+
surface_inputs = surface.inputs()
48+
pd.DataFrame([i.model_dump() for i in surface_inputs.inputs])
49+
return
50+
51+
52+
@app.cell
53+
def _():
54+
return
55+
56+
57+
if __name__ == "__main__":
58+
app.run()

docs/api/data/deribit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ from quantflow.data.deribit import Deribit
99
```
1010

1111
::: quantflow.data.deribit.Deribit
12+

docs/api/data/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Data fetching
22

33

4-
The :mod:`quantflow.data` module provides classes and functions for fetching data from various sources.
4+
The `quantflow.data` module provides classes and functions for fetching data from various sources.
55
To use the module the package must be installed with the optional `data` extra.
66
```
77
pip install quantflow[data]

docs/api/options/vol_surface.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
::: quantflow.options.surface.VolSurfaceLoader
1111

12+
::: quantflow.options.surface.VolCrossSectionLoader
13+
14+
::: quantflow.options.surface.Strike
15+
1216
::: quantflow.options.surface.OptionPrice
1317

1418
::: quantflow.options.surface.OptionSelection

docs/api/sp/dsp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Doubly Stochastic Poisson process
2+
3+
::: quantflow.sp.dsp.DSP

docs/api/utils/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# Utils
1+
# Utilities
2+
3+
This section contains utility functions and classes that are used throughout the library. They are not meant to be used directly by the user, but they can be useful for advanced users who want to extend the library or understand its inner workings.

docs/api/utils/numbers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Numbers
2+
3+
4+
::: quantflow.utils.numbers.DecimalNumber

docs/api/utils/types.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Types
2+
3+
4+
::: quantflow.utils.types.FloatArray
5+
6+
::: quantflow.utils.types.FloatArrayLike

docs/bibliography.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22

33
---
44

5+
### carr_madan
6+
7+
Peter Carr, Dilip Madan
8+
9+
[Option Valuation Using the Fast Fourier Transform](https://doi.org/10.1002/(SICI)1097-0261(199904)2:1<61::AID-FUT4>3.0.CO;2-4)
10+
11+
Journal of Computational Finance, 2(4):61-73, 1999
12+
13+
---
14+
15+
### carr_wu
16+
17+
Peter Carr, Liuren Wu
18+
19+
[Time-Changed Lévy Processes and Option Pricing](https://doi.org/10.1016/S0304-405X(03)00171-5)
20+
21+
Journal of Financial Economics, 71(1):113-141, 2004
22+
23+
---
24+
25+
### chourdakis
26+
27+
Kyriakos Chourdakis
28+
29+
[Option Pricing Using the Fractional FFT](https://doi.org/10.21314/JCF.2005.102)
30+
31+
Journal of Computational Finance, 8(2):1-18, 2005
32+
33+
---
34+
535
### molnar
636

737
Peter Molnar
Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
---
2-
jupytext:
3-
text_representation:
4-
extension: .md
5-
format_name: myst
6-
format_version: 0.13
7-
jupytext_version: 1.16.6
8-
kernelspec:
9-
display_name: Python 3 (ipykernel)
10-
language: python
11-
name: python3
12-
---
13-
141
# Characteristic Function
152

16-
The library makes heavy use of [characteristic function](https://en.wikipedia.org/wiki/Characteristic_function_(probability_theory))
3+
The library makes heavy use of the [characteristic function](https://en.wikipedia.org/wiki/Characteristic_function_(probability_theory))
174
concept and therefore, it is useful to familiarize with it.
185

196
## Definition
207

21-
The characteristic function of a random variable $x$ is the Fourier (inverse) transform of ${\mathbb P}_x$, where ${\mathbb P}_x$ is the distrubution measure of $x$
8+
The characteristic function of a random variable $x$ is the Fourier (inverse) transform of ${\mathbb P}_x$, where ${\mathbb P}_x$ is the distribution measure of $x$
9+
2210
\begin{equation}
2311
\Phi_{x,u} = {\mathbb E}\left[e^{i u x}\right] = \int e^{i u s} {\mathbb P}_x\left(ds\right)
2412
\end{equation}
@@ -33,23 +21,23 @@ The characteristic function of a random variable $x$ is the Fourier (inverse) tr
3321
* moments of $x$ are given by
3422

3523
\begin{equation}
36-
{\mathbb E}\left[x^n\right] = i^{-n} \left.\frac{\Phi_{x, u}}{d u}\right|_{u=0}
24+
{\mathbb E}\left[x^n\right] = i^{-n} \left.\frac{d\Phi_{x, u}}{d u}\right|_{u=0}
3725
\end{equation}
3826

39-
## Covolution
27+
## Convolution
4028

41-
The characteristic function is a great tool for working with linear combination of random variables.
29+
The characteristic function is a great tool for working with linear combinations of random variables.
4230

4331
* if $x$ and $y$ are independent random variables then the characteristic function of the linear combination $a x + b y$ ($a$ and $b$ are constants) is
4432

4533
\begin{equation}
46-
\Phi_{ax+bx,u} = \Phi_{x,a u}\Phi_{y,b u}
34+
\Phi_{ax+by,u} = \Phi_{x,a u}\Phi_{y,b u}
4735
\end{equation}
4836

4937
* which means, if $x$ and $y$ are independent, the characteristic function of $x+y$ is the product
5038

5139
\begin{equation}
52-
\Phi_{x+x,u} = \Phi_{x,u}\Phi_{y,u}
40+
\Phi_{x+y,u} = \Phi_{x,u}\Phi_{y,u}
5341
\end{equation}
5442

5543
* The characteristic function of $ax+b$ is
@@ -79,11 +67,6 @@ The inversion formula for these distributions is given by
7967
{\mathbb P}_x\left(x=k\right) = \frac{1}{2\pi}\int_{-\pi}^\pi e^{-iuk}\Phi_{k, u} du
8068
\end{equation}
8169

82-
```{code-cell}
83-
84-
```
85-
86-
(characteristic-exponent)=
8770
## Characteristic Exponent
8871

8972
The characteristic exponent $\phi_{x,u}$ is defined as

0 commit comments

Comments
 (0)