stock-bot/docs/development/backlog/tasks/S05.md

58 lines
4.2 KiB
Markdown

# S05 — Add a small composable multi-signal regime example
Parent epic: E4. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Quant strategy research.
Scheduling source of truth: [manifest entry S05](../manifest.json). No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness.
## 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).
## Intended behavior and implementation scope
Adapt the existing mean-reversion idea as a second TS strategy/example and compose trend/momentum scores plus a simple fixed/training-only volatility regime using reviewed calculations. Ordinary functions, no universal signal/regime framework. Code/decision tests can land before R08; conclusions about performance require R08 validation.
## Exclusions
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/
Write locks: example-strategy. One agent owns this change. Lock names do not override actual overlapping files.
## Dependencies and blockers
Implementation requires [S02](S02.md), [F08](F08.md) integrated.
No additional economic-policy approval is needed for this narrowly scoped task.
Feature activation/release gates: [R08](R08.md). These do not block implementing or integrating this component against its own tests.
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
## Acceptance criteria
- Two strategy instances sharing an asset maintain independent state/basis and route fills correctly.
- Exit is not blocked by entry-only volume filters; thresholds and owner budgets are explicit.
- Regime/no-regime ablation inputs and cost-sensitivity recipe are reproducible; no alpha claim before validation release gate.
## Mandatory tests
- signal_composition_units, regime_boundary_availability, multi_strategy_ownership, no_regime_ablation_reproducibility.
Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist.
## Regression risks and rollback
Compatibility or lifecycle regression; preserve frozen inputs, old results and existing failure tests.
Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics.
## 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.