Backtesting and factor evaluation for the BagelQuant ecosystem
Project description
bagelquant-bt
bagelquant-bt provides backtesting, factor evaluation, performance metrics, and
Plotly visualization for long-form Polars panels.
The public input shape is always explicit:
- prices:
time,asset_id,price - weights:
time,asset_id,weight - factors:
time,asset_id,factor
Weights at time=t earn each asset's close-to-close return from t to the next
available observation.
import polars as pl
from bagelquant_bt import BacktestConfig, run_backtest
prices = pl.DataFrame(
{
"time": ["2024-01-02", "2024-01-03"],
"asset_id": ["AAA", "AAA"],
"price": [100.0, 102.0],
}
)
weights = pl.DataFrame(
{"time": ["2024-01-02"], "asset_id": ["AAA"], "weight": [1.0]}
)
result = run_backtest(
weights,
prices,
kind="weights",
config=BacktestConfig(initial_capital=1_000_000),
)
print(result.returns)
print(result.summary)
Factor evaluation computes daily cross-sectional IC, quantile returns, a top-minus-bottom spread, and a TOP N equal-weight backtest.
Visualization helpers return Plotly figures:
from bagelquant_bt.visualization import plot_coverage, plot_cumulative_returns
fig = plot_cumulative_returns(result)
fig.write_html("cumulative_returns.html")
coverage_fig = plot_coverage(result)
coverage_fig.write_html("coverage.html")
Development
uv run ruff check .
uv run pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bagelquant_bt-0.1.4.tar.gz.
File metadata
- Download URL: bagelquant_bt-0.1.4.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9fcda96ef9f53fc52d0749024efd7adfa8d60b162e78449a7c97994104fe55b
|
|
| MD5 |
9e5e85d14bb0aecf6a6ba63276fcbefe
|
|
| BLAKE2b-256 |
21647f4c611d5a068284ebb737f07557a324207b4f16f160648126d2dac45e3b
|
File details
Details for the file bagelquant_bt-0.1.4-py3-none-any.whl.
File metadata
- Download URL: bagelquant_bt-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2083451f913e82c8d029347626be57a0615997fcf7df237f201093bb2b8ec1d
|
|
| MD5 |
9e08705a369a39a0d087b384d6d466ca
|
|
| BLAKE2b-256 |
bcbd8120c9fdbfb644b254e67cb5433fe869b11153c5d57f1b4c65eb735bcbff
|