backtest-configurator 0.3.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 (51) hide show
  1. backtest_configurator-0.3.0/LICENSE +201 -0
  2. backtest_configurator-0.3.0/MANIFEST.in +7 -0
  3. backtest_configurator-0.3.0/PKG-INFO +134 -0
  4. backtest_configurator-0.3.0/README_PYPI.md +112 -0
  5. backtest_configurator-0.3.0/backtest_configurator.egg-info/PKG-INFO +134 -0
  6. backtest_configurator-0.3.0/backtest_configurator.egg-info/SOURCES.txt +49 -0
  7. backtest_configurator-0.3.0/backtest_configurator.egg-info/dependency_links.txt +1 -0
  8. backtest_configurator-0.3.0/backtest_configurator.egg-info/entry_points.txt +3 -0
  9. backtest_configurator-0.3.0/backtest_configurator.egg-info/requires.txt +14 -0
  10. backtest_configurator-0.3.0/backtest_configurator.egg-info/top_level.txt +1 -0
  11. backtest_configurator-0.3.0/nba_configurator/__init__.py +33 -0
  12. backtest_configurator-0.3.0/nba_configurator/_data/requirements-lock.txt +923 -0
  13. backtest_configurator-0.3.0/nba_configurator/_planted.py +69 -0
  14. backtest_configurator-0.3.0/nba_configurator/behavior.py +108 -0
  15. backtest_configurator-0.3.0/nba_configurator/canonical.py +107 -0
  16. backtest_configurator-0.3.0/nba_configurator/cli.py +367 -0
  17. backtest_configurator-0.3.0/nba_configurator/confirmation.py +260 -0
  18. backtest_configurator-0.3.0/nba_configurator/data/conversion_table_v1.json +34 -0
  19. backtest_configurator-0.3.0/nba_configurator/data/nyse_calendar_v1.json +415 -0
  20. backtest_configurator-0.3.0/nba_configurator/data.py +395 -0
  21. backtest_configurator-0.3.0/nba_configurator/engine.py +963 -0
  22. backtest_configurator-0.3.0/nba_configurator/examples/a_trend_switch.yaml +43 -0
  23. backtest_configurator-0.3.0/nba_configurator/examples/b_sector_momentum.yaml +90 -0
  24. backtest_configurator-0.3.0/nba_configurator/examples/c_liquid_momentum.yaml +47 -0
  25. backtest_configurator-0.3.0/nba_configurator/export.py +549 -0
  26. backtest_configurator-0.3.0/nba_configurator/mcp/__init__.py +32 -0
  27. backtest_configurator-0.3.0/nba_configurator/mcp/__main__.py +3 -0
  28. backtest_configurator-0.3.0/nba_configurator/mcp/content.py +143 -0
  29. backtest_configurator-0.3.0/nba_configurator/mcp/hardening.py +293 -0
  30. backtest_configurator-0.3.0/nba_configurator/mcp/prompt.py +68 -0
  31. backtest_configurator-0.3.0/nba_configurator/mcp/render.py +221 -0
  32. backtest_configurator-0.3.0/nba_configurator/mcp/sections.py +328 -0
  33. backtest_configurator-0.3.0/nba_configurator/mcp/server.py +989 -0
  34. backtest_configurator-0.3.0/nba_configurator/metrics.py +174 -0
  35. backtest_configurator-0.3.0/nba_configurator/model.py +271 -0
  36. backtest_configurator-0.3.0/nba_configurator/nyse_calendar.py +294 -0
  37. backtest_configurator-0.3.0/nba_configurator/provenance.py +181 -0
  38. backtest_configurator-0.3.0/nba_configurator/report.py +422 -0
  39. backtest_configurator-0.3.0/nba_configurator/runner.py +598 -0
  40. backtest_configurator-0.3.0/nba_configurator/safeio.py +167 -0
  41. backtest_configurator-0.3.0/nba_configurator/schema/backtest-spec-v1.json +2017 -0
  42. backtest_configurator-0.3.0/nba_configurator/schema_check.py +190 -0
  43. backtest_configurator-0.3.0/nba_configurator/schema_source.py +536 -0
  44. backtest_configurator-0.3.0/nba_configurator/signals.py +262 -0
  45. backtest_configurator-0.3.0/nba_configurator/spec.py +1194 -0
  46. backtest_configurator-0.3.0/nba_configurator/synthetic.py +197 -0
  47. backtest_configurator-0.3.0/nba_configurator/templates/strategy_v1.py.txt +1042 -0
  48. backtest_configurator-0.3.0/nba_configurator/verify.py +315 -0
  49. backtest_configurator-0.3.0/nba_configurator/yaml_io.py +162 -0
  50. backtest_configurator-0.3.0/pyproject.toml +49 -0
  51. backtest_configurator-0.3.0/setup.cfg +4 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ # What the sdist holds besides the package (security review of the 0.3.0 RC, S3 and S5).
2
+ # The public README is the long description. The internal README.md (local paths, internal links) and the tests
3
+ # (which need helpers and fixtures that are not packaged, and hold decoy strings) stay in the repository only.
4
+ # scripts/check_wheel.py --sdist checks the result against an allowlist.
5
+ include README_PYPI.md
6
+ exclude README.md
7
+ prune tests
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: backtest-configurator
3
+ Version: 0.3.0
4
+ Summary: Backtest Configurator: a versioned, point-in-time spec for rotation strategies, and an engine that runs it on your own files. Results are hypothetical.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: <3.13,>=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: backtest-auditor==0.7.0
10
+ Requires-Dist: PyYAML==6.0.3
11
+ Requires-Dist: jsonschema==4.26.0
12
+ Requires-Dist: numpy==2.5.4
13
+ Requires-Dist: pandas==3.0.6
14
+ Requires-Dist: pyarrow==26.0.1
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest==9.1.1; extra == "test"
17
+ Requires-Dist: exchange_calendars==4.13.3; extra == "test"
18
+ Requires-Dist: hypothesis==6.170.16; extra == "test"
19
+ Provides-Extra: mcp
20
+ Requires-Dist: mcp==2.3.0; extra == "mcp"
21
+ Dynamic: license-file
22
+
23
+ # Backtest Configurator
24
+
25
+ Write a rotation strategy as a short spec file, check it, confirm it, and run it on your own price files. Your AI
26
+ assistant can draft the spec from your words through the MCP server; you review every line, and nothing runs until
27
+ you confirm.
28
+
29
+ Every result this tool produces is **hypothetical**:
30
+
31
+ > Hypothetical backtest. These results were simulated with hindsight and didn't come from real trading. They don't
32
+ > reflect actual costs, slippage or market impact beyond what's stated, and hypothetical results have well-known
33
+ > limits. Past results, simulated or live, don't guarantee future results.
34
+
35
+ Not investment advice; not tailored to you; we are not a registered investment adviser or broker-dealer.
36
+
37
+ Terms of use: https://nothingbutalpha.app/terms#backtest-configurator
38
+
39
+ ## What it does
40
+
41
+ - **A versioned spec (v1).** Rotation strategies only: on scheduled dates, rank and hold the top N (or all eligible
42
+ assets), with equal, inverse-volatility or fixed weights. Adjusted prices only. A JSON Schema defines every field,
43
+ and a fill on the same bar as the decision cannot be written.
44
+ - **Validation before anything runs.** The tool turns the spec into plain English, lists every assumption with its
45
+ origin (your answer, filled in by the assistant, or a default), and flags values that your own text does not
46
+ state.
47
+ - **A local engine.** It runs the spec on your own CSV or Parquet files (`date,ticker,open,high,low,close`) against a
48
+ pinned NYSE calendar. It needs no API key and calls no data vendor.
49
+ - **A disclosure block with every output**, and a receipt with hashes of the spec, the data and every result file.
50
+ The receipt holds no return figures.
51
+ - **A Python export.** `strategy.py` reproduces the engine's run in plain pandas and NumPy, on files the configurator accepts. The tool includes the
52
+ Backtest Auditor's static checks, which catch some common errors and miss many.
53
+ - **Run counting.** Every run is counted in the project folder, and the count goes with every result, so you can see
54
+ how many variants were tried before this one.
55
+
56
+ ## Install
57
+
58
+ Python 3.12. The command-line tool and the MCP server need the `mcp` extra:
59
+
60
+ ```
61
+ pip install "backtest-configurator[mcp]"
62
+ ```
63
+
64
+ ## Command-line quick start
65
+
66
+ Run these from your project folder, or pass `--project-dir`:
67
+
68
+ ```
69
+ backtest-configurator validate my_strategy.yaml
70
+ backtest-configurator run my_strategy.yaml
71
+ backtest-configurator export my_strategy.yaml --out strategy.py
72
+ backtest-configurator verify .nba-configurator/results/<run>/receipt.json
73
+ backtest-configurator explain momentum
74
+ ```
75
+
76
+ - `validate` reads no price data and runs nothing.
77
+ - `run` shows the rendering, the assumptions, the flags and the run count, then asks you to type `yes` at an
78
+ interactive terminal. A plain pipe or redirect is refused, and there is no flag that skips the question.
79
+ - `verify` re-runs a logged receipt and reports whether the results reproduced. It is not a run and is not counted.
80
+
81
+ ## MCP quick start
82
+
83
+ The server is `nba-configurator-mcp`, a local stdio server. Always pass the project folder: the run log and all
84
+ results live there.
85
+
86
+ Claude Code:
87
+
88
+ ```
89
+ claude mcp add nba-configurator -- nba-configurator-mcp --project-dir /path/to/project
90
+ ```
91
+
92
+ Claude Desktop or Cursor (`mcpServers` in the client's config file):
93
+
94
+ ```json
95
+ {"mcpServers": {"nba-configurator": {"command": "nba-configurator-mcp",
96
+ "args": ["--project-dir", "/path/to/project"]}}}
97
+ ```
98
+
99
+ A run needs a client that supports MCP elicitation, because the server asks for confirmation through it. A client
100
+ without it gets the plain-English rendering and a refusal, and nothing runs. Then save the spec to a file and use
101
+ `backtest-configurator run` in your own terminal.
102
+
103
+ ## Threat model and accepted risks
104
+
105
+ What the tool protects:
106
+
107
+ - Nothing is read or run before you confirm. Validation opens no price file and no membership file.
108
+ - Writes stay inside the project folder. A symlink, a reparse point or a file with more than one hard link is
109
+ refused as a write target (item 1 below is the limit of that check).
110
+ - No network requests, no model calls. It never runs your code or the exported code.
111
+
112
+ What it does not protect against, accepted for this release:
113
+
114
+ 1. **Races in the project folder.** A process that can write in the project folder at the same moment can swap a
115
+ folder for a link between the path check and the open, or replace a data file between its check and its read.
116
+ Closing this fully needs handle-relative file access.
117
+ 2. **The confirmation records a channel, not a person.** A program that runs the command-line tool inside a
118
+ pseudo-terminal can answer the prompt, and an MCP client that accepts elicitation requests automatically can
119
+ confirm without showing the request. The receipt records the channel (`cli_prompt`, `mcp_elicitation`), never
120
+ "user confirmed".
121
+ 3. **Reads may be anywhere your account can read.** Once you confirm, a data path may point outside the project
122
+ folder. That is by design: the files are yours.
123
+ 4. **Run counts are per project folder.** A new folder starts a new count.
124
+ 5. **The `mcp` extra installs server packages the tool never uses** (an HTTP server and its dependencies). They are
125
+ pinned, but an advisory on any of them concerns this package too.
126
+ 6. **The wheel is not byte-reproducible.** Only files built and tested in CI are published, with PyPI attestations.
127
+ 7. **No hash-locked install from PyPI.** Direct dependencies are pinned exactly; transitive ones are not.
128
+ 8. **Developer regeneration commands ship in the package.** `python -m nba_configurator.schema_source --write` and
129
+ `python -m nba_configurator.nyse_calendar --write` rewrite the installed schema and calendar with the same
130
+ generated content.
131
+
132
+ ## License
133
+
134
+ Apache-2.0.
@@ -0,0 +1,112 @@
1
+ # Backtest Configurator
2
+
3
+ Write a rotation strategy as a short spec file, check it, confirm it, and run it on your own price files. Your AI
4
+ assistant can draft the spec from your words through the MCP server; you review every line, and nothing runs until
5
+ you confirm.
6
+
7
+ Every result this tool produces is **hypothetical**:
8
+
9
+ > Hypothetical backtest. These results were simulated with hindsight and didn't come from real trading. They don't
10
+ > reflect actual costs, slippage or market impact beyond what's stated, and hypothetical results have well-known
11
+ > limits. Past results, simulated or live, don't guarantee future results.
12
+
13
+ Not investment advice; not tailored to you; we are not a registered investment adviser or broker-dealer.
14
+
15
+ Terms of use: https://nothingbutalpha.app/terms#backtest-configurator
16
+
17
+ ## What it does
18
+
19
+ - **A versioned spec (v1).** Rotation strategies only: on scheduled dates, rank and hold the top N (or all eligible
20
+ assets), with equal, inverse-volatility or fixed weights. Adjusted prices only. A JSON Schema defines every field,
21
+ and a fill on the same bar as the decision cannot be written.
22
+ - **Validation before anything runs.** The tool turns the spec into plain English, lists every assumption with its
23
+ origin (your answer, filled in by the assistant, or a default), and flags values that your own text does not
24
+ state.
25
+ - **A local engine.** It runs the spec on your own CSV or Parquet files (`date,ticker,open,high,low,close`) against a
26
+ pinned NYSE calendar. It needs no API key and calls no data vendor.
27
+ - **A disclosure block with every output**, and a receipt with hashes of the spec, the data and every result file.
28
+ The receipt holds no return figures.
29
+ - **A Python export.** `strategy.py` reproduces the engine's run in plain pandas and NumPy, on files the configurator accepts. The tool includes the
30
+ Backtest Auditor's static checks, which catch some common errors and miss many.
31
+ - **Run counting.** Every run is counted in the project folder, and the count goes with every result, so you can see
32
+ how many variants were tried before this one.
33
+
34
+ ## Install
35
+
36
+ Python 3.12. The command-line tool and the MCP server need the `mcp` extra:
37
+
38
+ ```
39
+ pip install "backtest-configurator[mcp]"
40
+ ```
41
+
42
+ ## Command-line quick start
43
+
44
+ Run these from your project folder, or pass `--project-dir`:
45
+
46
+ ```
47
+ backtest-configurator validate my_strategy.yaml
48
+ backtest-configurator run my_strategy.yaml
49
+ backtest-configurator export my_strategy.yaml --out strategy.py
50
+ backtest-configurator verify .nba-configurator/results/<run>/receipt.json
51
+ backtest-configurator explain momentum
52
+ ```
53
+
54
+ - `validate` reads no price data and runs nothing.
55
+ - `run` shows the rendering, the assumptions, the flags and the run count, then asks you to type `yes` at an
56
+ interactive terminal. A plain pipe or redirect is refused, and there is no flag that skips the question.
57
+ - `verify` re-runs a logged receipt and reports whether the results reproduced. It is not a run and is not counted.
58
+
59
+ ## MCP quick start
60
+
61
+ The server is `nba-configurator-mcp`, a local stdio server. Always pass the project folder: the run log and all
62
+ results live there.
63
+
64
+ Claude Code:
65
+
66
+ ```
67
+ claude mcp add nba-configurator -- nba-configurator-mcp --project-dir /path/to/project
68
+ ```
69
+
70
+ Claude Desktop or Cursor (`mcpServers` in the client's config file):
71
+
72
+ ```json
73
+ {"mcpServers": {"nba-configurator": {"command": "nba-configurator-mcp",
74
+ "args": ["--project-dir", "/path/to/project"]}}}
75
+ ```
76
+
77
+ A run needs a client that supports MCP elicitation, because the server asks for confirmation through it. A client
78
+ without it gets the plain-English rendering and a refusal, and nothing runs. Then save the spec to a file and use
79
+ `backtest-configurator run` in your own terminal.
80
+
81
+ ## Threat model and accepted risks
82
+
83
+ What the tool protects:
84
+
85
+ - Nothing is read or run before you confirm. Validation opens no price file and no membership file.
86
+ - Writes stay inside the project folder. A symlink, a reparse point or a file with more than one hard link is
87
+ refused as a write target (item 1 below is the limit of that check).
88
+ - No network requests, no model calls. It never runs your code or the exported code.
89
+
90
+ What it does not protect against, accepted for this release:
91
+
92
+ 1. **Races in the project folder.** A process that can write in the project folder at the same moment can swap a
93
+ folder for a link between the path check and the open, or replace a data file between its check and its read.
94
+ Closing this fully needs handle-relative file access.
95
+ 2. **The confirmation records a channel, not a person.** A program that runs the command-line tool inside a
96
+ pseudo-terminal can answer the prompt, and an MCP client that accepts elicitation requests automatically can
97
+ confirm without showing the request. The receipt records the channel (`cli_prompt`, `mcp_elicitation`), never
98
+ "user confirmed".
99
+ 3. **Reads may be anywhere your account can read.** Once you confirm, a data path may point outside the project
100
+ folder. That is by design: the files are yours.
101
+ 4. **Run counts are per project folder.** A new folder starts a new count.
102
+ 5. **The `mcp` extra installs server packages the tool never uses** (an HTTP server and its dependencies). They are
103
+ pinned, but an advisory on any of them concerns this package too.
104
+ 6. **The wheel is not byte-reproducible.** Only files built and tested in CI are published, with PyPI attestations.
105
+ 7. **No hash-locked install from PyPI.** Direct dependencies are pinned exactly; transitive ones are not.
106
+ 8. **Developer regeneration commands ship in the package.** `python -m nba_configurator.schema_source --write` and
107
+ `python -m nba_configurator.nyse_calendar --write` rewrite the installed schema and calendar with the same
108
+ generated content.
109
+
110
+ ## License
111
+
112
+ Apache-2.0.
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: backtest-configurator
3
+ Version: 0.3.0
4
+ Summary: Backtest Configurator: a versioned, point-in-time spec for rotation strategies, and an engine that runs it on your own files. Results are hypothetical.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: <3.13,>=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: backtest-auditor==0.7.0
10
+ Requires-Dist: PyYAML==6.0.3
11
+ Requires-Dist: jsonschema==4.26.0
12
+ Requires-Dist: numpy==2.5.4
13
+ Requires-Dist: pandas==3.0.6
14
+ Requires-Dist: pyarrow==26.0.1
15
+ Provides-Extra: test
16
+ Requires-Dist: pytest==9.1.1; extra == "test"
17
+ Requires-Dist: exchange_calendars==4.13.3; extra == "test"
18
+ Requires-Dist: hypothesis==6.170.16; extra == "test"
19
+ Provides-Extra: mcp
20
+ Requires-Dist: mcp==2.3.0; extra == "mcp"
21
+ Dynamic: license-file
22
+
23
+ # Backtest Configurator
24
+
25
+ Write a rotation strategy as a short spec file, check it, confirm it, and run it on your own price files. Your AI
26
+ assistant can draft the spec from your words through the MCP server; you review every line, and nothing runs until
27
+ you confirm.
28
+
29
+ Every result this tool produces is **hypothetical**:
30
+
31
+ > Hypothetical backtest. These results were simulated with hindsight and didn't come from real trading. They don't
32
+ > reflect actual costs, slippage or market impact beyond what's stated, and hypothetical results have well-known
33
+ > limits. Past results, simulated or live, don't guarantee future results.
34
+
35
+ Not investment advice; not tailored to you; we are not a registered investment adviser or broker-dealer.
36
+
37
+ Terms of use: https://nothingbutalpha.app/terms#backtest-configurator
38
+
39
+ ## What it does
40
+
41
+ - **A versioned spec (v1).** Rotation strategies only: on scheduled dates, rank and hold the top N (or all eligible
42
+ assets), with equal, inverse-volatility or fixed weights. Adjusted prices only. A JSON Schema defines every field,
43
+ and a fill on the same bar as the decision cannot be written.
44
+ - **Validation before anything runs.** The tool turns the spec into plain English, lists every assumption with its
45
+ origin (your answer, filled in by the assistant, or a default), and flags values that your own text does not
46
+ state.
47
+ - **A local engine.** It runs the spec on your own CSV or Parquet files (`date,ticker,open,high,low,close`) against a
48
+ pinned NYSE calendar. It needs no API key and calls no data vendor.
49
+ - **A disclosure block with every output**, and a receipt with hashes of the spec, the data and every result file.
50
+ The receipt holds no return figures.
51
+ - **A Python export.** `strategy.py` reproduces the engine's run in plain pandas and NumPy, on files the configurator accepts. The tool includes the
52
+ Backtest Auditor's static checks, which catch some common errors and miss many.
53
+ - **Run counting.** Every run is counted in the project folder, and the count goes with every result, so you can see
54
+ how many variants were tried before this one.
55
+
56
+ ## Install
57
+
58
+ Python 3.12. The command-line tool and the MCP server need the `mcp` extra:
59
+
60
+ ```
61
+ pip install "backtest-configurator[mcp]"
62
+ ```
63
+
64
+ ## Command-line quick start
65
+
66
+ Run these from your project folder, or pass `--project-dir`:
67
+
68
+ ```
69
+ backtest-configurator validate my_strategy.yaml
70
+ backtest-configurator run my_strategy.yaml
71
+ backtest-configurator export my_strategy.yaml --out strategy.py
72
+ backtest-configurator verify .nba-configurator/results/<run>/receipt.json
73
+ backtest-configurator explain momentum
74
+ ```
75
+
76
+ - `validate` reads no price data and runs nothing.
77
+ - `run` shows the rendering, the assumptions, the flags and the run count, then asks you to type `yes` at an
78
+ interactive terminal. A plain pipe or redirect is refused, and there is no flag that skips the question.
79
+ - `verify` re-runs a logged receipt and reports whether the results reproduced. It is not a run and is not counted.
80
+
81
+ ## MCP quick start
82
+
83
+ The server is `nba-configurator-mcp`, a local stdio server. Always pass the project folder: the run log and all
84
+ results live there.
85
+
86
+ Claude Code:
87
+
88
+ ```
89
+ claude mcp add nba-configurator -- nba-configurator-mcp --project-dir /path/to/project
90
+ ```
91
+
92
+ Claude Desktop or Cursor (`mcpServers` in the client's config file):
93
+
94
+ ```json
95
+ {"mcpServers": {"nba-configurator": {"command": "nba-configurator-mcp",
96
+ "args": ["--project-dir", "/path/to/project"]}}}
97
+ ```
98
+
99
+ A run needs a client that supports MCP elicitation, because the server asks for confirmation through it. A client
100
+ without it gets the plain-English rendering and a refusal, and nothing runs. Then save the spec to a file and use
101
+ `backtest-configurator run` in your own terminal.
102
+
103
+ ## Threat model and accepted risks
104
+
105
+ What the tool protects:
106
+
107
+ - Nothing is read or run before you confirm. Validation opens no price file and no membership file.
108
+ - Writes stay inside the project folder. A symlink, a reparse point or a file with more than one hard link is
109
+ refused as a write target (item 1 below is the limit of that check).
110
+ - No network requests, no model calls. It never runs your code or the exported code.
111
+
112
+ What it does not protect against, accepted for this release:
113
+
114
+ 1. **Races in the project folder.** A process that can write in the project folder at the same moment can swap a
115
+ folder for a link between the path check and the open, or replace a data file between its check and its read.
116
+ Closing this fully needs handle-relative file access.
117
+ 2. **The confirmation records a channel, not a person.** A program that runs the command-line tool inside a
118
+ pseudo-terminal can answer the prompt, and an MCP client that accepts elicitation requests automatically can
119
+ confirm without showing the request. The receipt records the channel (`cli_prompt`, `mcp_elicitation`), never
120
+ "user confirmed".
121
+ 3. **Reads may be anywhere your account can read.** Once you confirm, a data path may point outside the project
122
+ folder. That is by design: the files are yours.
123
+ 4. **Run counts are per project folder.** A new folder starts a new count.
124
+ 5. **The `mcp` extra installs server packages the tool never uses** (an HTTP server and its dependencies). They are
125
+ pinned, but an advisory on any of them concerns this package too.
126
+ 6. **The wheel is not byte-reproducible.** Only files built and tested in CI are published, with PyPI attestations.
127
+ 7. **No hash-locked install from PyPI.** Direct dependencies are pinned exactly; transitive ones are not.
128
+ 8. **Developer regeneration commands ship in the package.** `python -m nba_configurator.schema_source --write` and
129
+ `python -m nba_configurator.nyse_calendar --write` rewrite the installed schema and calendar with the same
130
+ generated content.
131
+
132
+ ## License
133
+
134
+ Apache-2.0.
@@ -0,0 +1,49 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README_PYPI.md
4
+ pyproject.toml
5
+ backtest_configurator.egg-info/PKG-INFO
6
+ backtest_configurator.egg-info/SOURCES.txt
7
+ backtest_configurator.egg-info/dependency_links.txt
8
+ backtest_configurator.egg-info/entry_points.txt
9
+ backtest_configurator.egg-info/requires.txt
10
+ backtest_configurator.egg-info/top_level.txt
11
+ nba_configurator/__init__.py
12
+ nba_configurator/_planted.py
13
+ nba_configurator/behavior.py
14
+ nba_configurator/canonical.py
15
+ nba_configurator/cli.py
16
+ nba_configurator/confirmation.py
17
+ nba_configurator/data.py
18
+ nba_configurator/engine.py
19
+ nba_configurator/export.py
20
+ nba_configurator/metrics.py
21
+ nba_configurator/model.py
22
+ nba_configurator/nyse_calendar.py
23
+ nba_configurator/provenance.py
24
+ nba_configurator/report.py
25
+ nba_configurator/runner.py
26
+ nba_configurator/safeio.py
27
+ nba_configurator/schema_check.py
28
+ nba_configurator/schema_source.py
29
+ nba_configurator/signals.py
30
+ nba_configurator/spec.py
31
+ nba_configurator/synthetic.py
32
+ nba_configurator/verify.py
33
+ nba_configurator/yaml_io.py
34
+ nba_configurator/_data/requirements-lock.txt
35
+ nba_configurator/data/conversion_table_v1.json
36
+ nba_configurator/data/nyse_calendar_v1.json
37
+ nba_configurator/examples/a_trend_switch.yaml
38
+ nba_configurator/examples/b_sector_momentum.yaml
39
+ nba_configurator/examples/c_liquid_momentum.yaml
40
+ nba_configurator/mcp/__init__.py
41
+ nba_configurator/mcp/__main__.py
42
+ nba_configurator/mcp/content.py
43
+ nba_configurator/mcp/hardening.py
44
+ nba_configurator/mcp/prompt.py
45
+ nba_configurator/mcp/render.py
46
+ nba_configurator/mcp/sections.py
47
+ nba_configurator/mcp/server.py
48
+ nba_configurator/schema/backtest-spec-v1.json
49
+ nba_configurator/templates/strategy_v1.py.txt
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ backtest-configurator = nba_configurator.cli:main
3
+ nba-configurator-mcp = nba_configurator.mcp:main
@@ -0,0 +1,14 @@
1
+ backtest-auditor==0.7.0
2
+ PyYAML==6.0.3
3
+ jsonschema==4.26.0
4
+ numpy==2.5.4
5
+ pandas==3.0.6
6
+ pyarrow==26.0.1
7
+
8
+ [mcp]
9
+ mcp==2.3.0
10
+
11
+ [test]
12
+ pytest==9.1.1
13
+ exchange_calendars==4.13.3
14
+ hypothesis==6.170.16