Skip to content

Commit 2c0b620

Browse files
committed
Build
1 parent e90dff0 commit 2c0b620

File tree

5 files changed

+84
-18
lines changed

5 files changed

+84
-18
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ jobs:
5555

5656
image:
5757
if: github.ref == 'refs/heads/main'
58-
needs:
59-
- build
6058
uses: ./.github/workflows/docker-multiarch.yml
6159
with:
6260
image-name: quantflow

app/hurst.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,46 @@ def _(paths):
7373
return
7474

7575

76+
@app.cell
77+
def _(mo):
78+
mo.md(r"""
79+
### Realized Variance
80+
81+
At this point we estimate the standard deviation using the **realized variance** along the path (we use the **scaled** flag so that the standard deviation is scaled by the square-root of time step, in this way it removes the dependency on the time step size).
82+
The value should be close to the **sigma** of the WeinerProcess defined above.
83+
""")
84+
return
85+
86+
87+
@app.cell
88+
def _(paths):
89+
float(paths.paths_std(scaled=True)[0])
90+
91+
return
92+
93+
94+
@app.cell
95+
def _(mo):
96+
mo.md(r"""
97+
The evaluation of the hurst exponent is done by calculating the variance for several time windows and by fitting a line to the log-log plot of the variance vs the time window.
98+
""")
99+
return
100+
101+
102+
@app.cell
103+
def _(paths):
104+
paths.hurst_exponent()
105+
return
106+
107+
108+
@app.cell
109+
def _(mo):
110+
mo.md(r"""
111+
As expected, the Hurst exponent should be close to 0.5, since we have calculated the exponent from the paths of a Weiner process.
112+
""")
113+
return
114+
115+
76116
@app.cell
77117
def _():
78118
return

docs/contributing.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contributing
2+
3+
Welcome to `quantflow` repository! We are excited you are here and want to contribute.
4+
5+
## Getting Started
6+
7+
To get started with quantflow's codebase, take the following steps:
8+
9+
* Clone the repo
10+
```
11+
git clone git@github.com:quantmind/quantflow.git
12+
```
13+
* Install dev dependencies
14+
```
15+
make install-dev
16+
```
17+
* Run tests
18+
```
19+
make tests
20+
```
21+
* Run the [marimo](https://marimo.io/) server during development
22+
```
23+
make marimo
24+
```

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ plugins:
5454
schema: false
5555
nav:
5656
- Home: index.md
57-
- Getting Started: getting-started.md
57+
- Contributing: contributing.md
5858
- Examples:
5959
- Gaussian Sampling: examples/gaussian-sampling
6060
- Supersmoother: examples/supersmoother

quantflow/ta/paths.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from __future__ import annotations
22

33
from datetime import datetime
4-
from typing import Any, cast
4+
from typing import Any, cast, Self
55

66
import numpy as np
77
import pandas as pd
88
from numpy.random import normal
99
from pydantic import BaseModel, Field
1010
from scipy.integrate import cumulative_trapezoid
11+
from typing_extensions import Annotated, Doc
1112

1213
from quantflow.utils import plot
1314
from quantflow.utils.bins import pdf as bins_pdf
@@ -168,7 +169,7 @@ def pdf(
168169
)
169170

170171
def plot(self, **kwargs: Any) -> Any:
171-
"""Plot paths
172+
"""Plot paths as lines
172173
173174
It requires plotly installed
174175
"""
@@ -177,19 +178,22 @@ def plot(self, **kwargs: Any) -> Any:
177178
@classmethod
178179
def normal_draws(
179180
cls,
180-
paths: int,
181-
time_horizon: float = 1,
182-
time_steps: int = 1000,
183-
antithetic_variates: bool = True,
184-
) -> Paths:
185-
"""Generate normal draws
186-
187-
:param paths: number of paths
188-
:param time_horizon: time horizon
189-
:param time_steps: number of time steps to arrive at horizon
190-
:param antithetic_variates: whether to use `antithetic variates`_
191-
192-
.. _antithetic variates: https://en.wikipedia.org/wiki/Antithetic_variates
181+
paths: Annotated[int, Doc("Number of paths to simulate")],
182+
time_horizon: Annotated[float, Doc("Time horizon")] = 1,
183+
time_steps: Annotated[
184+
int, Doc("Number of time steps to arrive at horizon")
185+
] = 1000,
186+
antithetic_variates: Annotated[
187+
bool,
188+
Doc(
189+
"Whether to use [antithetic variates]"
190+
"(https://en.wikipedia.org/wiki/Antithetic_variates)"
191+
" to reduce variance by generating pairs of paths that are mirror"
192+
" images of each other"
193+
),
194+
] = True,
195+
) -> Self:
196+
"""Create paths from normal draws
193197
"""
194198
time_horizon / time_steps
195199
odd = 0

0 commit comments

Comments
 (0)