From 0a0871101c55bfb5d3dffc327f5dbe7feabd6727 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Mon, 31 Aug 2026 20:31:39 +0300 Subject: [PATCH 1/6] #217: record the v5.7.0 Zenodo version DOI (10.5281/zenodo.22212233) in CITATION.cff + README citation block Co-Authored-By: Claude Fable 5 --- CITATION.cff | 3 +++ README.md | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 559ab1fa..708ab5ae 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -23,6 +23,9 @@ identifiers: - type: doi value: "10.5281/zenodo.22161256" description: "The v5.6.0 version DOI (2026-08-29)." + - type: doi + value: "10.5281/zenodo.22212233" + description: "The v5.7.0 version DOI (2026-08-31)." - type: doi value: "10.5281/zenodo.21473313" description: "The v5.0.0 version DOI." diff --git a/README.md b/README.md index 47e675e6..4c8127b7 100644 --- a/README.md +++ b/README.md @@ -103,10 +103,10 @@ per release via Zenodo (badge above). ``` Fetna, M. (2026). Trading Strategy Finder: a reproducible quantitative-analysis framework for futures -trading-strategy discovery and validation (Version 5.6.0) [Software]. Zenodo. -https://doi.org/10.5281/zenodo.22161256 +trading-strategy discovery and validation (Version 5.7.0) [Software]. Zenodo. +https://doi.org/10.5281/zenodo.22212233 ``` -Cite the **version you actually used** (the DOI above is v5.6.0). To cite the project in general — always +Cite the **version you actually used** (the DOI above is v5.7.0). To cite the project in general — always resolving to the newest release — use the concept DOI **`10.5281/zenodo.21473312`**. Every version DOI is listed in [`CITATION.cff`](CITATION.cff). From 81c240a124d4d81c9bfa2f6b1427b9247a641a23 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Tue, 1 Sep 2026 09:57:54 +0300 Subject: [PATCH 2/6] =?UTF-8?q?#218:=20JOSS=20paper=20(paper/paper.md=20+?= =?UTF-8?q?=20paper.bib)=20=E2=80=94=20software=20paper=20for=20submission?= =?UTF-8?q?=20from=20the=20owner's=20JOSS=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- paper/paper.bib | 32 ++++++++++++++++++ paper/paper.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 paper/paper.bib create mode 100644 paper/paper.md diff --git a/paper/paper.bib b/paper/paper.bib new file mode 100644 index 00000000..3da3176b --- /dev/null +++ b/paper/paper.bib @@ -0,0 +1,32 @@ +@article{bailey2014pseudo, + author = {Bailey, David H. and Borwein, Jonathan M. and L{\'o}pez de Prado, Marcos and Zhu, Qiji Jim}, + title = {Pseudo-mathematics and financial charlatanism: The effects of backtest overfitting on out-of-sample performance}, + journal = {Notices of the American Mathematical Society}, + volume = {61}, + number = {5}, + pages = {458--471}, + year = {2014}, + doi = {10.1090/noti1105} +} + +@article{harvey2016cross, + author = {Harvey, Campbell R. and Liu, Yan and Zhu, Heqing}, + title = {{\ldots} and the cross-section of expected returns}, + journal = {Review of Financial Studies}, + volume = {29}, + number = {1}, + pages = {5--68}, + year = {2016}, + doi = {10.1093/rfs/hhv059} +} + +@article{white2000reality, + author = {White, Halbert}, + title = {A reality check for data snooping}, + journal = {Econometrica}, + volume = {68}, + number = {5}, + pages = {1097--1126}, + year = {2000}, + doi = {10.1111/1468-0262.00152} +} diff --git a/paper/paper.md b/paper/paper.md new file mode 100644 index 00000000..6a0735e4 --- /dev/null +++ b/paper/paper.md @@ -0,0 +1,89 @@ + +--- +title: 'Trading Strategy Finder: a machine-verified, pre-registered research framework for futures trading strategies' +tags: + - Python + - quantitative finance + - backtesting + - reproducibility + - pre-registration + - futures markets +authors: + - name: Mulham Fetna + orcid: 0009-0006-4432-798X + corresponding: true + affiliation: 1 + - name: Abd Ulfatah Esper + affiliation: 1 +affiliations: + - name: BeInMedia (Nmo AI), Kuwait City, Kuwait + index: 1 +date: 2026-09-01 +bibliography: paper.bib +--- + +# Summary + +Trading Strategy Finder is a Python research framework for discovering and — more importantly — +*honestly validating* futures trading strategies. It combines a parity-locked pair of backtest +engines (a fast vectorized engine and an exact reference engine that must agree trade-for-trade), +a multi-objective optimizer (NSGA-III via Optuna) over a 165-indicator signal registry, +walk-forward fold evaluation, stressed transaction-cost reporting, and a governance layer that is +the project's distinctive contribution: a **machine-verified claims ledger**. Every number the +project publishes is a claim with three independent verifications that must fail for different +reasons, a declared blind spot, and committed evidence files; `optimize/verify/run.py` re-derives +all 79 current claims offline, with no market data, and continuous integration blocks any change +that breaks one. Studies are pre-registered before they run; negative results carry mandatory power +analyses; positive results require dumb controls and noise checks; and the live track record is +out-of-sample by construction, because the deployed parameter set and trading universe are +hash-frozen under a signed, amendment-only protocol before new data exists. + +# Statement of need + +Backtest research has a well-documented false-positive problem: selection among many implicit +trials, small per-trade effects, and cost assumptions that decide the sign of a result +[@bailey2014pseudo; @harvey2016cross; @white2000reality]. General scientific tooling for +pre-registration does not integrate with trading research pipelines, and popular open-source +backtesters (e.g., Backtrader, Zipline, vectorbt) provide simulation but no *verification +governance*: nothing in them prevents the researcher from silently re-running until something +works. Trading Strategy Finder addresses that gap. The framework's studies of opening-range +breakout (a pre-registered 225-cell, 16-year null), scheduled macroeconomic news, and forward +out-of-sample decay are all replayable by third parties from committed evidence, and the full +pipeline re-runs against any user-supplied one-minute data feed — market data are deliberately +external to the repository, so the software is data-vendor-neutral. The intended audience is +quantitative-finance researchers, reproducibility researchers, and practitioners who need an +auditable standard of evidence for strategy claims. + +# Functionality + +- **Engines:** causal box-strategy backtester with conservative fill conventions (gap-through fills + at the bar open, stop-first within a bar), an accelerated engine parity-locked to it, and golden + regression gates. +- **Optimization:** multi-objective search (Optuna/NSGA-III) with walk-forward folds, feasibility + constraints, and budget conventions; PostgreSQL-backed studies. +- **Verification:** the claims ledger (79 claims, three verifications + blind spot each, evidence + required to be git-tracked), a self-test that replays five historical defects, and data-free CI + (byte-compile, import smoke, engine parity, full ledger) required on protected branches. +- **Protocolized live record:** a signed protocol with a rule-derived instrument allowlist, frozen + parameters, repaint audits between data drops, and append-only amendments. +- **Reporting:** dashboards and full-book reports with raw/\$10/\$25 stressed-cost views. + +The engine test suite runs green on a fresh clone with no market data (data-dependent tests skip +themselves), which is also how the JOSS reviewer can exercise the software. + +# Author contributions + +M.F.: conceptualization, methodology, software, validation, formal analysis, investigation, data +curation, visualization, project administration, writing. A.U.E.: conceptualization, data curation, +supervision. + +# Acknowledgments + +This software was developed at **BeInMedia (Nmo AI)** (Kuwait • Dubai • Doha, +https://www.beinmedia.com/), which provided the research infrastructure, computing resources, and +data licensing. Substantial portions of the codebase were developed with the assistance of AI +coding agents operating under the authors' direction; all results are gated by the pre-registered +claims ledger and CI described above. + +# References + From 888f20dbbed09a8105c724b3cddce9b3e8bf5f01 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Tue, 1 Sep 2026 10:08:07 +0300 Subject: [PATCH 3/6] =?UTF-8?q?#218:=20JOSS=202026-format=20compliance=20?= =?UTF-8?q?=E2=80=94=20paper.md=20restructured=20to=20the=208=20required?= =?UTF-8?q?=20sections=20(state=20of=20the=20field,=20software=20design,?= =?UTF-8?q?=20research=20impact,=20AI-usage=20disclosure),=20bib=20extende?= =?UTF-8?q?d,=20official=20draft-PDF=20compile=20action,=20CONTRIBUTING.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .github/workflows/draft-pdf.yml | 25 ++++++ CONTRIBUTING.md | 29 +++++++ paper/paper.bib | 41 +++++++++ paper/paper.md | 144 ++++++++++++++++++++------------ 4 files changed, 186 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/draft-pdf.yml create mode 100644 CONTRIBUTING.md diff --git a/.github/workflows/draft-pdf.yml b/.github/workflows/draft-pdf.yml new file mode 100644 index 00000000..c6b01e24 --- /dev/null +++ b/.github/workflows/draft-pdf.yml @@ -0,0 +1,25 @@ +name: JOSS draft PDF +on: + push: + paths: + - paper/** + - .github/workflows/draft-pdf.yml + workflow_dispatch: + +jobs: + paper: + runs-on: ubuntu-latest + name: Paper draft + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build draft PDF + uses: openjournals/openjournals-draft-action@master + with: + journal: joss + paper-path: paper/paper.md + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: paper + path: paper/paper.pdf diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0f683e11 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Contributing + +Contributions are welcome — issues and pull requests both. This project has an unusual operating +contract, so please read two documents before writing code: + +1. **[`AGENTS.md`](AGENTS.md)** — the working rules of this repository (branch/PR flow, worktree + discipline, verification duties). They apply to human and AI contributors alike. +2. **The verification standard:** every published number in this project is a claim in the ledger + (`subprojects/Parametric-Indicators/optimize/verify/`). If your change alters a published + number, the corresponding claim and its committed evidence must change in the same PR — CI + replays the full ledger and will reject silent divergence. + +## The short version + +- **Open an issue first** describing what you intend to change; work happens on a + `feat/-` branch and lands via PR into `dev` (integration), then `main`. +- **Tests must pass without market data.** The engine suite runs green on a fresh clone + (`cd subprojects/Parametric-Indicators && pytest`); data-dependent tests skip themselves. Price + data are never committed — the pipeline runs against a user-supplied feed. +- **CI is the gate:** byte-compile, import smoke, engine-parity (fast vs exact engines must agree + trade-for-trade), and the claims-ledger replay are required checks on `dev` and `main`. +- **Research contributions** (new studies, strategy families, instruments) additionally follow the + pre-registration discipline: design filed before results are computed, negatives carry power + analyses, positives carry dumb controls and noise checks. See `docs/` for filed examples. + +## License + +By contributing you agree that your contributions are licensed under +[AGPL-3.0-or-later](LICENSE). diff --git a/paper/paper.bib b/paper/paper.bib index 3da3176b..e5305117 100644 --- a/paper/paper.bib +++ b/paper/paper.bib @@ -30,3 +30,44 @@ @article{white2000reality year = {2000}, doi = {10.1111/1468-0262.00152} } + +@misc{backtrader, + author = {Rodr{\'i}guez, Daniel}, + title = {backtrader: Python backtesting library for trading strategies}, + year = {2015}, + url = {https://github.com/mementum/backtrader} +} + +@misc{zipline, + author = {{Quantopian, Inc. and contributors}}, + title = {Zipline: a Pythonic algorithmic trading library}, + year = {2012}, + url = {https://github.com/quantopian/zipline} +} + +@misc{vectorbt, + author = {Polakow, Oleg}, + title = {vectorbt: getting into the vectorized backtesting}, + year = {2019}, + url = {https://github.com/polakowo/vectorbt} +} + +@inproceedings{optuna, + author = {Akiba, Takuya and Sano, Shotaro and Yanase, Toshihiko and Ohta, Takeru and Koyama, Masanori}, + title = {Optuna: A Next-generation Hyperparameter Optimization Framework}, + booktitle = {Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining}, + year = {2019}, + pages = {2623--2631}, + doi = {10.1145/3292500.3330701} +} + +@article{nosek2018preregistration, + author = {Nosek, Brian A. and Ebersole, Charles R. and DeHaven, Alexander C. and Mellor, David T.}, + title = {The preregistration revolution}, + journal = {Proceedings of the National Academy of Sciences}, + volume = {115}, + number = {11}, + pages = {2600--2606}, + year = {2018}, + doi = {10.1073/pnas.1708274114} +} diff --git a/paper/paper.md b/paper/paper.md index 6a0735e4..01237161 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -1,4 +1,3 @@ - --- title: 'Trading Strategy Finder: a machine-verified, pre-registered research framework for futures trading strategies' tags: @@ -18,72 +17,111 @@ authors: affiliations: - name: BeInMedia (Nmo AI), Kuwait City, Kuwait index: 1 -date: 2026-09-01 +date: 1 September 2026 bibliography: paper.bib --- # Summary -Trading Strategy Finder is a Python research framework for discovering and — more importantly — -*honestly validating* futures trading strategies. It combines a parity-locked pair of backtest -engines (a fast vectorized engine and an exact reference engine that must agree trade-for-trade), -a multi-objective optimizer (NSGA-III via Optuna) over a 165-indicator signal registry, -walk-forward fold evaluation, stressed transaction-cost reporting, and a governance layer that is -the project's distinctive contribution: a **machine-verified claims ledger**. Every number the -project publishes is a claim with three independent verifications that must fail for different -reasons, a declared blind spot, and committed evidence files; `optimize/verify/run.py` re-derives -all 79 current claims offline, with no market data, and continuous integration blocks any change -that breaks one. Studies are pre-registered before they run; negative results carry mandatory power -analyses; positive results require dumb controls and noise checks; and the live track record is -out-of-sample by construction, because the deployed parameter set and trading universe are -hash-frozen under a signed, amendment-only protocol before new data exists. +Trading Strategy Finder is a Python framework for researching trading strategies on futures +markets — and, centrally, for making the *claims* that come out of that research trustworthy. It +provides backtesting engines, a multi-objective strategy optimizer, and walk-forward evaluation, +like other backtesting tools. Its distinctive contribution is a governance layer: a +**machine-verified claims ledger** in which every number the project publishes exists as an +executable claim — the number is re-derived live from the committed evidence files that produced +it, checked by three independent verifications that must fail for different reasons (one of them a +falsification test), and accompanied by a mandatory declared blind spot. All 79 current claims +replay offline in minutes with no market data, continuous integration blocks any change that breaks +one, and a self-test replays five real historical defects and requires the harness to reject each +one for the right reason. Around the ledger, the framework operationalizes pre-registration with +append-only amendments, mandatory power analysis for negative results, dumb controls and noise +checks for positive ones, stressed transaction-cost reporting, and a live track record whose +parameters are hash-frozen under a signed protocol before evaluation data exists — making it +out-of-sample by construction. # Statement of need -Backtest research has a well-documented false-positive problem: selection among many implicit -trials, small per-trade effects, and cost assumptions that decide the sign of a result -[@bailey2014pseudo; @harvey2016cross; @white2000reality]. General scientific tooling for -pre-registration does not integrate with trading research pipelines, and popular open-source -backtesters (e.g., Backtrader, Zipline, vectorbt) provide simulation but no *verification -governance*: nothing in them prevents the researcher from silently re-running until something -works. Trading Strategy Finder addresses that gap. The framework's studies of opening-range -breakout (a pre-registered 225-cell, 16-year null), scheduled macroeconomic news, and forward -out-of-sample decay are all replayable by third parties from committed evidence, and the full -pipeline re-runs against any user-supplied one-minute data feed — market data are deliberately -external to the repository, so the software is data-vendor-neutral. The intended audience is -quantitative-finance researchers, reproducibility researchers, and practitioners who need an -auditable standard of evidence for strategy claims. +Trading-strategy research has a structural false-positive problem: the researcher controls the +number of trials, the cost assumptions, and the stopping rule, and effects are small relative to +per-trade noise. The methodology literature has quantified the damage — data-snooping reversals +[@white2000reality], the probability of backtest overfitting [@bailey2014pseudo], and +multiple-testing haircuts across published anomalies [@harvey2016cross] — but the remedies remain +conventions enforced by the same person they constrain. Researchers who want to hold themselves to +a pre-registration standard in this domain currently have no tooling that *binds* their published +numbers to the artifacts that produced them, forces negatives to state their statistical power, or +mechanically prevents the quiet edit of an evidence file. Trading Strategy Finder exists to close +that gap. Its target audience is quantitative-finance researchers, reproducibility researchers, and +practitioners who need an auditable standard of evidence for strategy claims. Market data are +deliberately external to the repository: the pipeline runs against any user-supplied one-minute +data feed, so the framework is data-vendor-neutral, and no data at all are needed to verify any +published claim. -# Functionality +# State of the field -- **Engines:** causal box-strategy backtester with conservative fill conventions (gap-through fills - at the bar open, stop-first within a bar), an accelerated engine parity-locked to it, and golden - regression gates. -- **Optimization:** multi-objective search (Optuna/NSGA-III) with walk-forward folds, feasibility - constraints, and budget conventions; PostgreSQL-backed studies. -- **Verification:** the claims ledger (79 claims, three verifications + blind spot each, evidence - required to be git-tracked), a self-test that replays five historical defects, and data-free CI - (byte-compile, import smoke, engine parity, full ledger) required on protected branches. -- **Protocolized live record:** a signed protocol with a rule-derived instrument allowlist, frozen - parameters, repaint audits between data drops, and append-only amendments. -- **Reporting:** dashboards and full-book reports with raw/\$10/\$25 stressed-cost views. +Mature open-source backtesting frameworks — Backtrader [@backtrader], Zipline +[@zipline], and vectorbt [@vectorbt], among others — provide event-driven or vectorized +simulation, portfolio accounting, and performance metrics, and QuantConnect's LEAN provides the +same as a hosted platform. All of them answer "what would this strategy have earned?"; none of them +constrain *how the researcher reports the answer*. Nothing in these tools prevents silent re-runs +until something works, headline results at zero cost assumptions, or negatives discarded without a +power analysis. On the governance side, general pre-registration infrastructure (e.g., the Open +Science Framework [@nosek2018preregistration]) records intent but does not integrate with a +computational pipeline: it cannot re-derive a published number from evidence or fail a build when a +claim breaks. Trading Strategy Finder occupies the intersection: simulation *plus* enforced +verification governance. We know of no other public trading-research codebase in which every +published number is a CI-enforced, falsifier-carrying, machine-replayable claim. -The engine test suite runs green on a fresh clone with no market data (data-dependent tests skip -themselves), which is also how the JOSS reviewer can exercise the software. +# Software design -# Author contributions +Three design decisions carry the framework. **First, verification is a data structure, not a +document.** A claim is an object binding a statement, its evidence-file paths, an executable +`value_fn` re-deriving the headline number within an explicit tolerance, three verifications +required to fail for different reasons, and a non-empty blind-spot declaration; structural rules +reject claims whose evidence is not version-controlled. This makes "the paper says X" a testable +proposition forever, at the cost of authorship overhead per claim — a trade-off we accept because +exploratory work may run unregistered but is unpublishable until registered. **Second, the engines +are redundant on purpose.** A fast vectorized engine and an exact reference engine are +parity-locked (they must agree trade-for-trade in CI) so that speed optimizations can never +silently change results — the parity suite runs data-free on synthetic sessions. **Third, the +framework distrusts its own gates.** A self-test replays five real historical defects from the +project's past — including a claim verified against notes rather than its producing artifact, and a +unit-drift defect — and requires each to be rejected *for the matching reason*, treating +rejection-by-crash as failure; this exists because the gate once passed for the wrong reason. +Optimization (NSGA-III via Optuna [@optuna]) writes to PostgreSQL studies with never-reused +prefixes, so failed campaigns remain on the record. -M.F.: conceptualization, methodology, software, validation, formal analysis, investigation, data -curation, visualization, project administration, writing. A.U.E.: conceptualization, data curation, -supervision. +# Research impact statement -# Acknowledgments +The framework is the instrument of an active 18-month research programme whose outputs are public +and re-derivable: two companion research papers submitted in 2026 — a pre-registered 225-cell, +16-year null result on opening-range breakout, and a methodology paper on the claims ledger itself +— draw every number from this repository's evidence files via the ledger, and both are reproducible +by third parties without any market data (`python3 optimize/verify/run.py`, 79/79 claims). The +software is versioned and archived with DOIs on Zenodo (concept DOI 10.5281/zenodo.21473312, eight +released versions to date), is deployed in production research use at BeInMedia, and operates a +signed, hash-frozen live evaluation protocol whose windows accumulate as new ledger claims — +a public, out-of-sample-by-construction track record that external researchers can audit +continuously. The verification pattern (claims with falsifiers and blind spots, defect-replay +self-tests, evidence-tracking rules) is domain-portable and documented for reuse beyond finance. -This software was developed at **BeInMedia (Nmo AI)** (Kuwait • Dubai • Doha, -https://www.beinmedia.com/), which provided the research infrastructure, computing resources, and -data licensing. Substantial portions of the codebase were developed with the assistance of AI -coding agents operating under the authors' direction; all results are gated by the pre-registered -claims ledger and CI described above. +# AI usage disclosure -# References +Generative AI was used substantially in this project, under human direction, and the framework's +governance was designed with that in mind. AI coding agents (Anthropic Claude-family models, +operated through the Claude Code environment) wrote large portions of the codebase, documentation, +and analysis pipeline, and assisted in drafting this paper. The human authors set the research +questions, made all core design decisions (the claim schema, engine parity, pre-registration and +verdict rules, the live protocol), reviewed the agents' outputs, and signed every pre-registration +and protocol decision. Independently of that review, correctness is enforced mechanically rather +than assumed: all AI-produced changes pass the same CI gates as any contribution — byte-compilation, +import smoke tests, engine-parity checks, and the full claims-ledger replay — and no result is +publishable except as a ledger claim with its falsifier. The defect-replay self-test described +above guards the verification layer itself. + +# Acknowledgements +This software was developed at BeInMedia (Nmo AI) — Kuwait, Dubai, and Doha +(https://www.beinmedia.com/) — which provided the research infrastructure, computing resources, +and data licensing that made the project possible. + +# References From ab3eb80dce9f3564f0436a14e84d628aa0260429 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Tue, 1 Sep 2026 10:43:43 +0300 Subject: [PATCH 4/6] =?UTF-8?q?#226:=20root=20curation=20phase=201=20?= =?UTF-8?q?=E2=80=94=20untrack=20x.md=20(scratch,=20local-only=20forward);?= =?UTF-8?q?=20era-move=20START-HERE/DATA=5FREQUEST(+csv)/demo=20to=20docs/?= =?UTF-8?q?=20with=20era=20banners;=20DATA-MAP=20path=20fix;=20README=20po?= =?UTF-8?q?inter;=20gitignore=20guards=20for=20all=20private=20root=20file?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .gitignore | 18 + README.md | 2 +- docs/DATA-AND-KNOWLEDGE-MAP.md | 2 +- .../DATA-REQUEST-2026-07-13-FULFILLED.md | 5 + ...026-07-13-release_timestamps_2010_2026.csv | 0 .../START-HERE-2026-08-legacy18-onboarding.md | 5 + .../console-output.txt | 0 .../equity_curve_dashboard.html | 0 .../live_trading_dashboard.html | 0 .../strategy-comparison.json | 0 .../trades-summary.json | 0 x.md | 323 ------------------ 12 files changed, 30 insertions(+), 325 deletions(-) rename DATA_REQUEST.md => docs/DATA-REQUEST-2026-07-13-FULFILLED.md (96%) rename DATA_REQUEST_release_timestamps_2010_2026.csv => docs/DATA-REQUEST-2026-07-13-release_timestamps_2010_2026.csv (100%) rename START-HERE.md => docs/START-HERE-2026-08-legacy18-onboarding.md (97%) rename {demo/live-demo => docs/archive/demo-live-2026-05-v1-era}/console-output.txt (100%) rename {demo/live-demo => docs/archive/demo-live-2026-05-v1-era}/equity_curve_dashboard.html (100%) rename {demo/live-demo => docs/archive/demo-live-2026-05-v1-era}/live_trading_dashboard.html (100%) rename {demo/live-demo => docs/archive/demo-live-2026-05-v1-era}/strategy-comparison.json (100%) rename {demo/live-demo => docs/archive/demo-live-2026-05-v1-era}/trades-summary.json (100%) delete mode 100644 x.md diff --git a/.gitignore b/.gitignore index 0e00090c..4f0aa891 100755 --- a/.gitignore +++ b/.gitignore @@ -360,3 +360,21 @@ subprojects/Parametric-Indicators/optimize/orb/data/grid1/orb_book_*.csv # runtime caches (wiped after any box/data change; never tracked) .wsenv/tmp/ + +# ---- local-only root files (never publish; #226 curation 2026-09-01) ---- +/scratch/ +/outreach-drafts/ +/keys.env +*.ovpn +/openvpn.log +/vpn_connect.sh +/vpn_kill.sh +/code +/data/ +/logs/ +/node_modules/ +/__pycache__/ +/combined_ledger.csv +/l2_ledger(3).csv +/last levels*.zip +/x.md diff --git a/README.md b/README.md index 4c8127b7..b71536ef 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ modelling, and a discipline of pre-registered, power-analysed, cross-instrument- | `subprojects/Parametric-Indicators/` | **The current engine** — box-strategy backtester, the fast (numpy) + exact engines (parity-locked), the optimizer, the L2 layer, the dashboard, and the golden regression gate (`perf/`). | | `subprojects/Parametric-Indicators/docs/superpowers/` | The research reports — every verdict, discovery, and honest retraction (news "priced in", gap-aware fills, the Asia-cell fluke, …). | | `subprojects/Parametric-Indicators/DAILY_REPORTS.md` | The running standup. | -| `docs/` | Workflow proposals and long-form references. **`docs/POSITIONING.md`** — where this work sits in the field, rung by rung, each cell linked to its evidence; `docs/POSITIONING-AUDIT-2026-08-29.md` — the measured audit behind it. | +| `docs/` | Workflow proposals and long-form references. Era-expired documents are kept under era-labelled names (e.g. `START-HERE-2026-08-legacy18-onboarding.md`) and `docs/archive/` — historical record, not current instructions. **`docs/POSITIONING.md`** — where this work sits in the field, rung by rung, each cell linked to its evidence; `docs/POSITIONING-AUDIT-2026-08-29.md` — the measured audit behind it. | | `src/deploy/` | **The live deployment layer** — the news-release executor (`release_executor.py`, v5.3.0–v5.4.2), the deployed power-forecast model (`power_forecast.py`, v5.4.3), the regime monitor and its schedule. The only code that touches an account. Covered by the 157-test root suite. | | `subprojects/Parametric-Indicators/shareable/`, `server-audit/` | **Snapshots, not live code** — hand-off bundles and the harvested server archive (#94). Each carries its own README saying so. | diff --git a/docs/DATA-AND-KNOWLEDGE-MAP.md b/docs/DATA-AND-KNOWLEDGE-MAP.md index 4c8e0b40..d52cbd1c 100644 --- a/docs/DATA-AND-KNOWLEDGE-MAP.md +++ b/docs/DATA-AND-KNOWLEDGE-MAP.md @@ -131,7 +131,7 @@ decision-TF CSV, 1m CSV, box CSV (`optimize/data.py::load_inputs`). | deployed champion set `best` (+ `incumbent`/`eod`) | `subprojects/Parametric-Indicators/optimize/results/{best,cap1p,eod1p}_champions_full[_].json` — ⚠️ `*.csv` there are gitignored | | golden gate (NQ 6/6 byte-identical anchors) | `subprojects/Parametric-Indicators/perf/check_golden.py` | | claims ledger (67/67) | `subprojects/Parametric-Indicators/optimize/verify/` (`run.py`, `claims_*.py`) | -| news calendar + release stamps (WS-NEWS2+) | `subprojects/Parametric-Indicators/optimize/fundamentals/data/` (+ `DATA_REQUEST_release_timestamps_2010_2026.csv` at repo root) | +| news calendar + release stamps (WS-NEWS2+) | `subprojects/Parametric-Indicators/optimize/fundamentals/data/` (+ `docs/DATA-REQUEST-2026-07-13-release_timestamps_2010_2026.csv`) | | earnings acceptance stamps / E-S1 dataset | `subprojects/Parametric-Indicators/optimize/earnings/data/` | | XNI / fusion / forward evidence | `optimize/xni/data/`, `optimize/fundamentals/*_result*`, `optimize/fwd/data/` (54 books, gate JSON, 54 screenshots) | | deployed forecast layers + artifacts | `src/deploy/{power_forecast,two_calendar_forecast,regime_monitor}.py`; playbooks + bundles under `playbooks/` | diff --git a/DATA_REQUEST.md b/docs/DATA-REQUEST-2026-07-13-FULFILLED.md similarity index 96% rename from DATA_REQUEST.md rename to docs/DATA-REQUEST-2026-07-13-FULFILLED.md index f0085f2b..50c324fb 100644 --- a/DATA_REQUEST.md +++ b/docs/DATA-REQUEST-2026-07-13-FULFILLED.md @@ -1,3 +1,8 @@ +> 🗄️ **HISTORICAL (2026-07-13) — REQUEST FULFILLED.** The 16-year 1-second/1-minute tape this +> document asks for was acquired (server-only since 2026-08-22). Kept as the record of what was +> requested and why; moved from the repo root 2026-09-01 (#226). Companion CSV: +> `DATA-REQUEST-2026-07-13-release_timestamps_2010_2026.csv`. + # DATA REQUEST — what to download, and exactly why **Date:** 2026-07-13 · For: Mulham · From: the fundamental-analysis workstream diff --git a/DATA_REQUEST_release_timestamps_2010_2026.csv b/docs/DATA-REQUEST-2026-07-13-release_timestamps_2010_2026.csv similarity index 100% rename from DATA_REQUEST_release_timestamps_2010_2026.csv rename to docs/DATA-REQUEST-2026-07-13-release_timestamps_2010_2026.csv diff --git a/START-HERE.md b/docs/START-HERE-2026-08-legacy18-onboarding.md similarity index 97% rename from START-HERE.md rename to docs/START-HERE-2026-08-legacy18-onboarding.md index d31eec4c..c70a715e 100644 --- a/START-HERE.md +++ b/docs/START-HERE-2026-08-legacy18-onboarding.md @@ -7,6 +7,11 @@ workstream: legacy-18-baseline (CLOSED 2026-08-23 — merged to main, single roo branch: dev (feature branches → dev → main) --- +> 🗄️ **HISTORICAL (era: Aug 2026, legacy18/single-root migration).** Moved from the repo root +> 2026-09-01 (#226): the migration it onboards for is complete and its instructions are superseded. +> For current onboarding read `README.md` + `AGENTS.md`; for data locations `docs/DATA-AND-KNOWLEDGE-MAP.md`. + + # START HERE — the project onboarding (single root since 2026-08-23) > ⚠️ **Data location changed 2026-08-22:** market data lives ONLY on the server (`~/Mulham/wsg-i`, `~/Mulham/data_2010_1s`); the local checkout has NO data trees. Authoritative map: `docs/DATA-AND-KNOWLEDGE-MAP.md`. diff --git a/demo/live-demo/console-output.txt b/docs/archive/demo-live-2026-05-v1-era/console-output.txt similarity index 100% rename from demo/live-demo/console-output.txt rename to docs/archive/demo-live-2026-05-v1-era/console-output.txt diff --git a/demo/live-demo/equity_curve_dashboard.html b/docs/archive/demo-live-2026-05-v1-era/equity_curve_dashboard.html similarity index 100% rename from demo/live-demo/equity_curve_dashboard.html rename to docs/archive/demo-live-2026-05-v1-era/equity_curve_dashboard.html diff --git a/demo/live-demo/live_trading_dashboard.html b/docs/archive/demo-live-2026-05-v1-era/live_trading_dashboard.html similarity index 100% rename from demo/live-demo/live_trading_dashboard.html rename to docs/archive/demo-live-2026-05-v1-era/live_trading_dashboard.html diff --git a/demo/live-demo/strategy-comparison.json b/docs/archive/demo-live-2026-05-v1-era/strategy-comparison.json similarity index 100% rename from demo/live-demo/strategy-comparison.json rename to docs/archive/demo-live-2026-05-v1-era/strategy-comparison.json diff --git a/demo/live-demo/trades-summary.json b/docs/archive/demo-live-2026-05-v1-era/trades-summary.json similarity index 100% rename from demo/live-demo/trades-summary.json rename to docs/archive/demo-live-2026-05-v1-era/trades-summary.json diff --git a/x.md b/x.md deleted file mode 100644 index 3514bb78..00000000 --- a/x.md +++ /dev/null @@ -1,323 +0,0 @@ -Post -user avatar -cvxv666 -@antpalkin -The most powerful tool in quant trading right now isn't AI. It's a piece of math from 1906 called a Markov chain. - -Citadel runs it inside the algorithms behind roughly 20% of all US stock trades - and never lets it outside the building. - -Somebody just rebuilt the whole thing where anyone can see it. - -There's now an app that runs all this math in two clicks. - -Full breakdown below. Save it before you need it. -user avatar -cvxv666 -@antpalkin -Jul 2 -Your strategy isn't losing because it's bad. It's losing because the market changed and nobody told you. - -Markets have moods: trend, chop, panic. Every strategy only works inside one of them. - -And when the mood flips, no bell rings. Your equity curve is the bell - by the time it -8:09 PM · Jul 2, 2026 -46.9K -Views -Don't miss what's happening -People on X are the first to know. -Log in -Sign up -cvxv666 on X: "The most powerful tool in quant trading right now isn't AI. It's a piece of math from 1906 called a Markov chain. Citadel runs it inside the algorithms behind roughly 20% of all US stock trades - and never lets it outside the building. Somebody just rebuilt the whole thing https://t.co/MRLAZQwpdy" / X - ----- - -To view keyboard shortcuts, press question mark -View keyboard shortcuts -Article -Conversation -Ruuj -@RuujSs -Image -How To Use The Hidden Markov Model To Detect Market Regimes (Complete Framework) -The market never tells you which regime it is in. It leaves fingerprints. Here is how to read them and build a system that trades on it. -Every trading strategy you have ever built carries an unspoken assumption. -A trend-following system assumes the market persists in a direction long enough to profit from following it. A mean-reversion system assumes the opposite that deviations correct rather than compound. Both assumptions are correct some of the time. Neither is correct all of the time. The strategy that made you money for six months and then quietly bled for the next three did not stop working because the logic broke. The market changed underneath it. -This is the single most important idea in this article: Markets do not announce a regime change. There is no signal that says "risk-off begins now." But they leave fingerprints. Returns become more erratic. Volatility clusters. Drawdowns deepen and rebounds shorten. Correlations across assets tighten. The fingerprints are there in the data. The question is how to read them systematically instead of by feel. -This is the third article in a series I have been building. The first covered pairs trading how to find genuinely anchored relationships between assets using cointegration. The second covered the Kalman filter how to estimate a hidden state, like a true hedge ratio, from noisy observations that update continuously. This article completes the trilogy with the Hidden Markov Model the framework for detecting which of several hidden regimes the market is currently in, and exactly how confident you should be about that. -Ruuj -@RuujSs -· -Jun 23 -Article cover image -How To Use The Kalman Filter To Build Smarter Trading Systems (Complete Framework) -NASA used it to navigate to the moon. Quant funds use it to navigate markets. Here is exactly how it works and how to build it. -The problem was simple to state and hard to solve. You are tracking... -If you have not read the first two, you must read them after this article. Together they form a complete picture of how serious systematic operations think about hidden state estimation in markets. -A 2025 study applying HMMs to Bitcoin markets found the model outperformed alternative approaches specifically in detecting transitions among bullish, bearish, and neutral phases information the researchers described as crucial for strategic trading decisions. A separate paper on regime-switching factor investing confirmed that strategies incorporating HMM-based regime predictions achieve both higher absolute and risk-adjusted returns compared to static approaches. This is active, current research producing measurable results, not a technique being revisited for nostalgia. -By the end of this article you will understand exactly what a Hidden Markov Model is and why "hidden" is the operative word, how the model learns regimes directly from data without ever being told what a regime looks like, the two distinct questions every HMM can answer and the two algorithms that answer them, how to correctly decide how many regimes actually exist in your data, and the specific documented failure points that separate a regime detector you can trust from one producing confident-looking noise. - - Note: This article builds the complete framework. What the model is actually doing, the full mathematics, and how to detect, and validate hidden market regimes. Read it in order every Chapter connects to the next. - -Part 1: Why "Hidden" Is the Entire Point -Start with the Markov chain you may already know. A Markov chain describes a system moving between observable states, where the probability of the next state depends only on the current state not the full history that led there. Weather is a simple example. If it is sunny today, there is some probability it stays sunny tomorrow and some probability it rains. You observe the state directly. Sunny is sunny. -Markets do not work this way, and the reason is the entire motivation for this model. -You cannot observe "the market is in a bull regime" directly. What you observe is price. Returns. Volatility. The regime. The underlying state generating those observations is hidden. You infer it from its effects, the same way a doctor infers a diagnosis from symptoms without directly observing the disease itself. -This is the core structural difference. In a standard Markov chain, the state is the observation. In a Hidden Markov Model, a hidden state sequence generates observations, and a separate observation sequence is what you actually see. The hidden states transition according to their own rules. Each hidden state, while active, generates observations according to its own statistical profile. -You never see the regime directly only the returns it produces. The model's job is inferring the hidden chain from the visible outputs. -The hidden state generates what you observe -Concretely: imagine the market has three hidden regimes calm, transitional, crisis. Each is a genuine statistical entity with its own return distribution. The calm regime produces small positive mean returns with low variance. The crisis regime produces negative mean returns with high variance. You never see "calm" or "crisis" labeled anywhere. You see a sequence of daily returns. The model's job is to infer, at each point, which regime was most likely active and how regimes transition into each other over time. -Here is a minimal illustration of the structure before the full mathematics: -python - -import numpy as np - -regime_names = ['Calm', 'Transitional', 'Crisis'] -regime_profile = { - 'Calm': (0.0008, 0.006), - 'Transitional': (0.0000, 0.014), - 'Crisis': (-0.0025, 0.030), -} -observed_returns = np.array([0.004, -0.002, 0.011, -0.031, -0.018, 0.006]) - -That gap a hidden structure you never see, versus an observed sequence you always see is what the entire model exists to bridge. -Part 2: What the Model Actually Learns -An HMM is defined by three sets of parameters. Understanding what each one represents is what makes everything after this section click. -The transition matrix describes the probability of moving from any regime to any other in one time step, including staying put. If the market is currently calm, the matrix tells you the probability it remains calm tomorrow versus shifts to transitional versus jumps straight to crisis. Regimes typically have high probability of persisting markets do not flip between calm and crisis on a coin flip day to day. -The emission distributions describe what each regime looks like statistically when it is active. In the simplest version this is a Gaussian defined by a mean and variance per regime. More sophisticated implementations feed multiple observed features simultaneously returns, realized volatility, volume with a full covariance matrix describing how these features move together within each regime. -Calm is tight and positive, transitional widens out near zero, crisis skews negative with fat tails, the regimes aren't just labels, they're statistically distinct. -Three regimes, three very different distributions -The initial state distribution is the probability of being in each regime at the very start of the observed history, before any data has been seen. -None of these are set by hand. You never decide in advance that the crisis regime has a mean return of negative 0.25% daily. The model learns all of it directly from data, through an algorithm called Baum-Welch a specific application of the more general Expectation-Maximization technique. -The process is iterative. Start with a rough initial guess for all parameters. Compute, given those parameters, how likely each observation is to belong to each regime this is the expectation step. Update the parameters to better explain the data given those probability-weighted assignments this is the maximization step. Repeat until the improvement between iterations becomes negligible. -Here is a complete, working implementation using hmmlearn, the standard Python library for this actively maintained: -python - -import numpy as np -import pandas as pd -from hmmlearn.hmm import GaussianHMM - -def fit_regime_model(returns: pd.Series, n_states: int = 3, - n_restarts: int = 10, random_state: int = 42): - X = returns.values.reshape(-1, 1) - best_model = None - best_score = -np.inf - - for seed in range(n_restarts): - try: - model = GaussianHMM( - n_components=n_states, - covariance_type="full", - n_iter=1000, - random_state=random_state + seed - ) - model.fit(X) - score = model.score(X) - except Exception: - continue - - if score > best_score: - best_score = score - best_model = model - - return best_model, best_score - -Ten independent restarts, keeping the one with the highest final log-likelihood, is the current documented practice for avoiding a common and well-known failure of this algorithm one covered fully in Chapter 5. -Part 3: The Two Questions Every HMM Answers -Once fitted, a model can answer two genuinely different questions. Conflating them is one of the most common and consequential mistakes in practical implementations. -The decoding question: what regime was the market in at each point in the past? -Given the full observed sequence and a fitted model, what is the single most likely sequence of hidden regimes that produced it? The Viterbi algorithm answers this efficiently, searching through the space of possible regime sequences and identifying the one with the highest overall probability rather than checking every combination individually. -python - -def decode_historical_regimes(model, returns: pd.Series) -> pd.Series: - X = returns.values.reshape(-1, 1) - hidden_states = model.predict(X) - return pd.Series(hidden_states, index=returns.index) - -This gives a clean regime label for every historical time point, genuinely useful for understanding how a strategy performed across different historical regimes, or building the shaded-region regime chart you have likely seen in research reports. -Viterbi doesn't just label each day independently, it finds the single sequence of regimes (calm → transitional → crisis) that's most probable given the whole path, not just one point in time. -Finding the most likely path through time -The filtering question: what regime is the market in right now, given only what has happened up to today? -This is the computation that actually matters for live trading, and it is structurally different. The forward algorithm computes the probability of being in each regime at the current time step using only observations up to and including today, nothing beyond it. -python - -from scipy.stats import multivariate_normal - -def filtered_regime_probabilities(model, data) -> pd.DataFrame: - X = data.values.reshape(-1, 1) if data.ndim == 1 else data.values - n_obs, n_states = X.shape[0], model.n_components - - emission_probs = np.zeros((n_obs, n_states)) - for i in range(n_states): - emission_probs[:, i] = multivariate_normal.pdf( - X, mean=model.means_[i], cov=model.covars_[i] - ) - - filtered = np.zeros((n_obs, n_states)) - alpha = model.startprob_ * emission_probs[0] - alpha /= alpha.sum() - filtered[0] = alpha - - for t in range(1, n_obs): - alpha = (filtered[t - 1] @ model.transmat_) * emission_probs[t] - alpha /= alpha.sum() - filtered[t] = alpha - - return pd.DataFrame( - filtered, index=data.index, - columns=[f'Regime_{i}' for i in range(n_states)] - ) - -Here is the single most important practical distinction in this entire article, stated plainly: smoothed probabilities use the entire dataset, including observations occurring after the point being evaluated, and are appropriate only for historical analysis. Filtered probabilities use only data available up to the current point and are the only appropriate choice for live decision-making. -Using smoothed probabilities to backtest a strategy that is meant to run live is a lookahead bias error. It is one of the most common mistakes in published research on this exact topic. A strategy that looks excellent in a backtest using smoothed regime labels can perform completely differently once deployed, because live trading only ever has access to filtered information the model on any given day has not yet seen tomorrow's return. -If you take one rule from this article, take this one: for anything touching live capital, use filtered probabilities computed incrementally as each new observation arrives. Reserve the Viterbi decoded path and smoothed probabilities strictly for research, historical labeling, and diagnostics. -Part 4: Choosing How Many Regimes Actually Exist -This has no clean textbook answer, and every serious implementation confronts it directly. -The number of hidden states is not learned by the model, it is chosen before fitting begins. Fit too few and you blend genuinely distinct market conditions together. Fit too many and you carve genuine regimes into statistically unstable fragments that do not generalize. -The standard approach combines two things. First, an information criterion - typically the Bayesian Information Criterion, which penalizes model complexity so you are not simply rewarded for adding states that fit noise better. -python - -def select_regime_count(returns: pd.Series, state_range=range(2, 7), - n_restarts: int = 10) -> pd.DataFrame: - T = len(returns) - results = [] - - for n_states in state_range: - best_model, best_logL = fit_regime_model( - returns, n_states=n_states, n_restarts=n_restarts - ) - if best_model is None: - continue - - n_params = ( - n_states * (n_states - 1) - + n_states - + n_states - + (n_states - 1) - ) - bic = -2 * best_logL + n_params * np.log(T) - - results.append({ - 'n_states': n_states, - 'log_likelihood': best_logL, - 'bic': bic - }) - - return pd.DataFrame(results).sort_values('bic') - -In practice, BIC alone is rarely decisive. Financial HMM literature generally finds performance concentrated in the two-to-four state range, and BIC scores are frequently similar across three, four, and five states meaning the statistical criterion often does not cleanly point to one right answer. This is where a second consideration becomes essential: interpretability and stability. A three-state model that cleanly separates into calm, transitional, and crisis regimes, each with an intuitive economic story and each persisting for a reasonable duration, is more useful than a four-state model with a marginally better BIC score that produces regimes flickering back and forth every few days. -There is a documented empirical pattern worth internalizing: models with four or more states often reduce BIC only marginally while producing unstable smoothed probabilities and states difficult to justify economically. Published research has explicitly chosen a two-state model over a marginally better four-state model specifically because portfolio performance built on the two-state regimes was materially better and the states themselves were more interpretable. -python - -def check_regime_stability(model, returns: pd.Series, - min_avg_duration_days: float = 3.0) -> dict: - """ - Validate that detected regimes persist for economically sensible - durations rather than flickering between states rapidly. - """ - states = decode_historical_regimes(model, returns) - durations = [] - current_state = states.iloc[0] - current_duration = 1 - - for i in range(1, len(states)): - if states.iloc[i] == current_state: - current_duration += 1 - else: - durations.append(current_duration) - current_state = states.iloc[i] - current_duration = 1 - durations.append(current_duration) - - avg_duration = np.mean(durations) - is_stable = avg_duration >= min_avg_duration_days - - print(f"Average regime duration : {avg_duration:.1f} days") - print(f"Number of transitions : {len(durations)}") - print(f"Stable : {is_stable}") - - return {'avg_duration': avg_duration, 'is_stable': is_stable, - 'durations': durations} - -The practical workflow current research converges on: fit models across a small range of state counts, typically two through six, each with multiple random restarts. Compare BIC across state counts as one input, not the deciding factor. Check whether the resulting regimes are persistent and economically interpretable. Only commit to a state count when the statistical criterion and the qualitative inspection agree. -Part 5: Where the Model Genuinely Struggles -Every serious treatment of this topic in current literature is direct about specific, well-documented weak points. Knowing them precisely is what separates a regime detector you can trust from one producing confident-looking numbers that mislead you. -Baum-Welch finds a local maximum, not a global one. -The likelihood surface Expectation-Maximization climbs is not smooth, it has many local peaks. Starting from a poor initial guess, the algorithm can converge to a solution that is mathematically stable, the likelihood stops improving between iterations while still being a substantially worse explanation of the data than a different solution reachable from a different starting point. This matters enormously in finance specifically, because different local optima can correspond to genuinely different regime interpretations of the same data. One fit might identify a clean three-regime structure; a different fit on identical data from a different starting point might converge to a degenerate solution where one regime absorbs almost no observations. -A poorly initialized EM run can converge to a local maximum that looks like a good fit but isn't — this is the silent failure mode nobody checks for. -Why initialization matters -Fit from multiple random initializations, ten independent restarts is the commonly documented figure and retain the highest final log-likelihood. A single fit from a single starting point should never inform a decision that matters. -Regime persistence is not always what the standard model assumes. -The basic HMM assumes that once in a regime, the probability of leaving it next period is constant which implies expected regime duration follows a geometric distribution. This is mathematically convenient but not always realistic. Crisis regimes especially often have duration patterns that do not match this assumption well. The check_regime_stability function above is a practical guard: if detected regimes are flickering at durations far shorter than economically sensible, this assumption is being violated in a way that matters, and either the feature set or the state count needs reconsidering before the model is trusted. -The features you feed the model matter more than the algorithm choice. -An HMM fitted only on daily returns finds regimes defined purely by return characteristics. Legitimate, but only one of many possible regime definitions. Feeding the model realized volatility, volume, or cross-asset correlation alongside returns produces a genuinely richer regime structure. -python - -def build_multivariate_features(prices: pd.DataFrame, - vol_window: int = 20) -> pd.DataFrame: - returns = prices['close'].pct_change() - realized_vol = returns.rolling(vol_window).std() * np.sqrt(252) - volume_z = ( - (prices['volume'] - prices['volume'].rolling(vol_window).mean()) - / prices['volume'].rolling(vol_window).std() - ) - - features = pd.DataFrame({ - 'returns': returns, - 'realized_vol': realized_vol, - 'volume_z': volume_z - }).dropna() - - return features - - -def fit_multivariate_regime_model(features: pd.DataFrame, - n_states: int = 3, - n_restarts: int = 10): - X = features.values - best_model, best_score = None, -np.inf - - for seed in range(n_restarts): - try: - model = GaussianHMM( - n_components=n_states, - covariance_type="full", - n_iter=1000, - random_state=seed - ) - model.fit(X) - score = model.score(X) - except Exception: - continue - - if score > best_score: - best_score, best_model = score, model - - return best_model, best_score - -Current research on Bitcoin regime detection specifically incorporates market sentiment, regulatory developments, and macroeconomic conditions precisely because pure price-based features miss structural shifts that these additional dimensions capture. The choice of what to feed the model is a design decision with as much impact on the outcome as the choice of state count. -A detected regime is a statistical summary, not a discovered physical fact. -This is worth internalizing conceptually. Hidden states in an HMM are not objects waiting to be found the way a hidden planet is found through its gravitational pull on other bodies. They are model-based summaries of changing statistical behavior, and what you find depends on your assumptions, your features, your chosen state count, and your validation discipline. Used well, an HMM is a structured way of asking a genuinely useful question, what kind of market am I probably trading in right now, and how should that change my risk posture rather than a claim to have discovered one true regime structure underlying markets. -The Summary -Markets do not announce their regime. This entire article is built on that observation and what follows from taking it seriously. -A Hidden Markov Model does not predict where the market is going. It answers a more modest and more useful question: given everything observed up to this moment, what is the most statistically coherent explanation of the hidden state currently generating those observations, and how confident should that explanation be. The transition matrix and emission distributions are learned entirely from data through Baum-Welch. The current regime is inferred through the forward algorithm for live use, or the Viterbi algorithm for historical analysis and confusing the two, using smoothed probabilities where filtered ones belong, is the most common and most consequential mistake in practical implementations. -Research published this year confirms the framework is not a historical artifact. It is active and producing measurably better risk-adjusted outcomes than static approaches when applied with the discipline this article has laid out. -Cointegration confirms the relationship exists, the Kalman filter tracks it continuously, and the HMM adds regime context, together they feed the trading decision. -The three-layer pipeline -Three articles. Cointegration establishes whether a relationship between two assets is real. The Kalman filter tracks how that relationship continuously evolves. The Hidden Markov Model tracks the discrete regime the broader market is currently operating in. Together they form a genuinely complete framework for the question every systematic trader eventually has to confront: not just what is the signal, but what kind of market is this signal currently operating in, and how much should that change what I do. - - I’m Ruuj a backend developer, researcher, and working on quant systems. DMs are open for thoughtful discussions and collaborations. - -Here is the question I want you to think about. -In your own systematic work right now, where are you currently applying one fixed strategy logic across all market conditions, when the honest answer is that the market has been quietly operating in several distinct regimes the whole time? The Hidden Markov Model is the right tool whenever that answer is: my strategy assumes one kind of market, and I am not tracking when that assumption stops being true. -That answer comes up more often than most people expect. -Want to publish your own Article? -Upgrade to Premium -5:38 PM · Jul 7, 2026 -· -169.2K - -Views -View quotes -Mulham Fetna - - From bc9c0f5e3cdeb8523b2b90c4e83a618ecb2f192d Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Tue, 1 Sep 2026 11:05:26 +0300 Subject: [PATCH 5/6] =?UTF-8?q?#226=20phase=202:=20label-don't-move=20?= =?UTF-8?q?=E2=80=94=20README=20'What's=20here'=20completed=20(one=20row?= =?UTF-8?q?=20per=20top-level=20dir,=20table=20split=20fixed,=20stale=20sr?= =?UTF-8?q?c/main=20line=20corrected)=20+=20era/status=20READMEs=20inside?= =?UTF-8?q?=20frontend,=20scripts,=20templates,=20deploy=5Fout=5Fd3/d4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- README.md | 10 ++++++++-- deploy_out_d3/README.md | 4 ++++ deploy_out_d4/README.md | 4 ++++ frontend/README.md | 6 ++++++ scripts/README.md | 5 +++++ templates/README.md | 4 ++++ 6 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 deploy_out_d3/README.md create mode 100644 deploy_out_d4/README.md create mode 100644 frontend/README.md create mode 100644 scripts/README.md create mode 100644 templates/README.md diff --git a/README.md b/README.md index b71536ef..2d46d6e2 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,17 @@ modelling, and a discipline of pre-registered, power-analysed, cross-instrument- | `subprojects/Parametric-Indicators/docs/superpowers/` | The research reports — every verdict, discovery, and honest retraction (news "priced in", gap-aware fills, the Asia-cell fluke, …). | | `subprojects/Parametric-Indicators/DAILY_REPORTS.md` | The running standup. | | `docs/` | Workflow proposals and long-form references. Era-expired documents are kept under era-labelled names (e.g. `START-HERE-2026-08-legacy18-onboarding.md`) and `docs/archive/` — historical record, not current instructions. **`docs/POSITIONING.md`** — where this work sits in the field, rung by rung, each cell linked to its evidence; `docs/POSITIONING-AUDIT-2026-08-29.md` — the measured audit behind it. | - | `src/deploy/` | **The live deployment layer** — the news-release executor (`release_executor.py`, v5.3.0–v5.4.2), the deployed power-forecast model (`power_forecast.py`, v5.4.3), the regime monitor and its schedule. The only code that touches an account. Covered by the 157-test root suite. | +| `deploy_out_d3/`, `deploy_out_d4/` | **Live output directories** of the deployment layer (events/results per instrument). Written by `src/deploy/` — do not move or rename. | +| `src/api|data|optimization|strategy/`, `scripts/`, `templates/` | **The frozen v1-era stack** (May 2026): the original API, data pipeline, optimizer and strategy code plus its two prep scripts and dashboard template. Frozen — no new work lands here — but still wired together and covered by the root test suite, so it stays runnable. | +| `frontend/` | **The v1-era dashboard UI** (Vue + Vite, frozen May 2026; `npm install && npm run dev`, backend = `src/api`). The current research dashboard lives in the engine, not here. | +| `tests/` | The root suite (157 tests): `src/` incl. the live deploy layer + workflow guards. Green without market data. | +| `playbooks/` | The champion playbooks (37 PDFs) + the portable backtest bundle that reproduces them. | +| `paper/` | The JOSS software paper (`paper.md` + `paper.bib`); compiled by the "JOSS draft PDF" action. | | `subprojects/Parametric-Indicators/shareable/`, `server-audit/` | **Snapshots, not live code** — hand-off bundles and the harvested server archive (#94). Each carries its own README saying so. | -The frozen **v1.x** era (`src/main/`) is preserved under the `v1.0.0` / `v1.0-working` tags. +The **v1.x era** is preserved two ways: the tagged releases `v1.0.0` / `v1.0-working`, and the frozen +v1 stack above (kept importable and test-covered rather than deleted). ## Two tiers of reproducibility (read this before judging the numbers) diff --git a/deploy_out_d3/README.md b/deploy_out_d3/README.md new file mode 100644 index 00000000..ed339bb5 --- /dev/null +++ b/deploy_out_d3/README.md @@ -0,0 +1,4 @@ +# deploy_out_d3/ — LIVE output directory (do not move or rename) + +Written by the deployed layer in `src/deploy/` (per-instrument events + results). The path is +referenced by deployed code; contents are runtime artifacts of the live/paper deployment. diff --git a/deploy_out_d4/README.md b/deploy_out_d4/README.md new file mode 100644 index 00000000..093cbdaa --- /dev/null +++ b/deploy_out_d4/README.md @@ -0,0 +1,4 @@ +# deploy_out_d4/ — LIVE output directory (do not move or rename) + +Written by the deployed layer in `src/deploy/` (per-instrument events + results). The path is +referenced by deployed code; contents are runtime artifacts of the live/paper deployment. diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 00000000..52f6b3dc --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,6 @@ +# frontend/ — v1-era dashboard UI (FROZEN, May 2026) + +The original Vue 3 + Vite dashboard of the v1 stack (`npm install && npm run dev`; backend = +`src/api/app.py`). Frozen since 2026-05-26 — no new work lands here; kept runnable as part of the +preserved v1 era (see the root README's "What's here"). The **current** research dashboard lives in +`subprojects/Parametric-Indicators/` and is served from the compute server. diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..54fbf5af --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,5 @@ +# scripts/ — v1-era data-prep scripts (FROZEN, May 2026) + +`preprocess_boxes.py` and `split_data_by_year.py` belong to the frozen v1 stack (referenced by +`src/api` / `src/strategy`, covered by the root test suite). Not used by the current engine — its +tooling lives under `subprojects/Parametric-Indicators/`. Kept so the v1 era stays runnable. diff --git a/templates/README.md b/templates/README.md new file mode 100644 index 00000000..aaf8e37b --- /dev/null +++ b/templates/README.md @@ -0,0 +1,4 @@ +# templates/ — v1-era dashboard template (FROZEN, May 2026) + +`ultimate_dashboard.html.tpl` is rendered by the frozen v1 stack (`src/api/app.py`). Not used by +the current engine dashboard. Kept so the v1 era stays runnable. From f6e450ebad70dbbfd8e3dcc689304b5ff3ee9f76 Mon Sep 17 00:00:00 2001 From: Mulham Fetna Date: Tue, 1 Sep 2026 11:15:35 +0300 Subject: [PATCH 6/6] v5.7.1 bump: CITATION.cff version/date for the curation+JOSS-paper release Co-Authored-By: Claude Fable 5 --- CITATION.cff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 708ab5ae..4d582d8b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -12,8 +12,8 @@ authors: given-names: Mulham orcid: "https://orcid.org/0009-0006-4432-798X" email: contact@mulhamfetna.com -version: 5.7.0 -date-released: "2026-08-31" +version: 5.7.1 +date-released: "2026-09-01" license: AGPL-3.0-or-later doi: "10.5281/zenodo.21473312" identifiers: