Skip to content

Commit 4889586

Browse files
authored
Fix heston calibration (#45)
1 parent 4be6b50 commit 4889586

30 files changed

Lines changed: 4869 additions & 3735 deletions

.github/copilot-instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ applyTo: '/**'
3030
* Do not use em dashes (—) in documentation files or docstrings. Use colons, parentheses, or restructure the sentence instead.
3131
* 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:`).
3232
* Glossary entries in `docs/glossary.md` must be kept in alphabetical order.
33+
* Do not repeat concept definitions inline in tutorials or docstrings — link to the glossary instead using a relative markdown link (e.g. `[moneyness](../glossary.md#moneyness)`).
3334
* To rebuild doc examples run `uv run ./dev/build-examples` — runs all scripts in `docs/examples/` and writes their output to `docs/examples_output/`
3435

36+
## Pydantic models
37+
38+
* Always document Pydantic fields with `Field(description=...)` — never use a docstring below a field assignment
39+
* Split long description strings across lines using implicit string concatenation rather than shortening the text
40+
3541
## Package structure
3642

3743
* Strategy runtime markdown descriptions (read by `load_description()` at runtime) live inside the package at `quantflow/options/strategies/docs/` — they must be inside the package to be accessible when the library is installed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Makefile Conventions
2+
3+
- Keep all targets sorted alphabetically.
4+
- targets should be separated by a one blank line only.
5+
- Each target should have a one-line description, starting with `##`, that describes what the target does. This description is used by the `help` target to generate documentation for all targets.

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
- uses: actions/checkout@v4
2424
- name: install rops
2525
uses: quantmind/rops/.github/actions/setup-rops@main
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.TOKEN_DEPLOYMENT }}
2628
- name: install taplo
2729
run: rops tools update taplo
2830
- name: Set up Python ${{ matrix.python-version }}

.github/workflows/docker-multiarch.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
password: ${{ github.token }}
2424
- name: install rops
2525
uses: quantmind/rops/.github/actions/setup-rops@main
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.TOKEN_DEPLOYMENT }}
2628
- name: build amd64
2729
run: rops docker build ${{ inputs.image-name }}
2830
- name: push amd64
@@ -44,6 +46,8 @@ jobs:
4446
password: ${{ github.token }}
4547
- name: install rops
4648
uses: quantmind/rops/.github/actions/setup-rops@main
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.TOKEN_DEPLOYMENT }}
4751
- name: build arm64
4852
run: rops docker build ${{ inputs.image-name }}
4953
- name: push arm64
@@ -64,5 +68,7 @@ jobs:
6468
password: ${{ github.token }}
6569
- name: install rops
6670
uses: quantmind/rops/.github/actions/setup-rops@main
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.TOKEN_DEPLOYMENT }}
6773
- name: create manifest
6874
run: rops docker manifest ${{ inputs.image-name }}

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@readme.md
22
@.github/copilot-instructions.md
3+
@.github/instructions/makefile.instructions.md

Makefile

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,39 @@ help:
55
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
66
@echo ================================================================================
77

8+
.PHONY: docs
9+
docs: ## build documentation
10+
@cp docs/index.md readme.md
11+
@uv run ./dev/build-examples
12+
@uv run mkdocs build
13+
14+
.PHONY: docs-examples
15+
docs-examples: ## Regenerate docs examples
16+
@uv run ./dev/build-examples
17+
18+
.PHONY: docs-serve
19+
docs-serve: ## serve documentation
20+
@uv run mkdocs serve --livereload --watch quantflow --watch docs
21+
22+
.PHONY: install-dev
23+
install-dev: ## Install development dependencies
24+
@./dev/install
825

926
.PHONY: lint
1027
lint: ## Lint and fix
1128
@uv run ./dev/lint fix
1229

13-
1430
.PHONY: lint-check
1531
lint-check: ## Lint check only
1632
@uv run ./dev/lint
1733

18-
19-
.PHONY: install-dev
20-
install-dev: ## Install development dependencies
21-
@./dev/install
22-
2334
.PHONY: marimo
2435
marimo: ## Run marimo for editing notebooks
2536
@./dev/marimo edit
2637

27-
.PHONY: docs-png
28-
docs-png: ## Regenerate PNG assets in docs/assets/ (requires Chrome via kaleido)
29-
@for f in docs/examples_png/*.py; do uv run python $$f; done
30-
31-
.PHONY: docs
32-
docs: ## build documentation
33-
@cp docs/index.md readme.md
34-
@uv run ./dev/build-examples
35-
@uv run mkdocs build
36-
37-
.PHONY: docs-serve
38-
docs-serve: ## serve documentation
39-
@uv run mkdocs serve --livereload --watch quantflow --watch docs
38+
.PHONY: outdated
39+
outdated: ## Show outdated packages
40+
uv tree --outdated
4041

4142
.PHONY: publish
4243
publish: ## Release to pypi
@@ -47,11 +48,6 @@ publish: ## Release to pypi
4748
tests: ## Unit tests
4849
@./dev/test
4950

50-
51-
.PHONY: outdated
52-
outdated: ## Show outdated packages
53-
uv tree --outdated
54-
5551
.PHONY: upgrade
5652
upgrade: ## Upgrade dependencies
5753
uv lock --upgrade

dev/build-examples

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
#!/usr/bin/env python
22
"""Run all example scripts in docs/examples/ and capture their stdout to .out files."""
3-
import subprocess
43
import sys
5-
from pathlib import Path
64

7-
out_dir = Path("docs/examples_output")
8-
out_dir.mkdir(exist_ok=True)
5+
from docs.examples._utils import build_examples
96

10-
examples = sorted(Path("docs/examples").glob("*.py"))
11-
failed = []
12-
13-
for script in examples:
14-
out_file = out_dir / script.with_suffix(".out").name
15-
print(f"running {script} -> {out_file}")
16-
result = subprocess.run(
17-
[sys.executable, str(script)],
18-
capture_output=True,
19-
text=True,
20-
)
21-
if result.returncode != 0:
22-
print(f"FAILED: {script}\n{result.stderr}", file=sys.stderr)
23-
failed.append(script)
24-
else:
25-
out_file.write_text(result.stdout)
7+
failed = build_examples()
268

279
if failed:
2810
sys.exit(1)

dev/lint

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ISORT_ARGS="-c"
55
BLACK_ARG="--check"
66
RUFF_ARG=""
77
TAPLO_ARG="format --check"
8+
PACKAGES="quantflow quantflow_tests docs/examples"
89

910
if [ "$1" = "fix" ] ; then
1011
ISORT_ARGS=""
@@ -15,12 +16,10 @@ fi
1516

1617
taplo ${TAPLO_ARG}
1718
echo isort
18-
uv run isort quantflow quantflow_tests ${ISORT_ARGS}
19+
uv run isort ${PACKAGES} ${ISORT_ARGS}
1920
echo black
20-
uv run black quantflow quantflow_tests ${BLACK_ARG}
21+
uv run black ${PACKAGES} ${BLACK_ARG}
2122
echo ruff
22-
uv run ruff check quantflow quantflow_tests ${RUFF_ARG}
23+
uv run ruff check ${PACKAGES} ${RUFF_ARG}
2324
echo mypy
24-
uv run mypy quantflow
25-
echo mypy tests
26-
uv run mypy quantflow_tests --explicit-package-bases
25+
uv run mypy ${PACKAGES}

docs/__init__.py

Whitespace-only changes.

docs/api/options/calibration.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Vol Model Calibration
22

3+
::: quantflow.options.calibration.OptionEntry
4+
35
::: quantflow.options.calibration.VolModelCalibration
46

5-
::: quantflow.options.calibration.HestonCalibration
7+
::: quantflow.options.heston_calibration.HestonCalibration
8+
9+
::: quantflow.options.heston_calibration.HestonJCalibration

0 commit comments

Comments
 (0)