Skip to content

Commit 4696bae

Browse files
authored
Add rate historical calibration (#77)
1 parent 70e842e commit 4696bae

46 files changed

Lines changed: 2539 additions & 1046 deletions

Some content is hidden

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

.github/copilot-instructions.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ applyTo: '/**'
4747
"""This is the docstring for foo"""
4848
return float(x)
4949
```
50-
* Do not use Docstrings with markdown text that may genereate headings (e.g. `# Heading`, `## Heading`, etc.)
50+
* Do not use Docstrings with markdown text that may generate headings (e.g. `# Heading`, `## Heading`, etc.)
5151
* 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:`).
5252
* Math notation convention: use $\Phi$ for the characteristic function and $\phi$ for the characteristic exponent, where $\Phi = e^{-\phi}$.
5353
* Glossary entries in `docs/glossary.md` must be kept in alphabetical order.
@@ -61,6 +61,15 @@ applyTo: '/**'
6161
* Always document Pydantic fields with `Field(description=...)`, never use a docstring below a field assignment
6262
* Split long description strings across lines using implicit string concatenation rather than shortening the text
6363
* When a docstring line exceeds the line length limit, split it across multiple lines rather than shortening the text
64+
* Put Pydantic config options directly in the class definition, not as a `model_config = ConfigDict(...)` class variable:
65+
```python
66+
# correct
67+
class Foo(BaseModel, arbitrary_types_allowed=True): ...
68+
69+
# wrong
70+
class Foo(BaseModel):
71+
model_config = ConfigDict(arbitrary_types_allowed=True)
72+
```
6473

6574
## Package structure
6675

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: quantflow-bibliography-instructions
3+
description: 'Instructions for bibliography in quantflow'
4+
applyTo: '/**'
5+
---
6+
7+
Instructions for updating the bibliography for quantflow:
8+
9+
* The bibliography for quantflow is maintained in `docs/references.bib`
10+
* Each entry must be added in alphabetical order of the label (the part after the first `{` in the bib entry).
11+
* Regenerate the markdown file `docs/bibliography.md` from the `bib` file using the
12+
```bash
13+
make docs-bib
14+
```
15+
* Run this command every time you update the `bib` file to keep the markdown file in sync
16+
* Do not edit `docs/bibliography.md` directly as it is generated from `docs/references.bib`.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ frontend/node_modules
4444
frontend/src/.observablehq
4545
docs/assets/examples
4646
docs/examples/output
47+
docs/examples/cache

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@readme.md
22
@.github/copilot-instructions.md
3+
@.github/instructions/bibliography.instructions.md
34
@.github/instructions/makefile.instructions.md
45
@.github/instructions/observable.instructions.md
56
@.github/instructions/release.instructions.md

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ lint: ## Lint and fix
4848
lint-check: ## Lint check only
4949
@uv run ./dev/lint
5050

51-
.PHONY: marimo
52-
marimo: ## Run marimo for editing notebooks
53-
@./dev/marimo edit
54-
5551
.PHONY: outdated
5652
outdated: ## Show outdated packages
5753
uv tree --outdated

app/api/deps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from fluid.utils import log
1010
from fluid.utils.redis import FluidRedis
1111
from pydantic import BaseModel
12-
from redis import Redis
12+
from redis.asyncio import Redis
1313

1414
from quantflow.data.fmp import FMP
1515

@@ -77,8 +77,9 @@ async def from_cache(
7777
value = await self.redis.get(self.key)
7878
if value is None:
7979
return await self.set_cache(await loader())
80+
data = value.encode() if isinstance(value, str) else value
8081
try:
81-
return pd.read_parquet(io.BytesIO(value))
82+
return pd.read_parquet(io.BytesIO(data))
8283
except Exception:
8384
logger.exception(f"Failed to decode cache value for key {self.key}")
8485
return await self.set_cache(await loader())

dev/install

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

3-
uv sync --all-extras
3+
uv sync --all-extras --all-groups

docs/api/dists/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Distributions
2+
3+
Probability distributions with a uniform `sample` / `log_pdf` API, used as
4+
return types of the
5+
[StateSpaceModel](../ta/kalman.md#quantflow.ta.kalman.StateSpaceModel)
6+
distribution-level interface.
7+
8+
::: quantflow.dists.Distribution
9+
10+
::: quantflow.dists.MvNormal

docs/api/rates/calibration.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Yield Curve Calibration
2+
3+
::: quantflow.rates.calibration.YieldCurveCalibration
4+
5+
::: quantflow.rates.calibration.OptionsDiscountingCalibration

docs/api/rates/options.md

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

0 commit comments

Comments
 (0)