Skip to content
Open
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 .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ applyTo: '/**'
* The documentation for quantflow is available at `https://quantflow.quantmid.com`
* Documentation is built using [mkdocs](https://www.mkdocs.org/) and stored in the `docs/` directory. The documentation source files are written in markdown format.
* Do not use em dashes (—) in documentation files or docstrings. Use colons, parentheses, or restructure the sentence instead.
* Math in documentation and docstrings uses `$...$` for inline and `$$...$$` or `\begin{equation}...\end{equation}` for block equations. Do not use `.. math::` or `:math:` (RST syntax).
* Math in documentation and docstrings: always use `\begin{equation}...\end{equation}` for any formula or equation. Use `$...$` only for brief inline references to variables (e.g. $F$, $K$). Do not use `$$...$$`, `` `...` ``, or RST syntax (`.. math::`, `:math:`).
* Glossary entries in `docs/glossary.md` must be kept in alphabetical order.
* To rebuild doc examples run `uv run ./dev/build-examples` — runs all scripts in `docs/examples/` and writes their output to `docs/examples_output/`

Expand Down
41 changes: 30 additions & 11 deletions app/volatility_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ def _(mo):
return


@app.cell
def _():
kwargs = dict()
return


@app.cell
def _(mo):
asset = mo.ui.dropdown(["btc", "eth", "sol"], value="btc", label="asset")
Expand All @@ -57,7 +51,7 @@ def _(mo):


@app.cell
async def _(asset, inverse):
async def _(asset, inverse, mo):
import pandas as pd
from quantflow.data.deribit import Deribit

Expand All @@ -74,18 +68,43 @@ async def _(asset, inverse):
surface.bs()
# disable outliers
surface.disable_outliers()
surface.plot3d()
return pd, surface
#
def int_or_none(v):
try:
return int(v)
except TypeError:
return None

maturites = [c.maturity for c in surface.maturities]
maturity_dropdown = mo.ui.dropdown(
options={m.strftime("%Y-%m-%d"): i for i, m in enumerate(maturites)},
label="Maturity"
)
maturity_dropdown
return int_or_none, maturity_dropdown, pd, surface


@app.cell
def _(pd, surface):
def _(int_or_none, maturity_dropdown, surface):
index = int_or_none(maturity_dropdown.value)
surface.plot3d(index=index)
return (index,)


@app.cell
def _(index, pd, surface):
# display inputs - only options with converged implied volatility
surface_inputs = surface.inputs(converged=True)
surface_inputs = surface.inputs(converged=True, index=index)
pd.DataFrame([i.model_dump() for i in surface_inputs.inputs])
return


@app.cell
def _(surface):
surface.term_structure()
return


@app.cell
def _():
return
Expand Down
4 changes: 4 additions & 0 deletions docs/api/utils/rates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Numbers


::: quantflow.utils.interest_rates.Rate
18 changes: 18 additions & 0 deletions docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ The [probability density function](https://en.wikipedia.org/wiki/Probability_den
F_x(x) = \int_{-\infty}^x f_x(s) ds
\end{equation}

## Put-Call Parity

Put-call parity is a no-arbitrage relationship between the prices of European call
and put options with the same strike $K$ and maturity. Denoting forward-space prices
$c = C/F$ and $p = P/F$ (see [Black Pricing](api/options/black.md)), the relationship
reads:

\begin{equation}
c - p = 1 - \frac{K}{F} = 1 - e^k
\end{equation}

where $k$ is the [log-strike](#log-strike).
In quoting currency terms, multiplying through by $F$:

\begin{equation}
C - P = F - K
\end{equation}

## Time To Maturity (TTM)

Time to maturity is the time remaining until an option or forward contract expires,
Expand Down
4 changes: 4 additions & 0 deletions quantflow/options/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class VolSurfaceSecurity(BaseModel):
def vol_surface_type(self) -> VolSecurityType:
raise NotImplementedError("vol_surface_type must be implemented by subclasses")

@classmethod
def forward(cls) -> Self:
raise NotImplementedError("forward_input must be implemented by subclasses")


class DefaultVolSecurity(VolSurfaceSecurity):
security_type: VolSecurityType = Field(
Expand Down
Loading
Loading