alphaverify 0.1.0__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 (59) hide show
  1. alphaverify-0.1.0/LICENSE +121 -0
  2. alphaverify-0.1.0/PKG-INFO +140 -0
  3. alphaverify-0.1.0/README.md +108 -0
  4. alphaverify-0.1.0/pyproject.toml +76 -0
  5. alphaverify-0.1.0/setup.cfg +4 -0
  6. alphaverify-0.1.0/src/alphaverify/__init__.py +1 -0
  7. alphaverify-0.1.0/src/alphaverify/cli.py +185 -0
  8. alphaverify-0.1.0/src/alphaverify/domain/__init__.py +1 -0
  9. alphaverify-0.1.0/src/alphaverify/domain/barrier.py +356 -0
  10. alphaverify-0.1.0/src/alphaverify/domain/combination.py +98 -0
  11. alphaverify-0.1.0/src/alphaverify/domain/features.py +76 -0
  12. alphaverify-0.1.0/src/alphaverify/domain/multiple_testing.py +29 -0
  13. alphaverify-0.1.0/src/alphaverify/domain/notation.py +57 -0
  14. alphaverify-0.1.0/src/alphaverify/domain/scoring.py +101 -0
  15. alphaverify-0.1.0/src/alphaverify/domain/shift.py +74 -0
  16. alphaverify-0.1.0/src/alphaverify/domain/tensor_runtime.py +42 -0
  17. alphaverify-0.1.0/src/alphaverify/domain/torch_features.py +137 -0
  18. alphaverify-0.1.0/src/alphaverify/domain/validation.py +228 -0
  19. alphaverify-0.1.0/src/alphaverify/infrastructure/__init__.py +1 -0
  20. alphaverify-0.1.0/src/alphaverify/infrastructure/artifact_history.py +66 -0
  21. alphaverify-0.1.0/src/alphaverify/infrastructure/artifact_io.py +149 -0
  22. alphaverify-0.1.0/src/alphaverify/infrastructure/market_data.py +67 -0
  23. alphaverify-0.1.0/src/alphaverify/infrastructure/scaffold.py +67 -0
  24. alphaverify-0.1.0/src/alphaverify/infrastructure/workspace.py +223 -0
  25. alphaverify-0.1.0/src/alphaverify/infrastructure/workspace_plugins.py +52 -0
  26. alphaverify-0.1.0/src/alphaverify/pipeline/__init__.py +1 -0
  27. alphaverify-0.1.0/src/alphaverify/pipeline/context.py +98 -0
  28. alphaverify-0.1.0/src/alphaverify/pipeline/reporting.py +116 -0
  29. alphaverify-0.1.0/src/alphaverify/pipeline/step_01_surface.py +112 -0
  30. alphaverify-0.1.0/src/alphaverify/pipeline/step_02_shift.py +96 -0
  31. alphaverify-0.1.0/src/alphaverify/pipeline/step_03_validation.py +183 -0
  32. alphaverify-0.1.0/src/alphaverify/pipeline/step_04_selection.py +107 -0
  33. alphaverify-0.1.0/src/alphaverify/pipeline/step_05_forecast.py +245 -0
  34. alphaverify-0.1.0/src/alphaverify/presentation/__init__.py +1 -0
  35. alphaverify-0.1.0/src/alphaverify/presentation/bin_figures.py +173 -0
  36. alphaverify-0.1.0/src/alphaverify/presentation/display.py +44 -0
  37. alphaverify-0.1.0/src/alphaverify/presentation/plot_style.py +117 -0
  38. alphaverify-0.1.0/src/alphaverify/presentation/workbooks.py +330 -0
  39. alphaverify-0.1.0/src/alphaverify.egg-info/PKG-INFO +140 -0
  40. alphaverify-0.1.0/src/alphaverify.egg-info/SOURCES.txt +57 -0
  41. alphaverify-0.1.0/src/alphaverify.egg-info/dependency_links.txt +1 -0
  42. alphaverify-0.1.0/src/alphaverify.egg-info/entry_points.txt +2 -0
  43. alphaverify-0.1.0/src/alphaverify.egg-info/requires.txt +7 -0
  44. alphaverify-0.1.0/src/alphaverify.egg-info/top_level.txt +1 -0
  45. alphaverify-0.1.0/tests/test_architecture_boundaries.py +129 -0
  46. alphaverify-0.1.0/tests/test_forecast_pipeline.py +183 -0
  47. alphaverify-0.1.0/tests/test_scoring_parity.py +224 -0
  48. alphaverify-0.1.0/tests/test_selection_pipeline.py +87 -0
  49. alphaverify-0.1.0/tests/test_validation_pipeline.py +232 -0
  50. alphaverify-0.1.0/tests/test_workspace_data.py +277 -0
  51. alphaverify-0.1.0/workspaces/_shared/snapshots.py +14 -0
  52. alphaverify-0.1.0/workspaces/_shared/yahoo.py +42 -0
  53. alphaverify-0.1.0/workspaces/btc_daily/data.py +103 -0
  54. alphaverify-0.1.0/workspaces/btc_daily/plugin.py +73 -0
  55. alphaverify-0.1.0/workspaces/btc_daily/universe.json +930 -0
  56. alphaverify-0.1.0/workspaces/btc_hourly/data.py +60 -0
  57. alphaverify-0.1.0/workspaces/btc_hourly/universe.json +69 -0
  58. alphaverify-0.1.0/workspaces/nasdaq_daily/data.py +64 -0
  59. alphaverify-0.1.0/workspaces/nasdaq_daily/universe.json +830 -0
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1,140 @@
1
+ Metadata-Version: 2.4
2
+ Name: alphaverify
3
+ Version: 0.1.0
4
+ Summary: Conditional barrier-touch probability pipeline.
5
+ Author: chengmarc
6
+ License-Expression: CC0-1.0
7
+ Project-URL: Homepage, https://github.com/doubletrends/alpha-verify
8
+ Project-URL: Repository, https://github.com/doubletrends/alpha-verify
9
+ Project-URL: Issues, https://github.com/doubletrends/alpha-verify/issues
10
+ Keywords: quantitative-finance,technical-analysis,hypothesis-testing,multiple-testing,barrier-touch,market-research
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: GPU :: NVIDIA CUDA
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Financial and Insurance Industry
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Office/Business :: Financial :: Investment
20
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy>=2.0
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: matplotlib>=3.8
27
+ Requires-Dist: yfinance>=0.2
28
+ Requires-Dist: openpyxl>=3.1
29
+ Requires-Dist: safetensors>=0.5
30
+ Requires-Dist: torch>=2.0
31
+ Dynamic: license-file
32
+
33
+ <div align="center">
34
+ <h1><strong>AlphaVerify</strong> - Multi-Asset Financial Strategy Debunker</h1>
35
+ <img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/alphaverify-icon-old.svg" alt="AlphaVerify icon" width="180">
36
+ <br>
37
+ <h3>Most “technical” indicators are essentially astrology with better charts.<br>
38
+ AlphaVerify is built to put an end to all that bullshit.</h3>
39
+ </div>
40
+
41
+ <p align="center">
42
+ <picture>
43
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/stats-dark.svg">
44
+ <img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/stats-light.svg" width="100%" alt="1,000 synthetic OHLC histories; 552 NASDAQ condition bins tested, across 57 features; 25 bins cleared, where pure chance predicts 27.6">
45
+ </picture>
46
+ </p>
47
+
48
+ # How to look at the figures
49
+ Each figure tests one market condition.
50
+
51
+ **Left:** while the condition holds, is the NASDAQ more likely (red) or less likely (blue) to move by a given percentage within 30 days?
52
+ **Right:** the same test run on 1,000 random markets that contain no signal. To count as an edge, the real score (blue line) has to beat 95% of them (dashed line).
53
+
54
+ ## The golden cross - folklore
55
+
56
+ Traders everywhere watch for the 50-day average to cross above the 200-day. Once it runs about 10% above, the heatmap looks decisive: the odds of a 4% drop jump, the odds of a 4% rise fall, a **24.5-point** swing. It looks like a real edge. It's folklore: random markets draw one at least this strong 8.4% of the time.
57
+
58
+ <p align="center">
59
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__ma_cross_50_200__bin_09.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__ma_cross_50_200__bin_09.png" width="100%" alt="MA Cross 50-200 bin 9: a 24.5 percentage-point contrast below the null 95th percentile"></a>
60
+ </p>
61
+
62
+ ## Above the 200-day - a textbook mirror
63
+
64
+ "Stay long while price is above the 200-day" is trend following's first rule. With price 4% to 6% above it, the picture is a near-perfect mirror: rises more likely, drops much less likely, a **27.4-point** swing. Random markets draw one at least this strong 23% of the time.
65
+
66
+ <p align="center">
67
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__ma_ratio_200__bin_04.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__ma_ratio_200__bin_04.png" width="100%" alt="MA Ratio-200 bin 4: a 27.4 percentage-point contrast well inside the synthetic null"></a>
68
+ </p>
69
+
70
+ ## Low bond yields - the 42-point edge
71
+
72
+ Cheap money lifts stocks; everyone knows that. When the 10-year Treasury yield sat below 1.34%, the NASDAQ was far more likely to rally 8% within a month: a **42-point** swing that grows steadily with time. It looks like a macro regime you could trade. It isn't. Random markets draw one at least this strong 7.6% of the time. Close, but not an edge.
73
+
74
+ <p align="center">
75
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__tnx_level__bin_01.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__tnx_level__bin_01.png" width="100%" alt="TNX Level bin 1: a 42 percentage-point upside contrast whose score still falls below the null 95th percentile"></a>
76
+ </p>
77
+
78
+ ## Moderate yields - same signal, opposite story
79
+
80
+ Move the yield to 2.5%-2.9% and the story flips: an 8% drop becomes likelier than a rise, a **21.2-point** swing. Read alone, it's a second, bearish regime. Random markets draw one at least this strong 41% of the time.
81
+
82
+ <p align="center">
83
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__tnx_level__bin_06.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__tnx_level__bin_06.png" width="100%" alt="TNX Level bin 6: a 21.2 percentage-point downside contrast, well inside the synthetic null"></a>
84
+ </p>
85
+
86
+ # Try it
87
+
88
+ <p>
89
+ <img src="https://img.shields.io/badge/PyTorch-%E2%89%A5%202.0-EE4C2C?logo=pytorch&logoColor=white" alt="PyTorch >= 2.0">
90
+ <img src="https://img.shields.io/badge/CUDA-%E2%89%A5%2012.0-76B900?logo=nvidia&logoColor=white" alt="CUDA >= 12.0">
91
+ </p>
92
+
93
+ **PyTorch is mandatory. A dedicated CUDA-enabled GPU is strongly recommended.**
94
+
95
+ The distribution, CLI, and Python package are named `alphaverify`.
96
+ The repository name remains `alpha-verify`. `init` copies one of the shipped
97
+ workspaces into `./workspaces`, which is where every later command looks for it.
98
+
99
+ ```
100
+ python -m pip install alphaverify
101
+
102
+ alphaverify init --workspace nasdaq_daily
103
+ alphaverify measure
104
+ alphaverify compare
105
+ alphaverify validate
106
+ alphaverify select
107
+ alphaverify forecast
108
+ ```
109
+
110
+ From a checkout, `python -m pip install -e .` installs the same CLI, and `init`
111
+ is unnecessary because `workspaces/` is already there; run commands from the
112
+ repository root and reinstall the editable package after updating it. To keep
113
+ workspaces anywhere else, pass `--workspaces-dir DIR` or set `$ALPHAVERIFY_WORKSPACES`.
114
+
115
+ After `validate`, the figure for every tested bin, including the four above, is in `workspaces/nasdaq_daily/03_validation/plot/`.
116
+
117
+ Each pipeline command also accepts `--cuda` when a CUDA-capable PyTorch installation and device are available.
118
+
119
+ # How it works
120
+
121
+ | Stage | CLI Command | What it does | Mathematical form |
122
+ |---|---|---|---|
123
+ | 1 | measure | Measure conditional probabilities | `π_condition(r, δ, k, t)` |
124
+ | 2 | compare | Compare them with the baseline | `G = π_condition − π_baseline` |
125
+ | 3 | validate | Validate every supported bin against the null | `p̂_k < 0.05 or p̂_k ≥ 0.05` |
126
+ | 4 | select | Retain cleared bins, rank them by evidence, and render their figures | `K_selected = {k : p̂_k < 0.05}` |
127
+ | 5 | forecast | List which nodes cleared and with which bins; combine those active on the last stored bar, one per family, and compare with their historical joint rate | `N_cleared = {node(k) : k ∈ K_selected}`; `logit P = logit π_baseline + Σ_k (logit π_k − logit π_baseline)` |
128
+
129
+
130
+ Validation writes `03_validation/`; selection consumes only a current validation result and writes `04_selection/`; the forecast consumes only a current selection and writes `05_forecast/`. Every cleared bin is retained—there is no top-k ranking or secondary economic gate.
131
+
132
+ # Repository map
133
+
134
+ - [Source architecture](https://github.com/doubletrends/alpha-verify/blob/master/src/alphaverify/README.md) — implementation boundaries, data flow, artifact contracts, and null mechanics.
135
+ - [Workspaces](https://github.com/doubletrends/alpha-verify/blob/master/workspaces/README.md) — experiment declarations, plugins, generated artifacts, and safe workspace changes.
136
+
137
+ AlphaVerify is research software, not investment advice.
138
+
139
+ The complete numerical specification is available as LaTeX in
140
+ [`mathematics.tex`](https://github.com/doubletrends/alpha-verify/blob/master/mathematics.tex).
@@ -0,0 +1,108 @@
1
+ <div align="center">
2
+ <h1><strong>AlphaVerify</strong> - Multi-Asset Financial Strategy Debunker</h1>
3
+ <img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/alphaverify-icon-old.svg" alt="AlphaVerify icon" width="180">
4
+ <br>
5
+ <h3>Most “technical” indicators are essentially astrology with better charts.<br>
6
+ AlphaVerify is built to put an end to all that bullshit.</h3>
7
+ </div>
8
+
9
+ <p align="center">
10
+ <picture>
11
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/stats-dark.svg">
12
+ <img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/stats-light.svg" width="100%" alt="1,000 synthetic OHLC histories; 552 NASDAQ condition bins tested, across 57 features; 25 bins cleared, where pure chance predicts 27.6">
13
+ </picture>
14
+ </p>
15
+
16
+ # How to look at the figures
17
+ Each figure tests one market condition.
18
+
19
+ **Left:** while the condition holds, is the NASDAQ more likely (red) or less likely (blue) to move by a given percentage within 30 days?
20
+ **Right:** the same test run on 1,000 random markets that contain no signal. To count as an edge, the real score (blue line) has to beat 95% of them (dashed line).
21
+
22
+ ## The golden cross - folklore
23
+
24
+ Traders everywhere watch for the 50-day average to cross above the 200-day. Once it runs about 10% above, the heatmap looks decisive: the odds of a 4% drop jump, the odds of a 4% rise fall, a **24.5-point** swing. It looks like a real edge. It's folklore: random markets draw one at least this strong 8.4% of the time.
25
+
26
+ <p align="center">
27
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__ma_cross_50_200__bin_09.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__ma_cross_50_200__bin_09.png" width="100%" alt="MA Cross 50-200 bin 9: a 24.5 percentage-point contrast below the null 95th percentile"></a>
28
+ </p>
29
+
30
+ ## Above the 200-day - a textbook mirror
31
+
32
+ "Stay long while price is above the 200-day" is trend following's first rule. With price 4% to 6% above it, the picture is a near-perfect mirror: rises more likely, drops much less likely, a **27.4-point** swing. Random markets draw one at least this strong 23% of the time.
33
+
34
+ <p align="center">
35
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__ma_ratio_200__bin_04.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__ma_ratio_200__bin_04.png" width="100%" alt="MA Ratio-200 bin 4: a 27.4 percentage-point contrast well inside the synthetic null"></a>
36
+ </p>
37
+
38
+ ## Low bond yields - the 42-point edge
39
+
40
+ Cheap money lifts stocks; everyone knows that. When the 10-year Treasury yield sat below 1.34%, the NASDAQ was far more likely to rally 8% within a month: a **42-point** swing that grows steadily with time. It looks like a macro regime you could trade. It isn't. Random markets draw one at least this strong 7.6% of the time. Close, but not an edge.
41
+
42
+ <p align="center">
43
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__tnx_level__bin_01.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__tnx_level__bin_01.png" width="100%" alt="TNX Level bin 1: a 42 percentage-point upside contrast whose score still falls below the null 95th percentile"></a>
44
+ </p>
45
+
46
+ ## Moderate yields - same signal, opposite story
47
+
48
+ Move the yield to 2.5%-2.9% and the story flips: an 8% drop becomes likelier than a rise, a **21.2-point** swing. Read alone, it's a second, bearish regime. Random markets draw one at least this strong 41% of the time.
49
+
50
+ <p align="center">
51
+ <a href="https://github.com/doubletrends/alpha-verify/blob/master/docs/bin_figure__tnx_level__bin_06.png"><img src="https://raw.githubusercontent.com/doubletrends/alpha-verify/master/docs/bin_figure__tnx_level__bin_06.png" width="100%" alt="TNX Level bin 6: a 21.2 percentage-point downside contrast, well inside the synthetic null"></a>
52
+ </p>
53
+
54
+ # Try it
55
+
56
+ <p>
57
+ <img src="https://img.shields.io/badge/PyTorch-%E2%89%A5%202.0-EE4C2C?logo=pytorch&logoColor=white" alt="PyTorch >= 2.0">
58
+ <img src="https://img.shields.io/badge/CUDA-%E2%89%A5%2012.0-76B900?logo=nvidia&logoColor=white" alt="CUDA >= 12.0">
59
+ </p>
60
+
61
+ **PyTorch is mandatory. A dedicated CUDA-enabled GPU is strongly recommended.**
62
+
63
+ The distribution, CLI, and Python package are named `alphaverify`.
64
+ The repository name remains `alpha-verify`. `init` copies one of the shipped
65
+ workspaces into `./workspaces`, which is where every later command looks for it.
66
+
67
+ ```
68
+ python -m pip install alphaverify
69
+
70
+ alphaverify init --workspace nasdaq_daily
71
+ alphaverify measure
72
+ alphaverify compare
73
+ alphaverify validate
74
+ alphaverify select
75
+ alphaverify forecast
76
+ ```
77
+
78
+ From a checkout, `python -m pip install -e .` installs the same CLI, and `init`
79
+ is unnecessary because `workspaces/` is already there; run commands from the
80
+ repository root and reinstall the editable package after updating it. To keep
81
+ workspaces anywhere else, pass `--workspaces-dir DIR` or set `$ALPHAVERIFY_WORKSPACES`.
82
+
83
+ After `validate`, the figure for every tested bin, including the four above, is in `workspaces/nasdaq_daily/03_validation/plot/`.
84
+
85
+ Each pipeline command also accepts `--cuda` when a CUDA-capable PyTorch installation and device are available.
86
+
87
+ # How it works
88
+
89
+ | Stage | CLI Command | What it does | Mathematical form |
90
+ |---|---|---|---|
91
+ | 1 | measure | Measure conditional probabilities | `π_condition(r, δ, k, t)` |
92
+ | 2 | compare | Compare them with the baseline | `G = π_condition − π_baseline` |
93
+ | 3 | validate | Validate every supported bin against the null | `p̂_k < 0.05 or p̂_k ≥ 0.05` |
94
+ | 4 | select | Retain cleared bins, rank them by evidence, and render their figures | `K_selected = {k : p̂_k < 0.05}` |
95
+ | 5 | forecast | List which nodes cleared and with which bins; combine those active on the last stored bar, one per family, and compare with their historical joint rate | `N_cleared = {node(k) : k ∈ K_selected}`; `logit P = logit π_baseline + Σ_k (logit π_k − logit π_baseline)` |
96
+
97
+
98
+ Validation writes `03_validation/`; selection consumes only a current validation result and writes `04_selection/`; the forecast consumes only a current selection and writes `05_forecast/`. Every cleared bin is retained—there is no top-k ranking or secondary economic gate.
99
+
100
+ # Repository map
101
+
102
+ - [Source architecture](https://github.com/doubletrends/alpha-verify/blob/master/src/alphaverify/README.md) — implementation boundaries, data flow, artifact contracts, and null mechanics.
103
+ - [Workspaces](https://github.com/doubletrends/alpha-verify/blob/master/workspaces/README.md) — experiment declarations, plugins, generated artifacts, and safe workspace changes.
104
+
105
+ AlphaVerify is research software, not investment advice.
106
+
107
+ The complete numerical specification is available as LaTeX in
108
+ [`mathematics.tex`](https://github.com/doubletrends/alpha-verify/blob/master/mathematics.tex).
@@ -0,0 +1,76 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "alphaverify"
7
+ version = "0.1.0"
8
+ description = "Conditional barrier-touch probability pipeline."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "CC0-1.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "chengmarc" }]
14
+ keywords = [
15
+ "quantitative-finance",
16
+ "technical-analysis",
17
+ "hypothesis-testing",
18
+ "multiple-testing",
19
+ "barrier-touch",
20
+ "market-research",
21
+ ]
22
+ classifiers = [
23
+ "Development Status :: 3 - Alpha",
24
+ "Environment :: Console",
25
+ "Environment :: GPU :: NVIDIA CUDA",
26
+ "Intended Audience :: Science/Research",
27
+ "Intended Audience :: Financial and Insurance Industry",
28
+ "Operating System :: OS Independent",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Office/Business :: Financial :: Investment",
32
+ "Topic :: Scientific/Engineering :: Information Analysis",
33
+ ]
34
+ dependencies = [
35
+ "numpy>=2.0",
36
+ "pandas>=2.2",
37
+ "matplotlib>=3.8",
38
+ "yfinance>=0.2",
39
+ "openpyxl>=3.1",
40
+ "safetensors>=0.5",
41
+ "torch>=2.0",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/doubletrends/alpha-verify"
46
+ Repository = "https://github.com/doubletrends/alpha-verify"
47
+ Issues = "https://github.com/doubletrends/alpha-verify/issues"
48
+
49
+ [project.scripts]
50
+ alphaverify = "alphaverify.cli:main"
51
+
52
+ [tool.setuptools]
53
+ # The shipped workspaces are distributed as `alphaverify.templates`, the source
54
+ # `alphaverify init` copies from. Adding a workspace means adding it here too;
55
+ # tests/test_workspace_data.py fails when one is missing.
56
+ package-dir = { "" = "src", "alphaverify.templates" = "workspaces" }
57
+ packages = [
58
+ "alphaverify",
59
+ "alphaverify.domain",
60
+ "alphaverify.infrastructure",
61
+ "alphaverify.pipeline",
62
+ "alphaverify.presentation",
63
+ "alphaverify.templates",
64
+ "alphaverify.templates._shared",
65
+ "alphaverify.templates.btc_daily",
66
+ "alphaverify.templates.btc_hourly",
67
+ "alphaverify.templates.nasdaq_daily",
68
+ ]
69
+
70
+ [tool.setuptools.package-data]
71
+ "alphaverify.templates.btc_daily" = ["universe.json"]
72
+ "alphaverify.templates.btc_hourly" = ["universe.json"]
73
+ "alphaverify.templates.nasdaq_daily" = ["universe.json"]
74
+
75
+ [tool.pytest.ini_options]
76
+ pythonpath = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Conditional barrier-touch probability pipeline."""
@@ -0,0 +1,185 @@
1
+ """Command-line interface for the barrier-touch pipeline."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ from collections.abc import Callable
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+
10
+ from alphaverify.domain import tensor_runtime
11
+ from alphaverify.infrastructure.scaffold import available_templates, copy_workspace
12
+ from alphaverify.infrastructure.workspace import (
13
+ STAGE_DIRECTORIES,
14
+ WORKSPACES_DIRNAME,
15
+ Workspace,
16
+ workspaces_root,
17
+ )
18
+ from alphaverify.pipeline.reporting import RULE, ansi_styles, color_enabled
19
+ from alphaverify.pipeline.step_01_surface import cmd_surface
20
+ from alphaverify.pipeline.step_02_shift import cmd_shift
21
+ from alphaverify.pipeline.step_03_validation import cmd_validation
22
+ from alphaverify.pipeline.step_04_selection import cmd_selection
23
+ from alphaverify.pipeline.step_05_forecast import cmd_forecast
24
+
25
+
26
+ @dataclass(frozen=True)
27
+ class Command:
28
+ name: str
29
+ summary: str
30
+ handler: Callable[[Workspace], None]
31
+ stage: str
32
+
33
+
34
+ COMMANDS = (
35
+ Command(
36
+ "measure",
37
+ "Measure raw conditional probabilities",
38
+ cmd_surface,
39
+ stage="surface",
40
+ ),
41
+ Command(
42
+ "compare",
43
+ "Compare raw probabilities to baseline",
44
+ cmd_shift,
45
+ stage="shift",
46
+ ),
47
+ Command(
48
+ "validate",
49
+ "Validate all eligible bins vs null",
50
+ cmd_validation,
51
+ stage="validation",
52
+ ),
53
+ Command(
54
+ "select",
55
+ "Select cleared bins and heatmaps",
56
+ cmd_selection,
57
+ stage="selection",
58
+ ),
59
+ Command(
60
+ "forecast",
61
+ "Cleared nodes and their forecast",
62
+ cmd_forecast,
63
+ stage="forecast",
64
+ ),
65
+ )
66
+ COMMAND_BY_NAME = {command.name: command for command in COMMANDS}
67
+
68
+ # Setup, not a stage: it writes the workspace that the stage commands then read.
69
+ INIT_COMMAND = "init"
70
+
71
+
72
+ def overview(color: bool) -> str:
73
+ """Root help: setup, then the pipeline commands in order with their artifact directories."""
74
+ accent, bold, dim, reset = ansi_styles(color)
75
+
76
+ def heading(text: str) -> list[str]:
77
+ return [f" {accent}{bold}{text}{reset}", ""]
78
+
79
+ def row(name: str, summary: str, target: str) -> str:
80
+ return (
81
+ f" {bold}{name}{reset}{' ' * (12 - len(name))}"
82
+ f"{summary:<38}→ {dim}{target}{reset}"
83
+ )
84
+
85
+ lines = [
86
+ f"{accent}{RULE}{reset}",
87
+ "AlphaVerify",
88
+ "Conditional barrier-touch probability pipeline",
89
+ f"{accent}{RULE}{reset}",
90
+ "",
91
+ *heading("Setup"),
92
+ row(INIT_COMMAND, "Copy a shipped workspace here", f"{WORKSPACES_DIRNAME}/NAME/"),
93
+ "",
94
+ *heading("Pipeline"),
95
+ ]
96
+ for command in COMMANDS:
97
+ lines.append(row(command.name, command.summary, f"{STAGE_DIRECTORIES[command.stage]}/"))
98
+ lines += [
99
+ "",
100
+ *heading("Options"),
101
+ " --workspace NAME Select a workspace",
102
+ " --workspaces-dir DIR Workspace root (or $ALPHAVERIFY_WORKSPACES)",
103
+ " --cuda Use CUDA numerical kernels",
104
+ " -h, --help Show this help",
105
+ ]
106
+ return "\n".join(lines) + "\n"
107
+
108
+
109
+ class RootParser(argparse.ArgumentParser):
110
+ """Root help is the command overview; subcommands keep argparse option help."""
111
+
112
+ def format_help(self) -> str:
113
+ return overview(color_enabled())
114
+
115
+
116
+ def _add_workspace_options(parser: argparse.ArgumentParser) -> None:
117
+ parser.add_argument("--workspace", metavar="NAME", default="nasdaq_daily")
118
+ parser.add_argument(
119
+ "--workspaces-dir",
120
+ metavar="DIR",
121
+ default=None,
122
+ help=(
123
+ "directory holding workspaces "
124
+ f"(default: $ALPHAVERIFY_WORKSPACES, else ./{WORKSPACES_DIRNAME})"
125
+ ),
126
+ )
127
+
128
+
129
+ def _add_run_options(parser: argparse.ArgumentParser) -> None:
130
+ _add_workspace_options(parser)
131
+ parser.add_argument(
132
+ "--cuda",
133
+ action="store_true",
134
+ help="run numerical barrier kernels on CUDA (requires an available CUDA PyTorch device)",
135
+ )
136
+
137
+
138
+ def build_parser() -> argparse.ArgumentParser:
139
+ parser = RootParser(prog="alphaverify")
140
+ commands = parser.add_subparsers(
141
+ dest="command", metavar="COMMAND", parser_class=argparse.ArgumentParser
142
+ )
143
+
144
+ _add_workspace_options(
145
+ commands.add_parser(
146
+ INIT_COMMAND,
147
+ help=f"copy a shipped workspace ({', '.join(available_templates())}) into place",
148
+ )
149
+ )
150
+ for command in COMMANDS:
151
+ _add_run_options(commands.add_parser(command.name))
152
+ return parser
153
+
154
+
155
+ def cmd_init(name: str, workspaces_dir: str | None) -> None:
156
+ """Write one shipped workspace declaration where the stage commands will look for it."""
157
+ root = workspaces_root(workspaces_dir)
158
+ written = copy_workspace(name, root)
159
+ accent, bold, dim, reset = ansi_styles(color_enabled())
160
+ print(f"\n{accent}{RULE}{reset}")
161
+ print(f"{accent}{bold}Workspace {name}{reset} → {root / name}")
162
+ print(f"{accent}{RULE}{reset}\n")
163
+ for path in written:
164
+ print(f" {dim}{path.relative_to(root)}{reset}")
165
+ option = "" if root == Path.cwd() / WORKSPACES_DIRNAME else f" --workspaces-dir {root}"
166
+ print(f"\n next: alphaverify measure --workspace {name}{option}\n")
167
+
168
+
169
+ def main(argv: list[str] | None = None) -> None:
170
+ parser = build_parser()
171
+ args = parser.parse_args(argv)
172
+ if args.command is None:
173
+ parser.print_help()
174
+ return
175
+ if args.command == INIT_COMMAND:
176
+ cmd_init(args.workspace, args.workspaces_dir)
177
+ return
178
+ ws = Workspace(args.workspace, args.workspaces_dir)
179
+ tensor_runtime.configure(args.cuda)
180
+
181
+ COMMAND_BY_NAME[args.command].handler(ws)
182
+
183
+
184
+ if __name__ == "__main__":
185
+ main()
@@ -0,0 +1 @@
1
+ """Pure numerical models and feature transforms."""