feat(strategies): add canonical regime-aware mean reversion
This commit is contained in:
parent
75abae2cfc
commit
6a67ae8683
24 changed files with 1910 additions and 88 deletions
|
|
@ -451,3 +451,19 @@ The existing ingestion service has no working producer for its legacy paper Sock
|
|||
Validation: `bun run check` passed build, source/contracts, 82 tooling, 43 utility, 44 calculation, 454 integration and 150 Rust tests (four manual tests ignored), plus lint. Full isolated PostgreSQL/Redis suite: **104 tests / 719 assertions**. Strict new-test TypeScript, scoped lint/format and diff checks passed. Final release addon matches this checkout's native library; **55 tests / 481 assertions** passed against it. No performance measurements were run. Exact commands, hashes and raw logs are in `manifest.json` → `seventeenth_wave_validation` and `/tmp/stock-bot-wave17.JfETUx/`.
|
||||
|
||||
Sandbox-only connection/child-process restrictions were rerun with escalation; only the exact stalled test process was stopped. Both exact disposable fixture containers were stopped after validation. Development services, worktrees and logs were retained. No S04 commit, push, PR, default cutover or trading activation occurred. The current trusted HTTP feed boundary still needs a real provider producer and operational calendars. **Next after acceptance/commit: S05**, a small composable multi-signal/regime strategy example; performance remains deferred. R01/R11 still need ADR-006.
|
||||
|
||||
|
||||
## Eighteenth-wave execution — 2026-10-23
|
||||
|
||||
S04 is accepted and committed as `75abae2`, superseding its uncommitted handoff above. S05 proceeds under its [pinned execution contract](backlog/tasks/S05.md#execution-contract--2026-10-23). Root owns shared selection/dispatch, integration and durable restart coverage; separate strategy and native-verification owners use worktrees under `/tmp/stock-bot-wave18.V1G17v/`, with independent review.
|
||||
|
||||
One new long-only mean-reversion program composes explicit trend/momentum/reversion filters and fixed per-observation volatility gating. Both regime/no-regime modes share warmup. Native target reconciliation handles partial entries and persistent exits; no TS accounting or Rust financial changes. R08 remains the gate for performance conclusions. Performance engineering, services, default cutover and trading activation remain out of scope.
|
||||
|
||||
|
||||
**Validated handoff:** S05 is `review` / `validated_uncommitted`. Twenty source/test/config files integrate one small canonical dispatcher, a distinct versioned mean-reversion program, shared exact desired-share sizing, native/worker verification and one durable restart regression. SMA calculations/checkpoint semantics and Rust financial code are unchanged. Independent G1/G2 review accepted the integrated source and public malformed-selection tests; strict final test types passed.
|
||||
|
||||
The [comparison example](../../apps/stock/orchestrator/examples/canonical-regime-research.ts) creates four explicit requests: volatility filter on/off under baseline and caller-supplied alternative costs. Inputs, versions, seeds and policies accompany native reports. It adds no experiment scheduler or optimizer. Periods count observed bars; volatility is not elapsed-time normalized. Initial owner budgets size desired shares and do not guarantee realized spend through gaps/fees. R08 remains necessary before conclusions about trading performance.
|
||||
|
||||
Validation: `bun run check` passed build/source/contracts, 82 tooling, 43 utility, 44 calculation, 479 integration and 150 Rust tests (four manual ignored), plus lint. The final added public-schema matrix passed separately. Full disposable PostgreSQL/Redis suite: **105 tests / 728 assertions**. Final strict new-test types, scoped lint/format and diff checks passed. **98 tests / 580 assertions** passed against the final release addon, including the added matrix, worker reports, SMA regressions and durable recovery. Exact commands, hashes and logs are recorded in `manifest.json` → `eighteenth_wave_validation` and `/tmp/stock-bot-wave18.V1G17v/`.
|
||||
|
||||
Only the two exact disposable test containers and identified sandbox-stalled verifier test processes were stopped; development resources, worktrees and logs remain. No S05 commit, push, PR, optimization, benchmark measurement, default cutover or trading activation occurred. Next after acceptance/commit: **R01 immutable strategy versions and R11 dataset workbench integration**, subject to the pending [ADR-006 research-product decision](architecture/decisions/006-research-product.md). Performance work remains deferred.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Canonical development backlog
|
||||
|
||||
**First sixteen waves committed; S04 is validated and awaiting acceptance/commit.** S03 is accepted as `c01e96e`. P08 remains deferred at the owner's request. S04 adds explicit canonical paper-feed custody, readiness and operator controls; the repository has no functioning vendor stream to claim as verified. Consult manifest execution_scope and [current wave](../ROADMAP.md#seventeenth-wave-execution--2026-10-23). ADR-002/003/004/005 are approved; other policies/default cutovers remain gated.
|
||||
**First seventeen waves committed; S05 is validated and awaiting acceptance/commit.** S04 is accepted as `75abae2`. P08 remains deferred at the owner's request. S05 adds a small composable mean-reversion/regime strategy on the canonical runtime; S04 still requires an external producer for operational feed readiness. Consult manifest execution_scope and [current wave](../ROADMAP.md#eighteenth-wave-execution--2026-10-23). ADR-002/003/004/005 are approved; other policies/default cutovers remain gated.
|
||||
|
||||
## One source of truth
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
|
|||
| [S01 Run deterministic TypeScript decisions on Rust sessions](tasks/S01.md) | P0 / done | F07, ADR-004, ADR-005 | — | TypeScript trading infrastructure / M |
|
||||
| [S02 Adapt one SMA strategy for the first canonical path](tasks/S02.md) | P1 / done | S01 | — | TypeScript strategy/quant engineering / M |
|
||||
| [S03 Adapt durable paper transactions to Rust financial reducers](tasks/S03.md) | P0 / done | S01, C06, ADR-005 | — | Durable execution/Rust integration / L |
|
||||
| [S04 Establish a verified paper feed and operator safety gate](tasks/S04.md) | P1 / review | S02, S03 | — | TypeScript trading infrastructure / M |
|
||||
| [S05 Add a small composable multi-signal regime example](tasks/S05.md) | P2 / ready | S02, F08 | R08 | Quant strategy research / M |
|
||||
| [S04 Establish a verified paper feed and operator safety gate](tasks/S04.md) | P1 / done | S02, S03 | — | TypeScript trading infrastructure / M |
|
||||
| [S05 Add a small composable multi-signal regime example](tasks/S05.md) | P2 / review | S02, F08 | R08 | Quant strategy research / M |
|
||||
| [S06 Retire duplicate simulator paths after cutover proof](tasks/S06.md) | P2 / blocked | S03, S04, R05 | — | TypeScript trading infrastructure / M |
|
||||
|
||||
### E5 — Existing web backtest vertical slice
|
||||
|
|
@ -118,4 +118,4 @@ Relative size: S narrow correction, M coherent boundary, L sensitive owner-contr
|
|||
|
||||
Before any wave: unique IDs; existing task/ADR references; acyclic implementation graph; no scheduled task dependent on merged/deferred work; approvals/readiness; actual file locks; isolated native build outputs/workspace dependencies and test databases. Release gates are checked separately at activation.
|
||||
|
||||
The first sixteen waves are committed. **S04 is validated and uncommitted; performance work is deferred by the owner.** S05 is also code/ADR-ready but outside this wave. R01/R11 still need ADR-006; the multi-asset mark-policy gate still blocks default activation. No default/paper activation, push or PR is included in this continuation.
|
||||
The first seventeen waves are committed. **S05 is validated and uncommitted; performance work remains deferred by the owner.** R01/R11 still need ADR-006; the multi-asset mark-policy gate still blocks default activation. No default/paper activation, push or PR is included in this continuation.
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
{
|
||||
"schema_version": 1,
|
||||
"plan_revision": "2026-10-23.38",
|
||||
"plan_revision": "2026-10-23.40",
|
||||
"repository_base": "b7aeca4",
|
||||
"plan_status": "seventeenth_wave_review",
|
||||
"plan_status": "eighteenth_wave_review",
|
||||
"execution_authorized": true,
|
||||
"execution_scope": {
|
||||
"authorized_by": "User: commit and continue after validated S03 handoff (2026-10-23). S03 accepted/committed c01e96e; S04 prerequisites satisfied. Performance work remains deferred.",
|
||||
"tasks": [
|
||||
"S04"
|
||||
"S05"
|
||||
],
|
||||
"permissions": [
|
||||
"accepted_wave16_commits",
|
||||
"isolated_implementation",
|
||||
"local_correctness_tests",
|
||||
"local_integration_review",
|
||||
"planning_progress_updates"
|
||||
"S05 isolated implementation, correctness tests, independent review and planning updates; S04 commit authorized and completed"
|
||||
],
|
||||
"excluded": [
|
||||
"performance_profiling_or_optimization",
|
||||
|
|
@ -30,6 +26,12 @@
|
|||
"ADR-006",
|
||||
"ADR-007",
|
||||
"ADR-008"
|
||||
],
|
||||
"exclusions": [
|
||||
"Performance profiling/optimization/benchmarks",
|
||||
"New-wave commits, push, PR or trading activation",
|
||||
"Default cutover or unapproved ADR policies",
|
||||
"Other backlog tasks"
|
||||
]
|
||||
},
|
||||
"canonical_metadata": "This manifest alone owns task status, dependency edges, approvals, assignments and write locks. Task Markdown owns scope and acceptance criteria. Index/roadmap are derived views.",
|
||||
|
|
@ -1091,7 +1093,7 @@
|
|||
"epic": "E4",
|
||||
"priority": "P1",
|
||||
"severity": "High",
|
||||
"status": "review",
|
||||
"status": "done",
|
||||
"dependencies": [
|
||||
"S02",
|
||||
"S03"
|
||||
|
|
@ -1111,12 +1113,12 @@
|
|||
"assignment": "/root/s04_controls_audit",
|
||||
"branch": "wave17/s04-control",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"completed_commit": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
|
||||
"blocker": null,
|
||||
"release_gates": [],
|
||||
"worktree": "/tmp/stock-bot-wave17.JfETUx/control",
|
||||
"integration_base": "c01e96e4dd2879d0c728e57b48f5b6172adecd0f",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"integration_state": "validated_committed",
|
||||
"implementation_slices": [
|
||||
{
|
||||
"owner": "/root/s04_feed_audit",
|
||||
|
|
@ -1142,7 +1144,7 @@
|
|||
"epic": "E4",
|
||||
"priority": "P2",
|
||||
"severity": "Medium",
|
||||
"status": "ready",
|
||||
"status": "review",
|
||||
"dependencies": [
|
||||
"S02",
|
||||
"F08"
|
||||
|
|
@ -1159,14 +1161,33 @@
|
|||
"write_locks": [
|
||||
"example-strategy"
|
||||
],
|
||||
"parallel_policy": "Allowed only with satisfied dependencies/approvals and disjoint write locks AND actual files; see agents/integration.md.",
|
||||
"assignment": null,
|
||||
"branch": null,
|
||||
"parallel_policy": "Root owns shared contracts/dispatcher and one durable restart test; strategy owner owns new program/direct tests; verifier owns disjoint replay fixture/native-worker tests; independent read-only review.",
|
||||
"assignment": "/root/s04_controls_audit",
|
||||
"branch": "wave18/s05-strategy",
|
||||
"pull_request": null,
|
||||
"completed_commit": null,
|
||||
"blocker": null,
|
||||
"release_gates": [
|
||||
"R08"
|
||||
],
|
||||
"worktree": "/tmp/stock-bot-wave18.V1G17v/strategy",
|
||||
"integration_base": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
|
||||
"integration_state": "validated_uncommitted",
|
||||
"implementation_slices": [
|
||||
{
|
||||
"owner": "/root/s04_controls_audit",
|
||||
"scope": "canonical-mean-reversion.ts and direct strategy tests",
|
||||
"worktree": "/tmp/stock-bot-wave18.V1G17v/strategy"
|
||||
},
|
||||
{
|
||||
"owner": "/root/s04_feed_audit",
|
||||
"scope": "canonical-regime-research fixture and native replay/worker verification",
|
||||
"worktree": "/tmp/stock-bot-wave18.V1G17v/verification"
|
||||
},
|
||||
{
|
||||
"owner": "/root",
|
||||
"scope": "shared selection contract, dispatcher/import seam, durable restart test, example recipe and integration/planning"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -6093,7 +6114,7 @@
|
|||
"Explicit recoverPending acknowledgement permits original-time replay of already-admitted work; activation succeeds only after recovery and final readiness. No silent skipping or restamping."
|
||||
],
|
||||
"seventeenth_wave_validation": {
|
||||
"state": "validated_uncommitted",
|
||||
"state": "validated_committed",
|
||||
"work_root": "/tmp/stock-bot-wave17.JfETUx",
|
||||
"committed_before_implementation": {
|
||||
"S03": "c01e96e4dd2879d0c728e57b48f5b6172adecd0f"
|
||||
|
|
@ -6226,6 +6247,156 @@
|
|||
"d96d9a126e665226aeebc191b5b58e25eb29165cbabb4c099201f01e6364ef7f"
|
||||
]
|
||||
},
|
||||
"next": "Accept/commit S04, then S05 composable multi-signal/regime example. R01/R11 still need ADR-006; performance remains deferred."
|
||||
"next": "Accept/commit S04, then S05 composable multi-signal/regime example. R01/R11 still need ADR-006; performance remains deferred.",
|
||||
"completed_commit": "75abae2cfc65229f65273bebc2ea9ef3148cce60"
|
||||
},
|
||||
"eighteenth_wave": [
|
||||
"S05"
|
||||
],
|
||||
"eighteenth_wave_base": "75abae2cfc65229f65273bebc2ea9ef3148cce60",
|
||||
"eighteenth_wave_notes": [
|
||||
"User commit-and-continue authorizes S05 after S04 acceptance; performance remains deferred.",
|
||||
"Small second trusted TS built-in on the unchanged canonical Rust financial core; no general signal/regime framework or alpha claim.",
|
||||
"Source and decision tests may integrate before R08; research validation conclusions remain gated."
|
||||
],
|
||||
"eighteenth_wave_validation": {
|
||||
"state": "validated_uncommitted",
|
||||
"work_root": "/tmp/stock-bot-wave18.V1G17v",
|
||||
"committed_before_implementation": {
|
||||
"S04": "75abae2cfc65229f65273bebc2ea9ef3148cce60"
|
||||
},
|
||||
"scope": [
|
||||
"Distinct versioned trusted long-only mean-reversion strategy with ordinary trend/momentum/reversion/volatility functions",
|
||||
"Small exhaustive canonical built-in dispatcher; unchanged SMA semantics and shared exact desired-share sizing",
|
||||
"Existing native worker and opt-in paper composition accept either trusted built-in",
|
||||
"Four explicit regime/no-regime and alternative-cost diagnostic requests, retaining exact inputs/results",
|
||||
"Independent native ownership/risk/worker fixtures, public-schema matrix and one durable fractional recovery regression"
|
||||
],
|
||||
"source_integration": {
|
||||
"files": 20,
|
||||
"exact_hashes": {
|
||||
"apps/stock/orchestrator/examples/canonical-regime-research.ts": "e8dfb0868c01eeaa2477b4b9508fe0e3f43c0b2d8fdcf1d27eb6faffdcfe73c2",
|
||||
"apps/stock/orchestrator/src/backtest/native-worker.ts": "740bf6ba6f7a871a7e87efa53320cc93052cc5e7b8f7256417a40bfff2880435",
|
||||
"apps/stock/orchestrator/src/container.ts": "06b011668f39eefa62c1c94a3770af926ca8f30ceef9fc9cbc7f6d63c1c0ea45",
|
||||
"apps/stock/orchestrator/src/contracts/builtin-strategy.ts": "11f0be101bee4d7515de84fcb730e502f4f5092f6747f6edb0594e29f9335e00",
|
||||
"apps/stock/orchestrator/src/strategies/canonical-builtins.ts": "a91af8965c3e414c47a0d991e8fb4a5a784454c0a4c71dcb4cfbde884ab8c510",
|
||||
"apps/stock/orchestrator/src/strategies/canonical-mean-reversion.ts": "8ebd12b41e6e1d3e088d0a5309978986b45fc28ab3b1789394fc782149b65eaa",
|
||||
"apps/stock/orchestrator/src/strategies/canonical-sizing.ts": "cbc33976d2a5a94cfb676aedd510e327e740da19d8f8ca8a455447f73d5fb858",
|
||||
"apps/stock/orchestrator/src/strategies/canonical-sma.ts": "03a15b17537abca285e6082cc1da8f62c7be42a453cc69f32b7c378f9b888176",
|
||||
"test/fixtures/canonical-regime-research.ts": "49a03799c10b8731efc76b18cc81a166de66501cbb3a40e6a2dfbbd6c90d2e40",
|
||||
"test/fixtures/canonical-sma.ts": "bd1de6c04a70f82cda805e6f3b9703e5cbc9f79d7db8c118baaa10043b754928",
|
||||
"test/fixtures/canonical-strategy-worker.ts": "764e1b18980bec563803f8520552513cb50bcbc1cc0c3d1f4735f43f74468f32",
|
||||
"test/integration/canonical-builtins.test.ts": "57c65793f28ecb99aafe94998001cb0b3bd049bbafc8bb8aaceabbeef350dd0e",
|
||||
"test/integration/canonical-mean-reversion.test.ts": "be7be4a596dcefa4e58daec7a1ad9ef9fa941a809195c5787594f8900dc66026",
|
||||
"test/integration/canonical-regime-research.test.ts": "425b04ebd2d2beaf747a751b0b1cdc495000a4f1eabd4f9ca572bc2c21ebceea",
|
||||
"test/integration/canonical-sma.test.ts": "de2c27a56d7462ed7c979547adaee94172da275c1e16de73bcc89dea796b2953",
|
||||
"test/integration/canonical-strategy-worker.test.ts": "8ba7c2b087c5407719eb72942f1af28f6c79da82557dbf2a3f218cfa8771caf8",
|
||||
"test/integration/regime-research-example.test.ts": "e4037292c735aaae14e0a8052c45fff77c33e95ba21439fabf773dca1af645a6",
|
||||
"test/postgres/canonical-paper.test.ts": "8c3016116d6c32bb75becacf8e1ba8a850693cb4914df9a44867a8c3833f13e8",
|
||||
"test/postgres/paper-http.test.ts": "c944c207f325de5389732385446dcf741fecf9955635ea8937f8938f05a37c90",
|
||||
"tsconfig.check.json": "1e62c41351267b3690a00463f96300287a3e9bc88529ebd8d533289942a56589"
|
||||
},
|
||||
"source_archive": "/tmp/stock-bot-wave18.V1G17v/s05-integrated-source.tar",
|
||||
"source_archive_sha256": "a35ee1607ec524a49e1390b007cca9e5b034209812f14026c1da3adfab760570",
|
||||
"strategy_archive_sha256": "b3ab174254c2976c7ad8a24725dc5de5871e1d7a3780596525d8fa312cfce5b6",
|
||||
"verification_archive_sha256": "b652be55f6e22716fa7d29f6b370dd88ca486899ef22c919adb0a0912480d34a"
|
||||
},
|
||||
"review": {
|
||||
"reviewer": "/root/s03_review",
|
||||
"result": "G1/G2 accepted; pending strict test types subsequently passed",
|
||||
"findings_resolved": [
|
||||
"Persistent exit target0 precedes entry filters",
|
||||
"Fractional owned targets survive partial entry cancellation without rounding",
|
||||
"Blocked entry remainder is abandoned, not rebuilt while holding",
|
||||
"Both ablation modes retain identical observation-count warmup",
|
||||
"Exact new strategy version and malformed parameter/code rejection matrix"
|
||||
]
|
||||
},
|
||||
"checks": [
|
||||
{
|
||||
"command": "CARGO_BUILD_JOBS=2 bun run check",
|
||||
"result": "passed; before final additional schema-matrix test and test-only assertion typing cleanup",
|
||||
"counts": {
|
||||
"tooling": 82,
|
||||
"utilities": 43,
|
||||
"calculations": 44,
|
||||
"integration": 479,
|
||||
"rust": 150,
|
||||
"rust_manual_ignored": 4
|
||||
},
|
||||
"log": "/tmp/stock-bot-wave18.V1G17v/integration-check.log"
|
||||
},
|
||||
{
|
||||
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32819/stock_bot_safety BACKTEST_TEST_REDIS_URL=redis://127.0.0.1:32820/15 bun run test:postgres",
|
||||
"result": "passed",
|
||||
"tests": 105,
|
||||
"assertions": 728,
|
||||
"log": "/tmp/stock-bot-wave18.V1G17v/integration-postgres.log"
|
||||
},
|
||||
{
|
||||
"command": "bunx tsc --project /tmp/stock-bot-wave18.V1G17v/root-tests-tsconfig.json --noEmit",
|
||||
"result": "passed on final integrated tests including public schema matrix",
|
||||
"log": "/tmp/stock-bot-wave18.V1G17v/root-tests-typecheck-final.log"
|
||||
},
|
||||
{
|
||||
"command": "Scoped ESLint --no-ignore --max-warnings0, Prettier --check and git diff --check; final schema-matrix test separately formatted/linted",
|
||||
"result": "passed",
|
||||
"logs": [
|
||||
"/tmp/stock-bot-wave18.V1G17v/integration-lint.log",
|
||||
"/tmp/stock-bot-wave18.V1G17v/integration-format.log"
|
||||
]
|
||||
},
|
||||
{
|
||||
"command": "CARGO_BUILD_JOBS=2 bun run --cwd apps/stock/engine build:release",
|
||||
"result": "passed; addon equals local target/release/libengine.so",
|
||||
"log": "/tmp/stock-bot-wave18.V1G17v/integration-release-build.log"
|
||||
},
|
||||
{
|
||||
"command": "PIPELINE_TEST_DATABASE_URL=postgres://fixture:fixture@127.0.0.1:32819/stock_bot_safety bun test test/integration/canonical-builtins.test.ts test/integration/canonical-mean-reversion.test.ts test/integration/canonical-regime-research.test.ts test/integration/regime-research-example.test.ts test/integration/canonical-sma.test.ts test/integration/canonical-strategy-worker.test.ts test/postgres/canonical-paper.test.ts scripts/test/native-bindings.test.ts",
|
||||
"result": "passed on final release addon and final source/tests",
|
||||
"tests": 98,
|
||||
"assertions": 580,
|
||||
"log": "/tmp/stock-bot-wave18.V1G17v/integration-release-focused.log"
|
||||
}
|
||||
],
|
||||
"native": {
|
||||
"rust_source_unchanged": true,
|
||||
"final_profile": "release",
|
||||
"final_addon_sha256": "ef00eed556f5c32332d36a9a00ef710682e90deb00b54552e4b5c8bfdfbe8103",
|
||||
"local_library_matches": true,
|
||||
"performance_measurements": false
|
||||
},
|
||||
"economic_evidence": [
|
||||
"Two MR owners on one asset retain distinct grossPnl40/10 and fees1.80/1.00 under the explicit fixture",
|
||||
"Mixed SMA/MR real worker trace, projection and report equal direct native replay",
|
||||
"Insufficient funding and position limits still reject via Rust; no strategy bypass",
|
||||
"Partial native entries/exits and same-bar prevention match declared capacity/timing policies",
|
||||
"Every-step durable replacement preserves fractional0.5 holding, target cancellation, final cash1001.91 and fees0.09 exactly",
|
||||
"Four-trial illustrative comparison yields exact native accounting under explicit fee/slippage inputs; no alpha evidence claimed"
|
||||
],
|
||||
"environment_notes": [
|
||||
"Independent native build required escalation after sandbox spawnSync EPERM.",
|
||||
"Verifier sandbox IPC run stalled; exact identified processes3710409/3710825 stopped; outside-sandbox rerun passed.",
|
||||
"Verification fixture expectations corrected to existing terminal-bar no-callback and previous-completed-volume liquidity policies.",
|
||||
"Root example test changed malformed-rate fixture from semantic negative to malformed decimal: native remains financial-policy authority; test-only optional/decimal branding corrections passed strict compilation.",
|
||||
"No frontend or Python source changes; browser/Python gates not rerun. No profiling, benchmarks, optimization or trading operations."
|
||||
],
|
||||
"limitations": [
|
||||
"Illustrative fixed-threshold long-only strategy, not a fitted model or validated alpha; R08 gates walk-forward/holdout conclusions.",
|
||||
"Volatility uses per-observation adjacent simple returns; gaps are not filled or elapsed-time normalized.",
|
||||
"Owner budget sizes initial desired whole shares, not a guaranteed realized spend after gaps/fees; Rust account risk/cash remains authoritative.",
|
||||
"Example returns exact in-memory inputs/results but adds no durable experiment/artifact framework; R01/R05/R06 still own immutable code provenance and saved experiments.",
|
||||
"Legacy/default research paths and web selection remain unchanged; canonical paper is opt-in and still needs an external verified feed producer."
|
||||
],
|
||||
"cleanup": {
|
||||
"status": "completed",
|
||||
"development_resources_untouched": true,
|
||||
"worktrees_and_logs_retained": true,
|
||||
"stopped_container_ids": [
|
||||
"68be5fd0dd5266a8c45dafe6f0a00c74ac0a51ae269e626ad7faa2820f5e3ac0",
|
||||
"02b1fad58921c72a907668a0b46d10bbc26ecddbf6481e3bd6643026f9085927"
|
||||
]
|
||||
},
|
||||
"next": "Accept/commit S05; next product work R01/R11 requires pending ADR-006. Performance remains deferred; no other code/ADR-ready execution task is authorized by this handoff."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ Scheduling source of truth: [manifest entry S05](../manifest.json). No task is a
|
|||
|
||||
## Evidence and root cause
|
||||
|
||||
- **STR-01 — Verified:** Registry is a useful small boundary, but its factories receive mode/execution services; BaseStrategy mixes author decisions, order submission and hidden signal filtering. [apps/stock/orchestrator/src/strategies/StrategyRegistry.ts:7](../../../../apps/stock/orchestrator/src/strategies/StrategyRegistry.ts#L7); [apps/stock/orchestrator/src/strategies/BaseStrategy.ts:315](../../../../apps/stock/orchestrator/src/strategies/BaseStrategy.ts#L315).
|
||||
- **FIN-04 — Verified:** Native fills notify every strategy. TypeScript realized P&L uses aggregate symbol cost basis, not per-strategy cost basis. [apps/stock/engine/src/backtest/engine.rs:489](../../../../apps/stock/engine/src/backtest/engine.rs#L489); [apps/stock/orchestrator/src/execution/model.ts:108](../../../../apps/stock/orchestrator/src/execution/model.ts#L108).
|
||||
- **RES-01 — Verified:** Experimental Python feature preprocessing uses full-sample medians/quantiles; shuffled returns preserve ordinary Sharpe. These routines must not silently become validation evidence. [apps/stock/analytics/src/ml/feature_engineering.py:386](../../../../apps/stock/analytics/src/ml/feature_engineering.py#L386); [apps/stock/analytics/src/analysis/statistical_validation.py:168](../../../../apps/stock/analytics/src/analysis/statistical_validation.py#L168).
|
||||
- **STR-01 — Reverified:** S01/S02 already provide an isolated owner context and trusted SMA program. `strategies/canonical-sma.ts` still contains the single-strategy factory/binding boundary; extract only that dispatch seam for a second program.
|
||||
- **FIN-04 — Addressed by F02/F04/F05:** Owner basis, cash, fees and target reconciliation are already canonical Rust behavior. Verify independent MR/SMA owners against it; do not recreate those calculations in TypeScript.
|
||||
- **RES-01 — Still relevant:** Experimental Python full-sample preprocessing is not research evidence. S05 uses explicit fixed per-observation thresholds and no fitting; R08 still gates validation/alpha claims.
|
||||
|
||||
## Intended behavior and implementation scope
|
||||
|
||||
|
|
@ -20,11 +20,13 @@ No unrelated refactor, new service or broker activation.
|
|||
|
||||
## Likely files and ownership
|
||||
|
||||
- apps/stock/orchestrator/src/strategies/builtin/
|
||||
- apps/stock/orchestrator/src/strategies/StrategyRegistry.ts
|
||||
- libs/calculations/
|
||||
- apps/stock/orchestrator/src/contracts/builtin-strategy.ts
|
||||
- apps/stock/orchestrator/src/strategies/canonical-{builtins,sizing,sma,mean-reversion}.ts
|
||||
- apps/stock/orchestrator/src/{container,backtest/native-worker}.ts
|
||||
- test/{integration,fixtures,postgres}/canonical-regime*.ts
|
||||
- Existing SMA/worker/paper test import sites and one runnable research example
|
||||
|
||||
Write locks: example-strategy. One agent owns this change. Lock names do not override actual overlapping files.
|
||||
Write locks: example-strategy. One program owner; root owns shared contracts/dispatch, and an independent verifier owns disjoint native fixtures/tests. Lock names do not override actual overlapping files.
|
||||
|
||||
## Dependencies and blockers
|
||||
|
||||
|
|
@ -56,3 +58,25 @@ Keep migrations additive and previous results readable. Do not add a switch that
|
|||
## Handoff
|
||||
|
||||
Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.
|
||||
|
||||
|
||||
## Execution contract — 2026-10-23
|
||||
|
||||
Base `75abae2` contains accepted S04. This wave adds `mean-reversion-regime-long-only/v1` as a distinct trusted canonical strategy; it does not reinterpret legacy mean-reversion or SMA versions. The existing native worker and opt-in paper composition use one small exhaustive built-in dispatcher. Preserve all existing financial, observation-clock and recovery contracts. No Rust, legacy strategy, generic feature framework, cache, optimizer, UI/default cutover or trading activation changes.
|
||||
|
||||
- Explicit parameters: price lookback >=2; longer trend period; momentum lag >=1; return-volatility window >=2; positive entry z threshold; nonnegative smaller exit z threshold; fractional trend/momentum floors >-1; nonnegative volatility ceiling; nonnegative decimal notional-volume minimum; `regimeFilter: volatility|none`. Owner budget remains an explicit decimal amount.
|
||||
- Pure signals reuse reviewed trailing mean/population deviation/simple returns: z=(latest-mean)/deviation (flat=0); trend=mean/longerMean-1; momentum=latest/laggedClose-1; volatility=population deviation of adjacent simple returns. Periods count observations, not elapsed time; gaps are not filled or time-normalized. Warmup is max(lookback,trend,momentum+1,volatility+1) in both ablation modes.
|
||||
- Entry is the conjunction z<=-entry, trend/momentum>=floors, close*volume>=minimum and volatility<=ceiling. `none` disables only the volatility gate. These are illustrative fixed parameters, not fitted evidence. No RSI or universal score type is needed.
|
||||
- Initial desired quantity is exact floor(ownerBudget/latestClose), without a forced minimum. Rust owns admission, available cash, fees, ownership, fills and all P&L. Retain a stable target while entry gates pass. If a gate fails, permanently cap the target to min(desired, actual owned quantity), abandoning unfilled buys; held fractional fills are preserved exactly. A flat owner may start a new eligible episode.
|
||||
- Exit z>=-exit is evaluated before entry gates. Target zero persists until the owner is flat, even during low volume/high volatility and partial exits. Never cancel an outstanding exit by replacing zero with held quantity. Empty target lists preserve prior commitments; explicit zero/owned targets invoke native reconciliation.
|
||||
- State is bounded detached JSON with exact selection/version binding, original observation identity, history and desired target. Future data rejects; duplicate/older delayed bars cannot rewrite evaluated history. Stale/missing/mismatched barriers may warm state but cannot emit a new target. Fresh decisions require the newest consumed observation to match the barrier.
|
||||
- Verification covers hand calculations and threshold equality, zero variance/warmup, every-prefix state continuation, suffix causality, native partial-fill/owner/risk oracles, mixed SMA/MR worker parity, one durable restart, repeated ablation inputs and explicit fee/slippage sensitivity. No claims of profitable alpha or out-of-sample validation before R08.
|
||||
|
||||
|
||||
## Validated handoff — 2026-10-23
|
||||
|
||||
Implementation and independent G1/G2 review accepted; manifest remains `review` until acceptance/commit. See [wave18 validation](../manifest.json) for exact source hashes, commands, economic oracles and limitations. Existing SMA version/selection serialization remains stable. The MR schema rejects legacy settings, unsupported versions and untrusted code fields.
|
||||
|
||||
Use `createBuiltinStrategy` from `strategies/canonical-builtins.ts` for either trusted canonical version. The new selection is `strategyId: mean_reversion`, `strategyVersion: mean-reversion-regime-long-only/v1`, with all parameters explicit. Both the existing native worker and opt-in canonical paper composition use that dispatcher; legacy/default APIs remain separate.
|
||||
|
||||
[The research example](../../../../apps/stock/orchestrator/examples/canonical-regime-research.ts) takes an existing `StrategyReplayRequest`, an existing `NativeBacktestWorker`, explicit alternative `{feeRate, slippageRate}` and an abort signal. `createRegimeComparisons` returns four detached requests for review; `runRegimeComparisons` executes them serially and returns exact requests/native reports. The caller owns worker lifecycle and artifact/result retention. This is a reproducible diagnostic recipe, not a validation/optimization or saved-experiment framework. No model or code artifact provenance guarantee replaces pending R01/R05/R06.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue