alphatonic
alphatonic is a Python library for testing trading signals. Give it scores and prices to measure how well the scores predict future returns. Inspect the results as pandas tables or open an interactive HTML report offline.
from alphatonic import evaluate
from alphatonic.demo import synthetic_market
factor, prices = synthetic_market(n_assets=30, n_bars=500, ic=0.04, seed=7) # or your own tables
result = evaluate(factor, prices, horizons=[1, 5])
result.summary.query("method == 'spearman'")[["horizon", "mean", "ci95_lower", "ci95_upper"]]
result.tearsheet("tearsheet.html")
What it measures
An information coefficient (IC) measures the association between a score and a future return. A positive IC means higher scores tend to precede higher returns.
- Cross-sectional IC: do higher-scored assets outperform lower-scored assets at each bar?
- Time-series IC: does each asset earn higher returns after higher scores? This also works with a single asset. By default, returns are divided by volatility estimated from past prices.
- Signal persistence: how much do scores, ranks and bucket membership change over time?
Both IC analyses run on every evaluation. Confidence intervals account for temporal dependence using
Newey–West standard errors and a block bootstrap. If a statistic cannot be computed, it is NaN
with a reason, such as constant_signal or insufficient_assets.
Horizons count rows of your price table. A return needs an unbroken path of prices; missing prices are never filled. Results can be saved, reloaded and used to rebuild reports.
For repeated experiments, a Study saves each completed trial, counts variants of the same idea and
keeps in-sample return labels out of a holdout period. Browse its results with alphatonic serve.
Install
Python 3.11 or newer. Install from PyPI:
python -m pip install "alphatonic[report]"
alphatonic[report] adds plotly and jinja2 for the tearsheet; evaluation itself depends only on
NumPy, pandas and pydantic.
Inputs
prices: aDataFrame, one row per bar, one column per asset, positive prices,NaNfor missing.factor: aDataFrameof scores, or a long-formatSeriesindexed by(timestamp, asset). Scores may cover a subset of the price rows and assets. Higher scores mean higher expected returns.
See prepare factor and prices for alignment rules, timing, and a look-ahead check.
Documentation
| Need | Guide |
|---|---|
| First run | Your first evaluation |
| Your own data | Prepare factor and prices |
| Choose windows and sample requirements | Configure an evaluation |
| Read the report | Read a tearsheet |
| Save results | Save and reload results |
| A statistic is missing | Troubleshooting |
| Many variants, one holdout | Keep every trial in a study |
| Tables and metric names | Results and metrics |
| What the numbers mean | Evaluation methodology |
| What it does not do | Design decisions |
See the changelog for release notes.
Preview the site with uv run --group docs zensical serve.
What it does not do
alphatonic measures predictive association and signal persistence. It does not simulate portfolios,
traded turnover, costs or P&L. It does not build factors or neutralise them by group. It cannot
check whether your factor uses future information, and a Study counts only the trials it saves.
See design decisions.
Development
uv sync --all-extras --locked
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run pyright
See Contributing for setup, tests and the release process.
License
MIT License. Copyright 2026 Manuel Blum.
Metadata
Release files for alphatonic 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| alphatonic-0.1.1.tar.gz | 165.1 kB | Without provenance | Details for alphatonic-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| alphatonic-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for alphatonic-0.1.1-py3-none-any.whl |
Total release size: 261.7 kB
Release files / alphatonic-0.1.1.tar.gz
| Download URL | alphatonic-0.1.1.tar.gz |
|---|---|
| Size | 165.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83da0a909f0c590861b80d37a6690e09ae9f2eb0772c8e8941bab2ebe28033d8
|
|
BLAKE2b-256 checksum How to use checksums |
63c2b48ac33e25c55a82a93fb3b88c5fe706b919457e2b39b777b44cd42af2fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / alphatonic-0.1.1-py3-none-any.whl
| Download URL | alphatonic-0.1.1-py3-none-any.whl |
|---|---|
| Size | 96.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48884b55c0972a2614236a4af75716917a166b2b1e2e0bc053bf3ddb9c17c53a
|
|
BLAKE2b-256 checksum How to use checksums |
98ca38789767c0d5d94d7de349454873c25b68c0da19ab70049be67fe089d7b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for alphatonic 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.