alpholio
Cross-sectional portfolio backtesting. The toolkit consumes alpha and handles bucketing, weighting, metrics and charts.
📖 Documentation (Chinese) | 简体中文 README
Four modules, one direction of data flow. Each module owns a single public entry point, so any stage can be swapped without touching the others.
InputProcessor ──InputBundle──▶ PortfolioEngine ──EngineResult──▶ Analyzer ──AnalysisResult──▶ Visualizer ──▶ PNG / CSV
The toolkit consumes alpha only — it never generates signals. Price-based factors such as MOM / STR / WSTR are ordinary inputs; see the daily MOM example for one worked end to end.
Install
pip install alpholio
Working from a clone instead:
pip install -e . # compatible ranges
pip install -e ".[docs]" # adds the documentation site toolchain
To reproduce the exact verified combination (Python 3.12.2):
conda env create -f environment.yml
conda activate alpholio
pip install -e .
Quick start
Factor and price tables go in as DataFrames — no need to write them to disk first:
import alpholio as alp
bt = alp.backtest(signals=alpha_df, prices=price_df, horizon=5)
bt.summary() # metrics per (signal_model, bucket, weight)
bt.plot("long_short") # long-short equity curve, returns a matplotlib Figure
bt.plot("deciles") # per-quantile gradient chart
bt.save("outputs/") # PNG charts and CSV metrics to disk
bt.returns # per-period portfolio returns, long format
bt.curves # equity and cumulative log-return curves
horizon is the measurement window of each period's realised return and is required.
Column mapping is inferred when the source names already match the contract
(date / id / alpha); the rebalance interval defaults to horizon; and value
weighting is added automatically when the price table carries a cap column.
Monthly panels only need a frequency: horizon and the rebalance interval then count
calendar months, and metrics annualise at 12 periods per year.
bt = alp.backtest(signals=alpha_df, prices=panel_df, horizon=1, frequency="monthly")
File paths work interchangeably with in-memory tables:
bt = alp.backtest(signals="alpha.feather", prices="prices.feather", horizon=5)
bt = alp.backtest(signals={"MOM": mom_df, "REV": rev_df}, prices=price_df, horizon=5)
Batch runs and reproducible archives
The JSON config directory remains a first-class entry point, suited to batch execution on a server and to shipping alongside a paper:
alpholio run --config-dir configs/
result = alp.run_pipeline("configs/")
Both paths share the same validation and computation and agree value for value. Parameters settled in a notebook export back out into a config directory:
bt.to_config("paper/configs/", data_dir="paper/data/")
Documentation
The full documentation is written in Chinese. Direct links:
| Page | Contents |
|---|---|
| Quick start | Install through the first equity curve |
| Concepts | Four modules, three data contracts, extension points |
| Preparing input | Signal table format, column mapping, forward-return sources |
| Data frequency | Daily vs monthly: units, alignment rules, annualisation base |
| Multiple signals | Running several alphas at once, and how charts split |
| Outputs | File listing, naming rules, long-table structure |
| Math contract | The exact formula behind every metric |
| Daily example | MOM 12-2 end to end: input shape, call, measured results |
| Monthly example | Three alphas off one monthly panel, frequency="monthly" |
| Python API | backtest() parameters and the result object |
| Config reference | Per-field types, defaults and constraints |
Benchmarks
No market index data is bundled. Benchmark series are supplied by the user through
input.references, enter the result table under bucket REF, and appear on charts once
"REF" is listed in a chart's buckets.
Equal-weighted portfolios should be paired with an equal-weighted index and cap-weighted
with a cap-weighted index — only like-for-like comparisons mean anything. A single
references entry is replicated across every weighting scheme, so pairing one index per
scheme takes two entries plus two chart configs constraining weights and signals. See
Multiple signals.
Building the docs locally
pip install -e ".[docs]"
mkdocs serve
License
MIT
Release files for alpholio 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alpholio-0.4.0.tar.gz | 55.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alpholio-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 122.6 kB
Release files / alpholio-0.4.0.tar.gz
| Download URL | alpholio-0.4.0.tar.gz |
|---|---|
| Size | 55.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
065e5e9871ddea097e2e895727dc894a319d219b18399b9fc0bf972842a3babb
|
|
BLAKE2b-256 checksum How to use checksums |
9e2b7404f015e9f8fa4c55b83f6f8eebfc1d68efd58e935733f42108189e2df9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency logRelease files / alpholio-0.4.0-py3-none-any.whl
| Download URL | alpholio-0.4.0-py3-none-any.whl |
|---|---|
| Size | 67.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
951fc79de820f6aaa2ba956a77c7b6e21cd41875219c6d335c2838d79a77b976
|
|
BLAKE2b-256 checksum How to use checksums |
3465e2e39da22b19c740f1cb93d11bdcd582426d97acfffc7898fc9810f4227d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.
Transparency log