Skip to content

Commit 1344203

Browse files
committed
Add hurst
1 parent de17818 commit 1344203

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,13 @@ jobs:
4444
- name: run tests
4545
run: make tests
4646
- name: upload coverage reports to codecov
47-
if: matrix.python-version == '3.13'
47+
if: matrix.python-version == '3.14'
4848
uses: codecov/codecov-action@v3
4949
with:
5050
token: ${{ secrets.CODECOV_TOKEN }}
5151
files: ./build/coverage.xml
52-
- name: build book
53-
if: ${{ matrix.python-version == '3.13' }}
54-
run: make book
55-
- name: publish book
56-
if: ${{ matrix.python-version == '3.13' }}
57-
run: make publish-book
5852
- name: publish
59-
if: ${{ matrix.python-version == '3.13' && github.event.head_commit.message == 'release' }}
53+
if: ${{ matrix.python-version == '3.14' && github.event.head_commit.message == 'release' }}
6054
run: make publish
6155

6256
deploy:

.github/workflows/update.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/hurst.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,48 @@ def _(mo):
3535
3636
* [Hurst Exponent for Algorithmic Trading](https://robotwealth.com/demystifying-the-hurst-exponent-part-1/)
3737
* [Basics of Statistical Mean Reversion Testing](https://www.quantstart.com/articles/Basics-of-Statistical-Mean-Reversion-Testing/)
38+
39+
## Estimate from OHLC data
40+
41+
We want to construct a mechanism to estimate the Hurst exponent via OHLC data because it is widely available from data providers and easily constructed as an online signal during trading.
42+
43+
In order to evaluate results against known solutions, we consider the Weiner process as generator of timeseries.
44+
45+
We use the **WeinerProcess** from the stochastic process library and sample one path over a time horizon of 1 (day) with a time step every second.
46+
""")
47+
return
48+
49+
50+
@app.cell
51+
def _():
52+
from quantflow.sp.weiner import WeinerProcess
53+
p = WeinerProcess(sigma=2.0)
54+
paths = p.sample(n=1, time_horizon=1, time_steps=24*60*60)
55+
paths.plot(title="A path of Weiner process with sigma=2.0")
56+
return (paths,)
57+
58+
59+
@app.cell
60+
def _(mo):
61+
mo.md(r"""
62+
In order to down-sample the timeseries, we need to convert it into a dataframe with dates as indices.
3863
""")
3964
return
4065

4166

67+
@app.cell
68+
def _(paths):
69+
70+
from quantflow.utils.dates import start_of_day
71+
df = paths.as_datetime_df(start=start_of_day(), unit="d").reset_index()
72+
73+
return
74+
75+
76+
@app.cell
77+
def _():
78+
return
79+
80+
4281
if __name__ == "__main__":
4382
app.run()

0 commit comments

Comments
 (0)