Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ notebook: ## Run Jupyter notebook server
.PHONY: book
book: ## Build static jupyter {book}
poetry run jupyter-book build notebooks --all
cp notebooks/CNAME notebooks/_build/html/CNAME
@cp notebooks/CNAME notebooks/_build/html/CNAME


.PHONY: nbconvert
Expand Down
4 changes: 4 additions & 0 deletions notebooks/examples/exponential_sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ kernelspec:

Here we sample the Asymmetric Laplace distribution. We will set the mean to 0 and the variance to 1 so that the distribution is fully determined by the asymmetric parameter $\kappa$.

```{admonition} Interactive notebook not enabled in docs - how to run it interactively?
The widget below is not enabled in the documentation. You can run the notebook to see the widget in action, see [contributing](../reference/contributing.md) for instructions on how to run the notebook.
```

```{code-cell} ipython3
from quantflow.utils.distributions import DoubleExponential
from quantflow.utils import bins
Expand Down
10 changes: 7 additions & 3 deletions notebooks/examples/gaussian_sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupytext:
format_version: 0.13
jupytext_version: 1.16.6
kernelspec:
display_name: Python 3 (ipykernel)
display_name: .venv
language: python
name: python3
---
Expand All @@ -15,7 +15,11 @@ kernelspec:

Here we sample the gaussian OU process for different mean reversion speed and number of paths.

```{code-cell}
```{admonition} Interactive notebook not enabled in docs - how to run it interactively?
The widget below is not enabled in the documentation. You can run the notebook to see the widget in action, see [contributing](../reference/contributing.md) for instructions on how to run the notebook.
```

```{code-cell} ipython3
from quantflow.sp.ou import Vasicek
from quantflow.utils import plot
import ipywidgets as widgets
Expand Down Expand Up @@ -51,6 +55,6 @@ fig = go.FigureWidget(data=[simulation, analytical])
widgets.VBox([kappa, samples, fig])
```

```{code-cell}
```{code-cell} ipython3

```
4 changes: 4 additions & 0 deletions notebooks/examples/poisson_sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ kernelspec:

Evaluate the MC simulation for The Poisson process against the analytical PDF.

```{admonition} Interactive notebook not enabled in docs - how to run it interactively?
The widget below is not enabled in the documentation. You can run the notebook to see the widget in action, see [contributing](../reference/contributing.md) for instructions on how to run the notebook.
```

```{code-cell}
from quantflow.sp.poisson import PoissonProcess
from quantflow.utils import plot
Expand Down
16 changes: 8 additions & 8 deletions notebooks/models/heston_jumps.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jupytext:
format_version: 0.13
jupytext_version: 1.16.6
kernelspec:
display_name: Python 3 (ipykernel)
display_name: .venv
language: python
name: python3
---

# Heston Model with Jumps

THe models complements the standard [Heston](./heston.md) stochastic volatility model, with the addition of a double exponential Compound Poisson process.
The models complements the standard [Heston](./heston.md) stochastic volatility model, with the addition of a double exponential Compound Poisson process.
The Compound Poisson process adds a jump component to the Heston diffusion SDEs which control the volatility smile and skew for shorter maturities.

\begin{align}
Expand All @@ -32,9 +32,9 @@ where $j_t$ is a double exponential Compound Poisson process which adds three ad

The jump process is independent of the other Brownian motions.

```{code-cell}
```{code-cell} ipython3
from quantflow.sp.heston import HestonJ
pr = HestonJ.create(
pr = HestonJ.exponential(
vol=0.6,
kappa=2,
sigma=0.8,
Expand All @@ -46,25 +46,25 @@ pr = HestonJ.create(
pr
```

```{code-cell}
```{code-cell} ipython3
from quantflow.utils import plot
plot.plot_marginal_pdf(pr.marginal(0.1), 128, normal=True, analytical=False)
```

```{code-cell}
```{code-cell} ipython3
from quantflow.options.pricer import OptionPricer
from quantflow.sp.heston import Heston
pricer = OptionPricer(pr)
pricer
```

```{code-cell}
```{code-cell} ipython3
fig = None
for ttm in (0.05, 0.1, 0.2, 0.4, 0.6, 1):
fig = pricer.maturity(ttm).plot(fig=fig, name=f"t={ttm}")
fig.update_layout(title="Implied black vols", height=500)
```

```{code-cell}
```{code-cell} ipython3

```
15 changes: 14 additions & 1 deletion notebooks/reference/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,21 @@ make book
```
Navigate to the `notebook/_build/html` directory to find the `index.html` file you can open on your browser.

## Notebooks

To run the notebooks you can use the provided `make` command.

```
make notebook
```

This will start a jupyter notebook server and open the browser with the notebook interface.
You will be able to run the notebooks and see the results interactively (the book doesn't have interactive widgets).

## Developing with VS code

If you develop with VS code we provide several tooling for easing developing.

* **Notebooks development**: you can use the provided tasks to synchronize notbooks with markdown `myst` files by `Ctrl+Shift+B`
* **Notebooks development**: you can use the provided tasks to synchronize notebooks with markdown `myst` files by `Ctrl+Shift+B`. This allows to interact with the notebooks on VS code rather than jupyter interface.

+++
Loading