Skip to content

Commit 75e9468

Browse files
committed
Remove jupyter book
1 parent 575dc61 commit 75e9468

File tree

758 files changed

+13430
-1303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

758 files changed

+13430
-1303
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ htmlcov
2121
.eggs
2222
*.egg-info
2323
__pycache__
24+
__marimo__
2425
build
2526
dist
2627
.venv

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"python.defaultInterpreterPath": ".venv/bin/python"
2+
"python.defaultInterpreterPath": ".venv/bin/python",
3+
"[python]": {
4+
"editor.defaultFormatter": "ms-python.black-formatter",
5+
"editor.formatOnSave": true
6+
}
37
}

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ lint-check: ## Lint check only
2020
install-dev: ## Install development dependencies
2121
@./dev/install
2222

23+
.PHONY: marimo
24+
marimo: ## Run marimo for editing notebooks
25+
@./dev/marimo edit
26+
27+
.PHONY: marimo-export
28+
marimo-export: ## Run marimo for editing notebooks
29+
@./dev/marimo export html-wasm -f --show-code notebooks/supersmoother.py -o docs/applications/supersmoother
2330

2431
.PHONY: notebook
2532
notebook: ## Run Jupyter notebook server
@@ -44,6 +51,14 @@ nbsync: ## Sync python myst notebooks to .ipynb files - needed for vs noteboo
4451
sphinx-config: ## Build sphinx config
4552
poetry run jupyter-book config sphinx notebooks
4653

54+
.PHONY: docs
55+
docs: ## build documentation
56+
@cp docs/index.md readme.md
57+
@poetry run mkdocs build
58+
59+
.PHONY: docs-serve
60+
docs-serve: ## serve documentation
61+
@poetry run mkdocs serve --livereload --watch quantflow --watch docs
4762

4863
.PHONY: sphinx
4964
sphinx: ## Build sphinx docs

app/__main__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import Annotated, Callable, Coroutine
2+
from fastapi.responses import HTMLResponse, RedirectResponse
3+
import marimo
4+
from fastapi import FastAPI, Form, Request, Response
5+
6+
7+
def crate_app() -> FastAPI:
8+
# Create a marimo asgi app
9+
server = (
10+
marimo.create_asgi_app()
11+
.with_app(path="/supersmoother", root="./app/supersmoother.py")
12+
)
13+
# Create a FastAPI app
14+
app = FastAPI()
15+
app.mount("/", server.build())
16+
return app
17+
18+
# Run the server
19+
if __name__ == "__main__":
20+
import uvicorn
21+
uvicorn.run(crate_app(), host="localhost", port=8001)

app/supersmoother.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import marimo
2+
3+
__generated_with = "0.19.7"
4+
app = marimo.App(width="medium")
5+
6+
7+
@app.cell(hide_code=True)
8+
def _(mo):
9+
mo.md(r"""
10+
# Supermsoother & EWMA
11+
""")
12+
return
13+
14+
15+
@app.cell
16+
def _():
17+
import marimo as mo
18+
19+
app = mo.App(
20+
requirements=["quantflow"]
21+
)
22+
return (mo,)
23+
24+
25+
@app.cell
26+
def _():
27+
from quantflow.data.fmp import FMP
28+
fmp = FMP()
29+
return (fmp,)
30+
31+
32+
@app.cell
33+
async def _(fmp):
34+
from datetime import date
35+
data = await fmp.prices("BTCUSD", from_date=date(2024,1,1))
36+
data
37+
return (data,)
38+
39+
40+
@app.cell
41+
def _():
42+
import altair as alt
43+
import pandas as pd
44+
return (alt,)
45+
46+
47+
@app.cell
48+
def _(mo):
49+
period = mo.ui.slider(start=2, stop=100, step=1, value=10, label="Period:")
50+
period
51+
return (period,)
52+
53+
54+
@app.cell
55+
def _(data, period):
56+
from quantflow.ta.supersmoother import SuperSmoother
57+
from quantflow.ta.ewma import EWMA
58+
smoother = SuperSmoother(period=period.value)
59+
ewma = EWMA(period=period.value)
60+
sm = data[["date", "close"]].copy()
61+
sm["supersmoother"] = data["close"].apply(smoother.update)
62+
sm["ewma"] = data["close"].apply(ewma.update)
63+
return (sm,)
64+
65+
66+
@app.cell(hide_code=True)
67+
def _(alt, sm):
68+
# Melt the dataframe to a long format suitable for Altair
69+
sm_long = sm.melt(
70+
id_vars=['date'],
71+
value_vars=['close', 'supersmoother', "ewma"],
72+
var_name='Signal',
73+
value_name='Price'
74+
)
75+
76+
# Create the chart with both SuperSmoothers
77+
line_chart_combined = alt.Chart(sm_long).mark_line().encode(
78+
x=alt.X('date:T', title='Date'),
79+
y=alt.Y('Price:Q', title='Price (USD)', scale=alt.Scale(zero=False)),
80+
color=alt.Color('Signal:N', title='Signal',
81+
scale=alt.Scale(
82+
domain=['close', 'supersmoother', 'ewma'],
83+
range=['#4c78a8', '#f58518', '#e45756']) # Vega-Lite default palette
84+
),
85+
tooltip=[
86+
alt.Tooltip('date:T', title='Date'),
87+
alt.Tooltip('Signal:N', title='Signal'),
88+
alt.Tooltip('Price:Q', title='Price', format='$,.2f')
89+
]
90+
).properties(
91+
title='BTCUSD Close Price vs. SuperSmoothers'
92+
).interactive()
93+
94+
line_chart_combined
95+
return
96+
97+
98+
@app.cell
99+
def _(sm):
100+
sm
101+
return
102+
103+
104+
@app.cell
105+
def _():
106+
return
107+
108+
109+
if __name__ == "__main__":
110+
app.run()

dev/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
pip install -U pip poetry
4-
poetry install --all-extras --with book
4+
poetry install --all-extras --with book --with docs

dev/marimo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
export PYTHONPATH=${PWD}:${PYTHONPATH}
5+
6+
poetry run marimo "$@"

docs/api/data/deribit.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Deribit
2+
3+
Fetch market and static data from [Deribit API](https://docs.deribit.com/).
4+
5+
You can import the module via
6+
7+
```python
8+
from quantflow.data.deribit import Deribit
9+
```
10+
11+
::: quantflow.data.deribit.Deribit

docs/api/data/fed.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Federal Reserve
2+
3+
You can import the module via
4+
5+
```python
6+
from quantflow.data.fed import FederalReserve
7+
```
8+
9+
::: quantflow.data.fed.FederalReserve

docs/api/data/fmp.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# FMP
2+
3+
4+
Reference information for the Financial Modeling Prep (FMP) data fetching module.
5+
You can find more information about FMP at [FMP developer docs](https://site.financialmodelingprep.com/developer/docs/stable).
6+
7+
You can import the module via
8+
9+
```python
10+
from quantflow.data.fmp import FMP
11+
```
12+
13+
::: quantflow.data.fmp.FMP

0 commit comments

Comments
 (0)