alphaengine 0.1.2__tar.gz → 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 (67) hide show
  1. {alphaengine-0.1.2 → alphaengine-0.3.0}/.github/workflows/ci.yml +6 -0
  2. alphaengine-0.3.0/.gitignore +30 -0
  3. alphaengine-0.3.0/PKG-INFO +498 -0
  4. alphaengine-0.3.0/README.md +457 -0
  5. {alphaengine-0.1.2 → alphaengine-0.3.0}/pyproject.toml +28 -0
  6. alphaengine-0.3.0/scripts/gen_docs.py +138 -0
  7. alphaengine-0.3.0/src/alphaengine/__main__.py +28 -0
  8. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/_version.py +6 -1
  9. alphaengine-0.3.0/src/alphaengine/agent/__init__.py +40 -0
  10. alphaengine-0.3.0/src/alphaengine/agent/answer.py +348 -0
  11. alphaengine-0.3.0/src/alphaengine/auth.py +138 -0
  12. alphaengine-0.3.0/src/alphaengine/cli.py +3173 -0
  13. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/client/__init__.py +8 -1
  14. alphaengine-0.3.0/src/alphaengine/client/agent.py +262 -0
  15. alphaengine-0.3.0/src/alphaengine/client/executor.py +748 -0
  16. alphaengine-0.3.0/src/alphaengine/client/session.py +481 -0
  17. alphaengine-0.3.0/src/alphaengine/commands.py +390 -0
  18. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/__init__.py +21 -0
  19. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/backtest.py +57 -10
  20. alphaengine-0.3.0/src/alphaengine/core/profile.py +282 -0
  21. alphaengine-0.3.0/src/alphaengine/core/screen.py +286 -0
  22. alphaengine-0.3.0/src/alphaengine/core/series_shapes.py +71 -0
  23. alphaengine-0.3.0/src/alphaengine/core/signals.py +283 -0
  24. alphaengine-0.3.0/src/alphaengine/core/stress.py +226 -0
  25. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/technical.py +5 -2
  26. alphaengine-0.3.0/src/alphaengine/demo.py +175 -0
  27. alphaengine-0.3.0/src/alphaengine/demo_book.py +31 -0
  28. alphaengine-0.3.0/src/alphaengine/demo_returns.py +18 -0
  29. alphaengine-0.3.0/src/alphaengine/demo_signal.py +44 -0
  30. alphaengine-0.3.0/src/alphaengine/demo_universe.py +18 -0
  31. alphaengine-0.3.0/src/alphaengine/loaders.py +227 -0
  32. alphaengine-0.3.0/src/alphaengine/model.py +248 -0
  33. alphaengine-0.3.0/tests/test_agent.py +136 -0
  34. alphaengine-0.3.0/tests/test_answer.py +263 -0
  35. alphaengine-0.3.0/tests/test_cli.py +1324 -0
  36. alphaengine-0.3.0/tests/test_client.py +711 -0
  37. alphaengine-0.3.0/tests/test_commands.py +207 -0
  38. {alphaengine-0.1.2 → alphaengine-0.3.0}/tests/test_goldens.py +40 -0
  39. alphaengine-0.3.0/tests/test_loaders.py +231 -0
  40. alphaengine-0.3.0/tests/test_screen.py +218 -0
  41. alphaengine-0.3.0/tests/test_signals.py +278 -0
  42. alphaengine-0.1.2/.gitignore +0 -14
  43. alphaengine-0.1.2/CHANGELOG.md +0 -108
  44. alphaengine-0.1.2/PKG-INFO +0 -184
  45. alphaengine-0.1.2/README.md +0 -143
  46. alphaengine-0.1.2/src/alphaengine/agent/__init__.py +0 -16
  47. alphaengine-0.1.2/src/alphaengine/client/executor.py +0 -236
  48. alphaengine-0.1.2/src/alphaengine/client/session.py +0 -237
  49. alphaengine-0.1.2/tests/test_client.py +0 -295
  50. {alphaengine-0.1.2 → alphaengine-0.3.0}/.github/workflows/publish.yml +0 -0
  51. {alphaengine-0.1.2 → alphaengine-0.3.0}/LICENSE +0 -0
  52. {alphaengine-0.1.2 → alphaengine-0.3.0}/SECURITY.md +0 -0
  53. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/__init__.py +0 -0
  54. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/agent/driver.py +0 -0
  55. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/factors.py +0 -0
  56. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/pairs.py +0 -0
  57. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/performance.py +0 -0
  58. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/risk.py +0 -0
  59. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/core/validation.py +0 -0
  60. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/py.typed +0 -0
  61. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/study/__init__.py +0 -0
  62. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/study/report.py +0 -0
  63. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/study/schema.py +0 -0
  64. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/sweep/__init__.py +0 -0
  65. {alphaengine-0.1.2 → alphaengine-0.3.0}/src/alphaengine/sweep/runner.py +0 -0
  66. {alphaengine-0.1.2 → alphaengine-0.3.0}/tests/test_smoke.py +0 -0
  67. {alphaengine-0.1.2 → alphaengine-0.3.0}/tests/test_sweep.py +0 -0
@@ -45,6 +45,12 @@ jobs:
45
45
  - run: ruff check src tests
46
46
  - run: ruff format --check src tests
47
47
  - run: mypy src
48
+ # THE FIFTH COPY GUARD. The command list lived in three hand-maintained
49
+ # places and none of them agreed: `--data` and `--universe` shipped and
50
+ # appeared in one. It is generated from `commands.py` now, and this fails
51
+ # the build when the README falls behind rather than letting a stale list
52
+ # quietly tell somebody a feature does not exist.
53
+ - run: python scripts/gen_docs.py --check
48
54
 
49
55
  # The numbers this library returns are a public contract once published: a
50
56
  # study written today has to reproduce in two years. This job exists to make
@@ -0,0 +1,30 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .coverage
12
+ htmlcov/
13
+ .DS_Store
14
+ .civenv/
15
+
16
+ # CREDENTIALS. Nothing here was ignored, so a `.env` created while working on
17
+ # this repo would have been committed to a PUBLIC repository with nothing to
18
+ # stop it. Found in a sweep 2026-08-02; no secret was ever actually committed.
19
+ .env
20
+ .env.*
21
+ *.pem
22
+ *.key
23
+ secrets.json
24
+ credentials.json
25
+
26
+ # Artifacts the package itself writes. `r.save()` drops study.json in the
27
+ # working directory by default, so running the example in a clone leaves one
28
+ # staged for the next `git add .`.
29
+ study.json
30
+ *.study.json
@@ -0,0 +1,498 @@
1
+ Metadata-Version: 2.4
2
+ Name: alphaengine
3
+ Version: 0.3.0
4
+ Summary: Validated research tooling for investment strategies: deflation, overfitting detection, and honest trial counts.
5
+ Project-URL: Homepage, https://github.com/quantOSC/alphaengine
6
+ Project-URL: Documentation, https://github.com/quantOSC/alphaengine#readme
7
+ Project-URL: Source, https://github.com/quantOSC/alphaengine
8
+ Project-URL: Issues, https://github.com/quantOSC/alphaengine/issues
9
+ Author: QuantOS
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: backtesting,deflated-sharpe,overfitting,quantitative-finance,research
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Financial and Insurance Industry
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Office/Business :: Financial :: Investment
22
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: numpy>=1.24
26
+ Requires-Dist: scipy>=1.10
27
+ Provides-Extra: agents
28
+ Requires-Dist: anthropic>=0.40; extra == 'agents'
29
+ Provides-Extra: connectors
30
+ Requires-Dist: httpx>=0.27; extra == 'connectors'
31
+ Requires-Dist: pyarrow>=15.0; extra == 'connectors'
32
+ Provides-Extra: dev
33
+ Requires-Dist: mypy==2.3.0; extra == 'dev'
34
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
35
+ Requires-Dist: pytest>=8.0; extra == 'dev'
36
+ Requires-Dist: ruff==0.16.1; extra == 'dev'
37
+ Requires-Dist: statsmodels>=0.14; extra == 'dev'
38
+ Provides-Extra: factors
39
+ Requires-Dist: statsmodels>=0.14; extra == 'factors'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # AlphaEngine
43
+
44
+ **The research loop, on your machine.** Ask what is worth looking at, whether it
45
+ holds up, how much to hold, and whether anything has crossed a line. Your data
46
+ never leaves.
47
+
48
+ ```bash
49
+ pip install alphaengine
50
+ alphaengine demo # the whole offline half, no account, no data of your own
51
+ ```
52
+
53
+ ## What it answers
54
+
55
+ Eight questions, in the order a research week actually asks them. The command
56
+ IS the question; only two of them need code of yours.
57
+
58
+ | Ask | Command | Workflow | Needs |
59
+ |---|---|---|---|
60
+ | Can I trust this data? | `diagnose` | `diagnose_data` | prices |
61
+ | What is worth a look? | `screen` | `screen_universe` | prices |
62
+ | Does this signal carry information? | `signal` | `evaluate_signal` | a signal panel + prices |
63
+ | Is this real, once you count the tries? | `validate` | `validate_study` | prices + your backtest |
64
+ | Where does it break? | `stress` | `stress_study` | a return series |
65
+ | Is it new, or my book again? | `overlap` | `check_overlap` | the candidate + the book |
66
+ | How much should I hold? | `size` | `size_position` | a return series |
67
+ | Still inside the lines? | `monitor` | `monitor_sleeve` | a return series |
68
+
69
+ ```bash
70
+ alphaengine diagnose --data prices.csv # before anything runs on it
71
+ alphaengine screen --universe sp500
72
+ alphaengine size --data returns.csv
73
+ ```
74
+
75
+ **The refusals are the point.** A screen over a universe that mostly could not
76
+ be measured is refused as a survivorship artifact rather than ranked. A size on
77
+ a record shorter than its own minimum track length is refused outright, because
78
+ a small position is still a claim and the caveat does not travel with it into a
79
+ book. A monitor with no stated tolerances reports `unchecked` — never a green
80
+ light. A stop exits 0: "this did not clear the bar" is the system working.
81
+
82
+ Or say it in plain English and let your own model pick:
83
+
84
+ ```bash
85
+ alphaengine
86
+ > which of my names are overbought on RSI?
87
+ ```
88
+
89
+ That second path is EXPLORATORY: the model chooses a workflow and then chooses
90
+ each step from what the server permits. Two runs of the same question may
91
+ differ, and the run says so. `run <workflow>` is SCRIPTED and reproducible.
92
+ Both are legitimate; presenting one as the other is not.
93
+
94
+ ## The three rungs
95
+
96
+ Each is useful without the one above it. The boot screen shows which are lit.
97
+
98
+ | Rung | What you need | What you get |
99
+ |---|---|---|
100
+ | **The maths** | nothing | Every statistic, offline, forever. No account. |
101
+ | **Workflows** | a QuantOS `ae_live_` key | The loop end to end, with the record. |
102
+ | **Ask anything** | your OWN model key | Plain English in. Runs under your account, not ours. |
103
+
104
+ Nothing here stores a model key: it is read from your environment at call time
105
+ and handed to the provider's own client. There is no field to put one in.
106
+
107
+ ## Getting your data in
108
+
109
+ Three doors, and nothing is ever fetched on your behalf.
110
+
111
+ ```bash
112
+ alphaengine run screen_universe --data prices.csv # a local CSV
113
+ alphaengine run screen_universe --universe sp500 # registered in the portal
114
+ alphaengine run validate_study --project research.momentum # a module of yours
115
+ ```
116
+
117
+ `--data` reads three shapes, decided by the header and nothing else:
118
+
119
+ ```
120
+ wide date,AAPL,MSFT,NVDA one column per name
121
+ long date,symbol,close one row per name per day
122
+ series date,close a single series, or one bare column of numbers
123
+ ```
124
+
125
+ A file it cannot place raises and names all three rather than guessing. A loader
126
+ that guesses eventually guesses wrong on somebody's book, and the failure is not
127
+ an error: it is a screen that ranked returns as prices and produced a shortlist
128
+ nobody can tell is wrong.
129
+
130
+ `--project` is the only door that can carry a **simulator**, because a simulator
131
+ is code. That is why `validate_study` needs it — and `evaluate_signal` needs it
132
+ for the scores it measures — while the rest run on prices alone.
133
+
134
+ `--universe` brings the closes you stored with it in the portal. That is your own
135
+ upload decrypted back to your own account, not us fetching market data, and the
136
+ distinction is the whole of the data boundary below.
137
+
138
+ ## Command reference
139
+
140
+ `alphaengine commands` prints this directory in the terminal, and
141
+ `alphaengine commands run` expands any one of them.
142
+
143
+ <!-- COMMANDS:START -->
144
+ <!-- Generated by scripts/gen_docs.py from src/alphaengine/commands.py.
145
+ Do not edit by hand; run `python scripts/gen_docs.py --write`. -->
146
+
147
+ ### Get started
148
+
149
+ | Command | Does | Where |
150
+ |---|---|---|
151
+ | `demo` | run the built-in example offline, with no account and no data | shell + session |
152
+ | `workflows` | what the server offers, what each needs, and which reproduce | shell + session |
153
+ | `key [quantos \| anthropic \| openai]` | enter a credential now, or see which rungs are unlocked | session |
154
+ | `commands [verb]` | this directory, or one command in full | shell + session |
155
+
156
+ ### Do the work
157
+
158
+ | Command | Does | Where |
159
+ |---|---|---|
160
+ | `diagnose` | can I trust this data? | shell + session |
161
+ | `screen` | what is worth a look? | shell + session |
162
+ | `signal` | does this signal carry information? | shell + session |
163
+ | `validate` | is this real? | shell + session |
164
+ | `stress` | where does it break? | shell + session |
165
+ | `overlap` | is it new, or my book again? | shell + session |
166
+ | `size` | how much? | shell + session |
167
+ | `monitor` | still inside the lines? | shell + session |
168
+ | `run <workflow>` | run one workflow exactly as written | shell + session |
169
+ | `<anything else>` | ask in plain English; your model picks a workflow and drives it | session |
170
+ | `status` | the current run, and what is loaded | session |
171
+
172
+ ### Bring your data
173
+
174
+ | Command | Does | Where |
175
+ |---|---|---|
176
+ | `universe <name>` | load a universe you registered in the portal, with its closes | session |
177
+ | `data <file.csv>` | load a local CSV without leaving the session | session |
178
+ | `project <module>` | load `data` and `backtest_fn` from a module of yours | session |
179
+
180
+ ### Session
181
+
182
+ | Command | Does | Where |
183
+ |---|---|---|
184
+ | `logout` | remove stored credentials from this machine | shell + session |
185
+ | `version` | print the version | shell |
186
+ | `help` | the short list | session |
187
+ | `quit` | leave the session | session |
188
+
189
+ ### Data flags
190
+
191
+ | Flag | What it takes |
192
+ |---|---|
193
+ | `--data FILE` | a local CSV. Wide (date,AAPL,MSFT), long (date,symbol,close), or one series. |
194
+ | `--universe NAME` | a universe you registered in the portal, with the closes you stored. |
195
+ | `--project MODULE` | a Python module. The only door that can carry a simulator. |
196
+
197
+ ### Flags
198
+
199
+ | Flag | Does |
200
+ |---|---|
201
+ | `--url URL` | workflow server (default $QUANTOS_API_URL or the public API) |
202
+ | `--key KEY` | portal-issued ae_live_ key (default $QUANTOS_API_KEY) |
203
+ | `--project MODULE` | a module exposing `data` and `backtest_fn` |
204
+ | `--data FILE` | a local CSV: wide, long, or a single series |
205
+ | `--universe NAME` | a universe registered in the portal, with its stored closes |
206
+ | `--symbol TICKER` | one name out of a loaded universe; its closes become the return series |
207
+ | `--sleeve NAME` | the sleeve this run belongs to, and the budget it is bound by |
208
+ | `--thesis ID` | a draft thesis to propose this run's shortlist as a sleeve for |
209
+ | `--label TEXT` | what to call the artifact this run produces |
210
+ | `--input K=V` | a workflow input; repeatable |
211
+ | `--quiet` | only the result, no step narration |
212
+
213
+ ### Examples
214
+
215
+ ```bash
216
+ alphaengine diagnose --universe <name>
217
+ alphaengine screen --universe <name>
218
+ alphaengine signal
219
+ alphaengine validate
220
+ alphaengine stress
221
+ alphaengine overlap
222
+ alphaengine size
223
+ alphaengine monitor
224
+ alphaengine demo
225
+ alphaengine workflows
226
+ alphaengine commands
227
+ alphaengine run screen_universe --universe sp500
228
+ alphaengine run size_position --data returns.csv
229
+ alphaengine run validate_study --project research.momentum
230
+ alphaengine logout
231
+ alphaengine version
232
+ ```
233
+
234
+ <!-- COMMANDS:END -->
235
+
236
+ ## The library, without the CLI
237
+
238
+ The commands above are a wrapper. Everything they compute is importable, runs
239
+ offline, and needs no account:
240
+
241
+ ```python
242
+ from alphaengine import sweep
243
+
244
+ r = sweep(backtest_fn, {"fast": [5, 10, 20], "slow": [50, 100, 200]}, data=prices)
245
+
246
+ r.surface() # is the result a broad plateau or a single lucky configuration?
247
+ r.verdict() # deflated for the 9 trials that were actually run
248
+ r.save() # study.json, on your disk
249
+ ```
250
+
251
+ The trial count is **derived from the grid that ran**, never asserted. Omit it
252
+ and it is recorded as `not_recorded` rather than defaulting to a flattering 1,
253
+ and an unrecorded denominator cannot reach an `edge` verdict at all.
254
+
255
+ ## Writing your own `backtest_fn`
256
+
257
+ Two rules, both easy to get wrong the first time, and the reason the example
258
+ above exists to copy:
259
+
260
+ **Return a bare 1-D return series.** Not a dict, not a stats object — the
261
+ per-period returns themselves. `sweep` does `np.asarray(list(raw))`, so a dict
262
+ of results iterates its *keys* and fails on the first string.
263
+
264
+ **Return the same length for every combination.** PBO splits the trial matrix
265
+ into time blocks and compares configurations within each block, which only means
266
+ anything if they line up in time. Ragged output is refused rather than truncated,
267
+ because silently trimming produces a confident number over series that do not
268
+ correspond. In practice: pick a warm-up long enough for the slowest window in
269
+ your grid and start every configuration there.
270
+
271
+ ```python
272
+ WARMUP = 200 # covers the slowest `slow` in the grid
273
+
274
+
275
+ def backtest_fn(*, data, fast, slow):
276
+ close = data["close"]
277
+ return [
278
+ (close[i + 1] - close[i]) / close[i] * (1 if sma(close, fast, i) > sma(close, slow, i) else 0)
279
+ for i in range(WARMUP, len(close) - 1)
280
+ ]
281
+ ```
282
+
283
+ `data` is whatever you want it to be — a DataFrame, a dict of series, an array.
284
+ The package never inspects it and it never leaves your machine.
285
+
286
+ ## What it does
287
+
288
+ **Runs your parameter grid.** `sweep()` calls your backtest function once per
289
+ combination. It does not backtest anything itself, so the engine you already
290
+ trust stays the engine you trust.
291
+
292
+ **Counts the trials for you.** The statistics that correct a Sharpe ratio for
293
+ multiple testing need to know how many variants were tested. That number is
294
+ almost never recorded, because nobody counts what they discarded. Running the
295
+ grid makes it `len(grid)`, so it never has to be asked for or asserted.
296
+
297
+ **Refuses to flatter an unrecorded count.** Since 0.2.0, omitting `n_trials`
298
+ means `not_recorded` — not `1`. The trial count comes back `null`,
299
+ `n_trials_source` travels beside it, and **a verdict of `edge` is unreachable
300
+ without a recorded denominator.** A deflated Sharpe is a ratio; deflating by a
301
+ denominator nobody wrote down does not produce a weaker claim, it produces a
302
+ claim about nothing.
303
+
304
+ **Shows you the neighbourhood.** The output is whether your result sits on a
305
+ broad plateau or a knife edge, and where the robust region is centred. A single
306
+ spike surrounded by failures is a result fitted to its own parameters.
307
+
308
+ **Produces a portable study.** A JSON artifact holding what was tried, what came
309
+ back, and a content hash of the data it ran on. Readable in a text editor,
310
+ diffable, and versioned so it still parses in two years.
311
+
312
+ ## What is in it
313
+
314
+ | Module | Contents |
315
+ |---|---|
316
+ | `alphaengine.core` | deflated Sharpe, PSR, PBO via CSCV, CPCV, minimum track record length, performance and risk statistics |
317
+ | `alphaengine.sweep` | the grid runner and the sensitivity surface |
318
+ | `alphaengine.study` | the study artifact and its schema |
319
+ | `alphaengine.client` | the workflow client and the step executor |
320
+ | `alphaengine.cli` | the `alphaengine` terminal entry point |
321
+
322
+ Two runtime dependencies, numpy and scipy, both already present in a typical
323
+ research environment. `import alphaengine` makes no network call and needs no
324
+ account. Factor decomposition and cointegration testing need statsmodels and
325
+ are available as `pip install 'alphaengine[factors]'`.
326
+
327
+ ## Getting a study to somebody else
328
+
329
+ `save()` writes to your disk and needs no account. When the work has to reach
330
+ the PM who will act on it, `report()` sends the study — and only the study.
331
+
332
+ ```python
333
+ import os
334
+ from alphaengine import Study, sweep
335
+
336
+ os.environ["QUANTOS_API_KEY"] = "ae_live_..." # created in the portal
337
+
338
+ r = sweep(backtest_fn, grid, data=prices)
339
+ r.save() # yours, on your disk, always
340
+
341
+ Study.from_sweep(r, label="momentum, 9 configs").report()
342
+ ```
343
+
344
+ What crosses is an explicit allowlist: the trial count and how it was obtained,
345
+ a content hash of the data, the verdict, the shape of the neighbourhood, the
346
+ performance figures. Your returns, your prices and your parameter grid stay on
347
+ the machine, and a guard keyed on length rather than field name refuses to send
348
+ anything series-shaped whatever it is called.
349
+
350
+ Reporting is the only part of this package that touches a network, so it is the
351
+ only part that is not imported until you call it. `import alphaengine` still
352
+ makes no network call.
353
+
354
+ ## Where this sits in QuantOS
355
+
356
+ AlphaEngine is the open research layer of the [QuantOS](https://github.com/quantOSC)
357
+ platform. It is the piece that runs on your machine, against your data, and it
358
+ is complete on its own: everything above works offline and forever, at no cost.
359
+
360
+ The QuantOS platform builds on it. Studies produced here can be persisted to a
361
+ firm's record, referenced when an idea becomes a position, and assembled into
362
+ the reports that go to an investment committee or an allocator. The library
363
+ computes; the platform remembers and reports. The two halves are separated so
364
+ that the part touching your data has no reason to phone home.
365
+
366
+ ## The methods
367
+
368
+ Everything in `core` comes from the published literature. Nothing here is a
369
+ proprietary formula, which is deliberate: a referee whose reasoning you cannot
370
+ inspect is not a referee.
371
+
372
+ **Deflated Sharpe Ratio, Probabilistic Sharpe Ratio, minimum track record length**
373
+ Bailey, D. H., and López de Prado, M. (2012). "The Sharpe Ratio Efficient
374
+ Frontier." *Journal of Risk* 15(2), 3 to 44.
375
+ Bailey, D. H., and López de Prado, M. (2014). "The Deflated Sharpe Ratio:
376
+ Correcting for Selection Bias, Backtest Overfitting, and Non-Normality."
377
+ *Journal of Portfolio Management* 40(5), 94 to 107.
378
+
379
+ **Probability of Backtest Overfitting via CSCV**
380
+ Bailey, D. H., Borwein, J., López de Prado, M., and Zhu, Q. J. (2017). "The
381
+ Probability of Backtest Overfitting." *Journal of Computational Finance* 20(4),
382
+ 39 to 69.
383
+
384
+ **Combinatorial purged cross-validation**
385
+ López de Prado, M. (2018). *Advances in Financial Machine Learning.* Wiley,
386
+ chapters 7 and 12.
387
+
388
+ **Multiple testing in asset pricing**
389
+ Harvey, C. R., Liu, Y., and Zhu, H. (2016). "... and the Cross-Section of
390
+ Expected Returns." *Review of Financial Studies* 29(1), 5 to 68.
391
+ Harvey, C. R., and Liu, Y. (2015). "Backtesting." *Journal of Portfolio
392
+ Management* 42(1), 13 to 28.
393
+
394
+ **Downside deviation**
395
+ Sortino, F. A., and Price, L. N. (1994). "Performance Measurement in a Downside
396
+ Risk Framework." *Journal of Investing* 3(3), 59 to 64.
397
+
398
+ **Factor regression standard errors** (in the `factors` extra)
399
+ Newey, W. K., and West, K. D. (1987). "A Simple, Positive Semi-Definite,
400
+ Heteroskedasticity and Autocorrelation Consistent Covariance Matrix."
401
+ *Econometrica* 55(3), 703 to 708.
402
+
403
+ **Unit root testing for cointegration** (in the `factors` extra)
404
+ Dickey, D. A., and Fuller, W. A. (1979). "Distribution of the Estimators for
405
+ Autoregressive Time Series with a Unit Root." *Journal of the American
406
+ Statistical Association* 74(366), 427 to 431.
407
+
408
+ ## Reproducibility
409
+
410
+ The values these functions return are treated as a public contract. A study
411
+ written today has to reproduce in two years, so a change to a computed value is
412
+ a breaking change requiring a version bump even when the signature is unchanged.
413
+ While the leading digit is 0 the minor position carries that rule — 0.1 → 0.2 is
414
+ what a changed figure costs — so every 0.2.x release produces identical numbers.
415
+ CI fails if a pinned value moves.
416
+
417
+ ## Installing: "command not found"
418
+
419
+ The console script lives in your venv's `Scripts/` (Windows) or `bin/` (POSIX),
420
+ which joins your PATH only while that venv is **activated**. A fresh install
421
+ followed by `alphaengine` therefore says *command not found*, which reads as a
422
+ broken install and is not one.
423
+
424
+ ```powershell
425
+ .\.venv\Scripts\Activate.ps1 # Windows PowerShell
426
+ source .venv/bin/activate # macOS / Linux
427
+ alphaengine
428
+ ```
429
+
430
+ Or skip activation entirely — **`python -m alphaengine` always works**, because
431
+ the interpreter that can import the package can always run it:
432
+
433
+ ```bash
434
+ .venv/Scripts/python.exe -m alphaengine # Windows, unactivated
435
+ .venv/bin/python -m alphaengine # POSIX, unactivated
436
+ ```
437
+
438
+ This is the price of in-process data access, and it is the one cost we will not
439
+ engineer around: a launcher that worked from anywhere would have to run in its
440
+ own environment, which is exactly the isolation that makes `compute.*` unable to
441
+ see your DataFrames.
442
+
443
+ The run narrates itself, because a loop you cannot watch is a loop you cannot
444
+ trust. The server names an op, this machine executes it and hands back figures:
445
+
446
+ ```
447
+ validate_study · <your workflow server>
448
+ server → compute.sweep
449
+ local · done
450
+ server → compute.deflated_sharpe
451
+ local · done
452
+ server → Stop: the surface is a ridge, not a plateau
453
+ ```
454
+
455
+ `--project` names an ordinary module of yours exposing `data` and, if the
456
+ workflow sweeps, `backtest_fn`. Authenticate with a key from the portal:
457
+
458
+ ```bash
459
+ export QUANTOS_API_KEY=ae_live_... # QUANTOS_API_URL for self-hosted or VPC
460
+ ```
461
+
462
+ **A stop exits 0.** "This did not clear the bar" is the system working, not a
463
+ broken build — a non-zero exit there would make every CI pipeline treat an
464
+ honest refusal as a failure, which is exactly the pressure that gets honesty
465
+ controls switched off. Only a run that could not execute a step exits non-zero.
466
+
467
+ > **Install this into the venv you do research in — not with `pipx` or
468
+ > `uv tool install`.** The compute steps execute in-process against your own
469
+ > DataFrames, so tool isolation, which is normally the right way to install a
470
+ > CLI, is the one thing that cannot work here. You cannot have isolation and
471
+ > in-process data access, and your data not moving is the point.
472
+
473
+ **No LLM dependency and no key field.** `AgentDriver` takes a callable, so you
474
+ bring your own model by passing a function. There is nowhere in this tool to put
475
+ a model key, ours or yours, and that is how "runs under your own account" is
476
+ satisfied structurally rather than promised.
477
+
478
+ ## Development
479
+
480
+ ```bash
481
+ python -m venv .venv && .venv/bin/pip install -e '.[dev,factors]'
482
+ ```
483
+
484
+ CI runs five gates. Run all of them before pushing — `ruff check` and
485
+ `ruff format` are different tools with different opinions, and passing one
486
+ says nothing about the other:
487
+
488
+ ```bash
489
+ python -m ruff check src tests
490
+ python -m ruff format --check src tests
491
+ python -m mypy src
492
+ python -m pytest
493
+ python -m pytest tests -m golden -q # the frozen figures
494
+ ```
495
+
496
+ ## Licence
497
+
498
+ Apache-2.0. See [LICENSE](LICENSE).