alphatonic 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. alphatonic-0.1.1/.gitignore +199 -0
  2. alphatonic-0.1.1/CHANGELOG.md +18 -0
  3. alphatonic-0.1.1/CONTRIBUTING.md +174 -0
  4. alphatonic-0.1.1/LICENSE +21 -0
  5. alphatonic-0.1.1/PKG-INFO +137 -0
  6. alphatonic-0.1.1/README.md +102 -0
  7. alphatonic-0.1.1/docs/_includes/CHANGELOG.md +1 -0
  8. alphatonic-0.1.1/docs/_includes/CONTRIBUTING.md +1 -0
  9. alphatonic-0.1.1/docs/_includes/README.md +1 -0
  10. alphatonic-0.1.1/docs/changelog.md +6 -0
  11. alphatonic-0.1.1/docs/contributing/development.md +8 -0
  12. alphatonic-0.1.1/docs/contributing/reference-exposures.md +40 -0
  13. alphatonic-0.1.1/docs/explanation/design.md +75 -0
  14. alphatonic-0.1.1/docs/explanation/methodology.md +198 -0
  15. alphatonic-0.1.1/docs/explanation/report-design.md +44 -0
  16. alphatonic-0.1.1/docs/explanation/signal-persistence.md +91 -0
  17. alphatonic-0.1.1/docs/explanation/targets-and-scaling.md +132 -0
  18. alphatonic-0.1.1/docs/explanation/targets_and_scaling.py +265 -0
  19. alphatonic-0.1.1/docs/how-to/compare-factors.md +72 -0
  20. alphatonic-0.1.1/docs/how-to/configure-evaluation.md +130 -0
  21. alphatonic-0.1.1/docs/how-to/measure-persistence.md +48 -0
  22. alphatonic-0.1.1/docs/how-to/prepare-inputs.md +170 -0
  23. alphatonic-0.1.1/docs/how-to/read-a-tearsheet.md +96 -0
  24. alphatonic-0.1.1/docs/how-to/run-a-study.md +162 -0
  25. alphatonic-0.1.1/docs/how-to/save-and-reload.md +71 -0
  26. alphatonic-0.1.1/docs/how-to/troubleshooting.md +89 -0
  27. alphatonic-0.1.1/docs/index.md +8 -0
  28. alphatonic-0.1.1/docs/reference/api.md +95 -0
  29. alphatonic-0.1.1/docs/reference/cli.md +45 -0
  30. alphatonic-0.1.1/docs/reference/results.md +246 -0
  31. alphatonic-0.1.1/docs/tutorials/first-evaluation.md +129 -0
  32. alphatonic-0.1.1/pyproject.toml +129 -0
  33. alphatonic-0.1.1/src/alphatonic/__init__.py +41 -0
  34. alphatonic-0.1.1/src/alphatonic/__main__.py +5 -0
  35. alphatonic-0.1.1/src/alphatonic/cli.py +80 -0
  36. alphatonic-0.1.1/src/alphatonic/config.py +240 -0
  37. alphatonic-0.1.1/src/alphatonic/cross_section.py +177 -0
  38. alphatonic-0.1.1/src/alphatonic/demo.py +62 -0
  39. alphatonic-0.1.1/src/alphatonic/evaluation.py +344 -0
  40. alphatonic-0.1.1/src/alphatonic/export.py +92 -0
  41. alphatonic-0.1.1/src/alphatonic/inputs.py +213 -0
  42. alphatonic-0.1.1/src/alphatonic/persistence.py +171 -0
  43. alphatonic-0.1.1/src/alphatonic/progress.py +45 -0
  44. alphatonic-0.1.1/src/alphatonic/py.typed +0 -0
  45. alphatonic-0.1.1/src/alphatonic/report/__init__.py +622 -0
  46. alphatonic-0.1.1/src/alphatonic/report/board.py +147 -0
  47. alphatonic-0.1.1/src/alphatonic/report/figures.py +270 -0
  48. alphatonic-0.1.1/src/alphatonic/report/page.py +39 -0
  49. alphatonic-0.1.1/src/alphatonic/report/static/alphatonic.css +165 -0
  50. alphatonic-0.1.1/src/alphatonic/report/static/pico.LICENSE.md +21 -0
  51. alphatonic-0.1.1/src/alphatonic/report/static/pico.classless.min.css +4 -0
  52. alphatonic-0.1.1/src/alphatonic/report/templates/base.html +13 -0
  53. alphatonic-0.1.1/src/alphatonic/report/templates/board.html +113 -0
  54. alphatonic-0.1.1/src/alphatonic/report/templates/tearsheet.html +435 -0
  55. alphatonic-0.1.1/src/alphatonic/report/ts_figures.py +157 -0
  56. alphatonic-0.1.1/src/alphatonic/returns.py +72 -0
  57. alphatonic-0.1.1/src/alphatonic/server.py +145 -0
  58. alphatonic-0.1.1/src/alphatonic/signal_persistence.py +197 -0
  59. alphatonic-0.1.1/src/alphatonic/stats.py +371 -0
  60. alphatonic-0.1.1/src/alphatonic/study.py +663 -0
  61. alphatonic-0.1.1/src/alphatonic/time_series.py +505 -0
  62. alphatonic-0.1.1/tests/conftest.py +68 -0
  63. alphatonic-0.1.1/tests/reference.py +375 -0
  64. alphatonic-0.1.1/tests/test_calendar.py +112 -0
  65. alphatonic-0.1.1/tests/test_cli.py +76 -0
  66. alphatonic-0.1.1/tests/test_config.py +159 -0
  67. alphatonic-0.1.1/tests/test_cross_section.py +155 -0
  68. alphatonic-0.1.1/tests/test_demo.py +52 -0
  69. alphatonic-0.1.1/tests/test_docs.py +98 -0
  70. alphatonic-0.1.1/tests/test_evaluation.py +301 -0
  71. alphatonic-0.1.1/tests/test_export.py +70 -0
  72. alphatonic-0.1.1/tests/test_inference.py +129 -0
  73. alphatonic-0.1.1/tests/test_inputs.py +236 -0
  74. alphatonic-0.1.1/tests/test_persistence.py +158 -0
  75. alphatonic-0.1.1/tests/test_progress.py +29 -0
  76. alphatonic-0.1.1/tests/test_public_api.py +65 -0
  77. alphatonic-0.1.1/tests/test_reference_equivalence.py +150 -0
  78. alphatonic-0.1.1/tests/test_report.py +99 -0
  79. alphatonic-0.1.1/tests/test_returns.py +94 -0
  80. alphatonic-0.1.1/tests/test_server.py +233 -0
  81. alphatonic-0.1.1/tests/test_signal_persistence.py +195 -0
  82. alphatonic-0.1.1/tests/test_stats.py +270 -0
  83. alphatonic-0.1.1/tests/test_study.py +381 -0
  84. alphatonic-0.1.1/tests/test_time_series.py +276 -0
@@ -0,0 +1,199 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ *.lcov
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ # Pipfile.lock
97
+
98
+ # uv
99
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # uv.lock
103
+
104
+ # poetry
105
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
107
+ # commonly ignored for libraries.
108
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109
+ # poetry.lock
110
+ # poetry.toml
111
+
112
+ # pdm
113
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116
+ # pdm.lock
117
+ # pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # pixi
122
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123
+ # pixi.lock
124
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125
+ # in the .venv directory. It is recommended not to include this directory in version control.
126
+ .pixi/*
127
+ !.pixi/config.toml
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Environments
133
+ .env
134
+ .envrc
135
+ .venv
136
+ env/
137
+ venv/
138
+ ENV/
139
+ env.bak/
140
+ venv.bak/
141
+
142
+ # Spyder project settings
143
+ .spyderproject
144
+ .spyproject
145
+
146
+ # Rope project settings
147
+ .ropeproject
148
+
149
+ # mkdocs/Zensical documentation
150
+ /site
151
+
152
+ # mypy
153
+ .mypy_cache/
154
+ .dmypy.json
155
+ dmypy.json
156
+
157
+ # Pyre type checker
158
+ .pyre/
159
+
160
+ # pytype static type analyzer
161
+ .pytype/
162
+
163
+ # Cython debug symbols
164
+ cython_debug/
165
+
166
+ # PyCharm
167
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
168
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
169
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
170
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
171
+ # .idea/
172
+
173
+ # Abstra
174
+ # Abstra is an AI-powered process automation framework.
175
+ # Ignore directories containing user credentials, local state, and settings.
176
+ # Learn more at https://abstra.io/docs
177
+ .abstra/
178
+
179
+ # Visual Studio Code
180
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
181
+ # can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
182
+ # and can be added to the global gitignore or merged into this file. However, if you prefer, you
183
+ # could uncomment the following to ignore the entire vscode folder
184
+ # .vscode/
185
+ # Temporary file for partial code execution
186
+ tempCodeRunnerFile.py
187
+
188
+ # Ruff stuff:
189
+ .ruff_cache/
190
+
191
+ # PyPI configuration file
192
+ .pypirc
193
+
194
+ # Documentation site: `zensical build` writes both
195
+ site/
196
+ .cache/
197
+
198
+ # The README example writes its tearsheet to the working directory
199
+ /tearsheet.html
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes are listed here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project aims to follow
5
+ [Semantic Versioning](https://semver.org/) once it reaches 1.0.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.1] - 2026-10-29
10
+
11
+ ### Added
12
+
13
+ - alphatonic is on [PyPI](https://pypi.org/project/alphatonic/): install it with
14
+ `python -m pip install "alphatonic[report]"`.
15
+
16
+ ## [0.1.0] - 2026-10-29
17
+
18
+ First public version.
@@ -0,0 +1,174 @@
1
+ # Contributing
2
+
3
+ Bug reports with a minimal, runnable example are welcome. Use
4
+ `alphatonic.demo.synthetic_market` to share an example without market data. For usage questions,
5
+ check the [documentation](README.md) or open an issue.
6
+
7
+ Statistical changes need a source or a fixed-seed simulation in `tests/test_inference.py`, plus an
8
+ update to [the methodology](docs/explanation/methodology.md). Add a changelog entry for changes
9
+ users would notice. Work on a branch and open a pull request.
10
+
11
+ By contributing, you agree that your contribution is licensed under the MIT License.
12
+
13
+ ## Set up local development
14
+
15
+ Local development uses Python 3.13 (`.python-version`); the library supports Python 3.11–3.14. Use
16
+ [uv](https://docs.astral.sh/uv/). Run commands from the repository root:
17
+
18
+ ```sh
19
+ uv sync --all-extras --locked # create .venv with the dev tools and the report extra
20
+ uv run pytest # in parallel, under 40 seconds
21
+ uv run ruff check .
22
+ uv run ruff format --check .
23
+ uv run pyright # type-check src/ using Python 3.11 compatibility
24
+ ```
25
+
26
+ Pyright checks `src/` in standard mode using the settings in `pyproject.toml`. The dev group
27
+ includes pandas type stubs. Select the project's `.venv` interpreter in your editor so Pylance uses
28
+ the same dependencies; it also reads the shared Pyright settings.
29
+
30
+ The tests use synthetic data and temporary directories only. They run with every warning turned into
31
+ an error (`filterwarnings = ["error"]`), so a deprecation in pandas, NumPy or plotly fails the suite
32
+ instead of reaching users.
33
+
34
+ The suite runs on all cores with [pytest-xdist](https://pytest-xdist.readthedocs.io/) and must
35
+ finish in under 40 seconds. Add `-n 0` to run it in one process, for example with `--pdb`, and
36
+ `--durations=10` to see the slowest tests. Keep new tests fast: use small synthetic panels,
37
+ `time_series={"bootstrap_samples": 0}` when the bootstrap is not under test, and a coarse
38
+ `rolling_step` when the rolling windows are not.
39
+
40
+ ## Where changes belong
41
+
42
+ | Change | Module | Tests |
43
+ | --- | --- | --- |
44
+ | Options and their validation | `config.py` | `test_config.py` |
45
+ | Input checks, alignment, the evaluation window | `inputs.py` | `test_inputs.py`, `test_calendar.py` |
46
+ | Forward-return labels | `returns.py` | `test_returns.py` |
47
+ | Correlations, HAC, score buckets | `stats.py` | `test_stats.py` |
48
+ | Cross-sectional IC | `cross_section.py` | `test_cross_section.py` |
49
+ | Time-series windows, bootstrap, monthly statistics | `time_series.py` | `test_time_series.py` |
50
+ | Signal persistence | `signal_persistence.py` | `test_signal_persistence.py` |
51
+ | `evaluate`, `Evaluation`, metrics | `evaluation.py` | `test_evaluation.py` |
52
+ | JSON values of results (`to_dict`) | `export.py` | `test_export.py` |
53
+ | Saving and loading | `persistence.py` | `test_persistence.py` |
54
+ | Studies: trials, the holdout, the board | `study.py` | `test_study.py` |
55
+ | The tearsheet | `report/__init__.py`, `report/*figures.py`, `report/templates/` | `test_report.py` |
56
+ | Styles shared by both pages | `report/page.py`, `report/static/` | `test_report.py` |
57
+ | The list of trials and its server | `report/board.py`, `server.py` | `test_server.py` |
58
+ | The `alphatonic` command | `cli.py` | `test_cli.py` |
59
+ | Demo data | `demo.py` | `test_demo.py` |
60
+ | Documentation examples | `docs/` | `test_docs.py` |
61
+
62
+ Preserve the explicit handling of gaps, ties, constants and unavailable statistics: a statistic that
63
+ cannot be computed is `NaN` with a status, never zero.
64
+
65
+ ## The pages' stylesheet
66
+
67
+ The tearsheet and the list of trials share one stylesheet, written into each page: [Pico
68
+ CSS](https://picocss.com) followed by `report/static/alphatonic.css`. Pico styles the elements
69
+ themselves, so templates use semantic HTML (`article`, `details`, `nav`, `table`) and add a class
70
+ only where Pico has nothing to say, such as a dense numeric table. Put new rules in
71
+ `alphatonic.css`; never edit the vendored file. The accent colour, royal blue (`#4169e1`), is set
72
+ there by overriding Pico's `--pico-primary` variables, with a lighter tint for dark mode. The
73
+ charts' colours are in `report/figures.py`.
74
+
75
+ `report/static/pico.classless.min.css` is Pico 2.1.1 from the npm package `@picocss/pico`, with its
76
+ licence beside it as `pico.LICENSE.md`. To update it, download the package tarball from the npm
77
+ registry, check it against the registry's `integrity` hash, copy the same file and the licence,
78
+ change the version in `report/page.py` and `tests/test_report.py`, and look at both pages in a
79
+ browser. Check the study board in light and dark mode; the tearsheet uses a light theme.
80
+
81
+ ## The reference implementation
82
+
83
+ `tests/reference.py` holds the original, straightforward formulation of the cross-sectional and
84
+ time-series evaluation: one timestamp or window at a time, with pandas. The optimised code in `src/`
85
+ must produce the same tables, and `tests/test_reference_equivalence.py` asserts it on randomised
86
+ data with gaps, ties, delays, constants and varied bucket counts. When you change statistical
87
+ behaviour on purpose, change the reference in the same commit and say so in the pull request. When
88
+ you optimise, leave the reference alone.
89
+
90
+ `tests/test_inference.py` runs fixed-seed simulations that pin the calibration of the inference: a
91
+ factor without skill must not be declared significant much more often than 5% of the time.
92
+
93
+ ## Supported versions
94
+
95
+ CI runs the suite on Python 3.11 to 3.14, on the newest dependencies, and on the **lowest**
96
+ supported versions (`uv run --resolution lowest-direct`). When you raise a lower bound in
97
+ `pyproject.toml` say why in the pull request. Run the lowest-bound check locally with:
98
+
99
+ ```sh
100
+ uv run --isolated --resolution lowest-direct --python 3.11 pytest
101
+ ```
102
+
103
+ ## Documentation
104
+
105
+ The site is built with [Zensical](https://zensical.org/) and the API pages are rendered by
106
+ mkdocstrings from docstrings (Google style):
107
+
108
+ ```sh
109
+ uv run --group docs zensical serve # preview
110
+ uv run --group docs zensical build --strict # what CI runs
111
+ ```
112
+
113
+ Python code blocks in the root Markdown files and `docs/` are executed by `tests/test_docs.py`, in order, within
114
+ one namespace per page and in a temporary directory. Put `<!-- notest -->` on the line above a block
115
+ that must not run (for example one that needs another library). The structure follows
116
+ [Diátaxis](https://diataxis.fr/): tutorials, how-to guides, reference, explanation. Keep reference
117
+ pages factual, and put reasons in the explanation pages. Tutorials should lead a new user through
118
+ one working example. How-to guides should solve a specific task. Use short, direct sentences and
119
+ British spelling. Check descriptions against the code when editing; a runnable example alone does
120
+ not prove that the surrounding explanation is correct.
121
+
122
+ ### Shared pages
123
+
124
+ Edit `README.md` for the site home page, `CHANGELOG.md` for the changelog, and this file for
125
+ contributor guidance. The matching pages under `docs/` include these files at build time using
126
+ Zensical's built-in Jinja support. `docs/_includes/` contains symlinks to the three root files;
127
+ it is excluded from site navigation and output. The page filters adapt repository-relative links for the
128
+ site. Use inline Markdown links rather than reference-style links so these filters can adjust them.
129
+
130
+ The example tests expand the same includes before running code blocks. After changing links,
131
+ build the site with `--strict` and check the rendered destinations. Shared files are watched
132
+ when running `zensical serve`.
133
+
134
+ ## Releasing
135
+
136
+ A release is a tag `X.Y.Z` on `master`, without a `v` prefix, equal to the version in
137
+ `pyproject.toml`. Pushing the tag runs `.github/workflows/release.yml`, which builds the
138
+ documentation from the tag and publishes it to GitHub Pages at
139
+ <https://mblum.github.io/alphatonic/>, and builds the distributions from the tag and uploads them
140
+ to [PyPI](https://pypi.org/project/alphatonic/). The workflow stops before it publishes anything if
141
+ the tag is not on `master`, does not match the version, or has no section in `CHANGELOG.md`, or if
142
+ the documentation does not build. Tags of any other form, such as `v1.0.0` or `1.0.0rc1`, do not
143
+ start it.
144
+
145
+ 1. On a branch, set the version with `uv version X.Y.Z` (or `uv version --bump minor`), which
146
+ updates `pyproject.toml` and `uv.lock`. In `CHANGELOG.md`, rename `[Unreleased]` to
147
+ `[X.Y.Z] - YYYY-MM-DD` and add an empty `[Unreleased]` above it. Open a pull request and
148
+ merge it once CI is green.
149
+ 2. Tag the merge commit on `master` and push the tag:
150
+
151
+ ```sh
152
+ git switch master && git pull --ff-only
153
+ git tag -a X.Y.Z -m "alphatonic X.Y.Z"
154
+ git push origin X.Y.Z
155
+ ```
156
+
157
+ 3. Check that the Release workflow succeeds. If the check or the documentation build fails,
158
+ nothing has been published: delete the tag (`git push --delete origin X.Y.Z`, then
159
+ `git tag -d X.Y.Z`), fix the cause on `master` and tag again. If the deployment or the upload
160
+ fails, fix the settings below and re-run the failed jobs. PyPI never accepts a version twice,
161
+ even after it is deleted, so once the upload has succeeded a fix needs a new version.
162
+
163
+ GitHub Pages needs two settings, made once by a repository admin. Under **Settings → Pages**, set
164
+ the source to **GitHub Actions**. Under **Settings → Environments → github-pages**, add a
165
+ deployment tag rule `[0-9]*.[0-9]*.[0-9]*`: by default the environment accepts deployments only
166
+ from `master`, and it rejects the tag.
167
+
168
+ The upload uses [trusted publishing](https://docs.pypi.org/trusted-publishers/), so the
169
+ repository keeps no PyPI token. On PyPI, add a GitHub publisher with owner `mblum`, repository
170
+ `alphatonic`, workflow `release.yml` and environment `pypi`. Before the first release the project
171
+ does not exist yet, so add it as a pending publisher at
172
+ <https://pypi.org/manage/account/publishing/>; later, a project owner manages it under the
173
+ project's **Publishing** settings. In GitHub, under **Settings → Environments**, create the
174
+ environment `pypi` and give it the same deployment tag rule, so that only release tags can upload.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manuel Blum
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.5
2
+ Name: alphatonic
3
+ Version: 0.1.1
4
+ Summary: Evaluate predictive signals with cross-sectional and time-series information coefficients, dependence-aware uncertainty, and offline tearsheets.
5
+ Project-URL: Homepage, https://github.com/mblum/alphatonic
6
+ Project-URL: Documentation, https://mblum.github.io/alphatonic/
7
+ Project-URL: Source, https://github.com/mblum/alphatonic
8
+ Project-URL: Issues, https://github.com/mblum/alphatonic/issues
9
+ Project-URL: Changelog, https://github.com/mblum/alphatonic/blob/HEAD/CHANGELOG.md
10
+ Author: Manuel Blum
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: alpha,backtesting,factor,finance,information coefficient,quant,signal
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Office/Business :: Financial :: Investment
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: numpy>=1.26
29
+ Requires-Dist: pandas>=2.2.2
30
+ Requires-Dist: pydantic>=2.6
31
+ Provides-Extra: report
32
+ Requires-Dist: jinja2<4,>=3.1; extra == 'report'
33
+ Requires-Dist: plotly<7,>=6.1; extra == 'report'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # alphatonic
37
+
38
+ [![CI](https://github.com/mblum/alphatonic/actions/workflows/ci.yml/badge.svg)](https://github.com/mblum/alphatonic/actions/workflows/ci.yml)
39
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
40
+
41
+ alphatonic is a Python library for testing trading signals. Give it scores and prices to measure how
42
+ well the scores predict future returns. Inspect the results as pandas tables or open an interactive
43
+ HTML report offline.
44
+
45
+ ```python
46
+ from alphatonic import evaluate
47
+ from alphatonic.demo import synthetic_market
48
+
49
+ factor, prices = synthetic_market(n_assets=30, n_bars=500, ic=0.04, seed=7) # or your own tables
50
+ result = evaluate(factor, prices, horizons=[1, 5])
51
+
52
+ result.summary.query("method == 'spearman'")[["horizon", "mean", "ci95_lower", "ci95_upper"]]
53
+ result.tearsheet("tearsheet.html")
54
+ ```
55
+
56
+ ## What it measures
57
+
58
+ An **information coefficient (IC)** measures the association between a score and a future return. A
59
+ positive IC means higher scores tend to precede higher returns.
60
+
61
+ - **Cross-sectional IC:** do higher-scored assets outperform lower-scored assets at each bar?
62
+ - **Time-series IC:** does each asset earn higher returns after higher scores? This also works
63
+ with a single asset. By default, returns are divided by volatility estimated from past prices.
64
+ - **Signal persistence:** how much do scores, ranks and bucket membership change over time?
65
+
66
+ Both IC analyses run on every evaluation. Confidence intervals account for temporal dependence using
67
+ Newey–West standard errors and a block bootstrap. If a statistic cannot be computed, it is `NaN`
68
+ with a reason, such as `constant_signal` or `insufficient_assets`.
69
+
70
+ Horizons count rows of your price table. A return needs an unbroken path of prices; missing prices
71
+ are never filled. Results can be saved, reloaded and used to rebuild reports.
72
+
73
+ For repeated experiments, a `Study` saves each completed trial, counts variants of the same idea and
74
+ keeps in-sample return labels out of a holdout period. Browse its results with `alphatonic serve`.
75
+
76
+ ## Install
77
+
78
+ Python 3.11 or newer. Install from [PyPI](https://pypi.org/project/alphatonic/):
79
+
80
+ ```sh
81
+ python -m pip install "alphatonic[report]"
82
+ ```
83
+
84
+ `alphatonic[report]` adds plotly and jinja2 for the tearsheet; evaluation itself depends only on
85
+ NumPy, pandas and pydantic.
86
+
87
+ ## Inputs
88
+
89
+ - `prices`: a `DataFrame`, one row per bar, one column per asset, positive prices, `NaN` for
90
+ missing.
91
+ - `factor`: a `DataFrame` of scores, or a long-format `Series` indexed by
92
+ `(timestamp, asset)`. Scores may cover a subset of the price rows and assets. Higher scores
93
+ mean higher expected returns.
94
+
95
+ See [prepare factor and prices](docs/how-to/prepare-inputs.md) for alignment rules, timing, and a
96
+ look-ahead check.
97
+
98
+ ## Documentation
99
+
100
+ | Need | Guide |
101
+ | --- | --- |
102
+ | First run | [Your first evaluation](docs/tutorials/first-evaluation.md) |
103
+ | Your own data | [Prepare factor and prices](docs/how-to/prepare-inputs.md) |
104
+ | Choose windows and sample requirements | [Configure an evaluation](docs/how-to/configure-evaluation.md) |
105
+ | Read the report | [Read a tearsheet](docs/how-to/read-a-tearsheet.md) |
106
+ | Save results | [Save and reload results](docs/how-to/save-and-reload.md) |
107
+ | A statistic is missing | [Troubleshooting](docs/how-to/troubleshooting.md) |
108
+ | Many variants, one holdout | [Keep every trial in a study](docs/how-to/run-a-study.md) |
109
+ | Tables and metric names | [Results and metrics](docs/reference/results.md) |
110
+ | What the numbers mean | [Evaluation methodology](docs/explanation/methodology.md) |
111
+ | What it does not do | [Design decisions](docs/explanation/design.md) |
112
+
113
+ See the [changelog](CHANGELOG.md) for release notes.
114
+
115
+ Preview the site with `uv run --group docs zensical serve`.
116
+
117
+ ## What it does not do
118
+
119
+ alphatonic measures predictive association and signal persistence. It does not simulate portfolios,
120
+ traded turnover, costs or P&L. It does not build factors or neutralise them by group. It cannot
121
+ check whether your factor uses future information, and a `Study` counts only the trials it saves.
122
+ See [design decisions](docs/explanation/design.md).
123
+
124
+ ## Development
125
+
126
+ ```sh
127
+ uv sync --all-extras --locked
128
+ uv run pytest
129
+ uv run ruff check . && uv run ruff format --check .
130
+ uv run pyright
131
+ ```
132
+
133
+ See [Contributing](CONTRIBUTING.md) for setup, tests and the release process.
134
+
135
+ ## License
136
+
137
+ [MIT License](LICENSE). Copyright 2026 Manuel Blum.
@@ -0,0 +1,102 @@
1
+ # alphatonic
2
+
3
+ [![CI](https://github.com/mblum/alphatonic/actions/workflows/ci.yml/badge.svg)](https://github.com/mblum/alphatonic/actions/workflows/ci.yml)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
5
+
6
+ alphatonic is a Python library for testing trading signals. Give it scores and prices to measure how
7
+ well the scores predict future returns. Inspect the results as pandas tables or open an interactive
8
+ HTML report offline.
9
+
10
+ ```python
11
+ from alphatonic import evaluate
12
+ from alphatonic.demo import synthetic_market
13
+
14
+ factor, prices = synthetic_market(n_assets=30, n_bars=500, ic=0.04, seed=7) # or your own tables
15
+ result = evaluate(factor, prices, horizons=[1, 5])
16
+
17
+ result.summary.query("method == 'spearman'")[["horizon", "mean", "ci95_lower", "ci95_upper"]]
18
+ result.tearsheet("tearsheet.html")
19
+ ```
20
+
21
+ ## What it measures
22
+
23
+ An **information coefficient (IC)** measures the association between a score and a future return. A
24
+ positive IC means higher scores tend to precede higher returns.
25
+
26
+ - **Cross-sectional IC:** do higher-scored assets outperform lower-scored assets at each bar?
27
+ - **Time-series IC:** does each asset earn higher returns after higher scores? This also works
28
+ with a single asset. By default, returns are divided by volatility estimated from past prices.
29
+ - **Signal persistence:** how much do scores, ranks and bucket membership change over time?
30
+
31
+ Both IC analyses run on every evaluation. Confidence intervals account for temporal dependence using
32
+ Newey–West standard errors and a block bootstrap. If a statistic cannot be computed, it is `NaN`
33
+ with a reason, such as `constant_signal` or `insufficient_assets`.
34
+
35
+ Horizons count rows of your price table. A return needs an unbroken path of prices; missing prices
36
+ are never filled. Results can be saved, reloaded and used to rebuild reports.
37
+
38
+ For repeated experiments, a `Study` saves each completed trial, counts variants of the same idea and
39
+ keeps in-sample return labels out of a holdout period. Browse its results with `alphatonic serve`.
40
+
41
+ ## Install
42
+
43
+ Python 3.11 or newer. Install from [PyPI](https://pypi.org/project/alphatonic/):
44
+
45
+ ```sh
46
+ python -m pip install "alphatonic[report]"
47
+ ```
48
+
49
+ `alphatonic[report]` adds plotly and jinja2 for the tearsheet; evaluation itself depends only on
50
+ NumPy, pandas and pydantic.
51
+
52
+ ## Inputs
53
+
54
+ - `prices`: a `DataFrame`, one row per bar, one column per asset, positive prices, `NaN` for
55
+ missing.
56
+ - `factor`: a `DataFrame` of scores, or a long-format `Series` indexed by
57
+ `(timestamp, asset)`. Scores may cover a subset of the price rows and assets. Higher scores
58
+ mean higher expected returns.
59
+
60
+ See [prepare factor and prices](docs/how-to/prepare-inputs.md) for alignment rules, timing, and a
61
+ look-ahead check.
62
+
63
+ ## Documentation
64
+
65
+ | Need | Guide |
66
+ | --- | --- |
67
+ | First run | [Your first evaluation](docs/tutorials/first-evaluation.md) |
68
+ | Your own data | [Prepare factor and prices](docs/how-to/prepare-inputs.md) |
69
+ | Choose windows and sample requirements | [Configure an evaluation](docs/how-to/configure-evaluation.md) |
70
+ | Read the report | [Read a tearsheet](docs/how-to/read-a-tearsheet.md) |
71
+ | Save results | [Save and reload results](docs/how-to/save-and-reload.md) |
72
+ | A statistic is missing | [Troubleshooting](docs/how-to/troubleshooting.md) |
73
+ | Many variants, one holdout | [Keep every trial in a study](docs/how-to/run-a-study.md) |
74
+ | Tables and metric names | [Results and metrics](docs/reference/results.md) |
75
+ | What the numbers mean | [Evaluation methodology](docs/explanation/methodology.md) |
76
+ | What it does not do | [Design decisions](docs/explanation/design.md) |
77
+
78
+ See the [changelog](CHANGELOG.md) for release notes.
79
+
80
+ Preview the site with `uv run --group docs zensical serve`.
81
+
82
+ ## What it does not do
83
+
84
+ alphatonic measures predictive association and signal persistence. It does not simulate portfolios,
85
+ traded turnover, costs or P&L. It does not build factors or neutralise them by group. It cannot
86
+ check whether your factor uses future information, and a `Study` counts only the trials it saves.
87
+ See [design decisions](docs/explanation/design.md).
88
+
89
+ ## Development
90
+
91
+ ```sh
92
+ uv sync --all-extras --locked
93
+ uv run pytest
94
+ uv run ruff check . && uv run ruff format --check .
95
+ uv run pyright
96
+ ```
97
+
98
+ See [Contributing](CONTRIBUTING.md) for setup, tests and the release process.
99
+
100
+ ## License
101
+
102
+ [MIT License](LICENSE). Copyright 2026 Manuel Blum.
@@ -0,0 +1 @@
1
+ ../../CHANGELOG.md
@@ -0,0 +1 @@
1
+ ../../CONTRIBUTING.md
@@ -0,0 +1 @@
1
+ ../../README.md
@@ -0,0 +1,6 @@
1
+ ---
2
+ render_macros: true
3
+ ---
4
+
5
+ {# Edit CHANGELOG.md in the repository root. #}
6
+ {% include "CHANGELOG.md" %}
@@ -0,0 +1,8 @@
1
+ ---
2
+ render_macros: true
3
+ ---
4
+
5
+ {# Edit CONTRIBUTING.md in the repository root. #}
6
+ {% filter replace("](docs/", "](../") | replace("](README.md)", "](../index.md)") | replace("](CHANGELOG.md)", "](../changelog.md)") %}
7
+ {% include "CONTRIBUTING.md" %}
8
+ {% endfilter %}