57 lines
3.9 KiB
Markdown
57 lines
3.9 KiB
Markdown
# S02 — Adapt one SMA strategy for the first canonical path
|
|
|
|
Parent epic: E4. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: TypeScript strategy/quant engineering.
|
|
|
|
Scheduling source of truth: [manifest entry S02](../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).
|
|
|
|
## Intended behavior and implementation scope
|
|
|
|
Adapt one existing SMA strategy first into the approved TS decision API using the current registry alias. Remove direct ModeManager/ExecutionService access for this version; parameters and owner budget are explicit. Keep other strategies/version readers intact and visibly legacy/unsupported on the canonical path until adapted. A native conformance strategy is test-only, not a competing production implementation.
|
|
|
|
## Exclusions
|
|
|
|
No unrelated refactor, new service or broker activation.
|
|
|
|
## Likely files and ownership
|
|
|
|
- apps/stock/orchestrator/src/strategies/StrategyRegistry.ts
|
|
- apps/stock/orchestrator/src/strategies/BaseStrategy.ts
|
|
- apps/stock/orchestrator/src/strategies/builtin/SmaCrossoverStrategy.ts
|
|
- apps/stock/orchestrator/src/strategies/builtin/MeanReversionStrategy.ts
|
|
|
|
Write locks: strategy-builtins. One agent owns this change. Lock names do not override actual overlapping files.
|
|
|
|
## Dependencies and blockers
|
|
|
|
Implementation requires [S01](S01.md) integrated.
|
|
|
|
No additional economic-policy approval is needed for this narrowly scoped task.
|
|
|
|
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
|
|
|
|
## Acceptance criteria
|
|
|
|
- The versioned SMA strategy runs via the Rust session with no service injection and isolated checkpoint state.
|
|
- Entry/exit and owner sizing are explicit; prior registry alias still resolves to a deliberate version/capability.
|
|
- A new canonical run can ship after this one strategy passes; migrating every native/TS built-in is not a release gate.
|
|
|
|
## Mandatory tests
|
|
|
|
- sma_registry_alias, owner_budget_sizing, sma_checkpoint_restore, sma_next_open_trace.
|
|
- Legacy strategy/result compatibility remains; no wholesale BaseStrategy deletion.
|
|
|
|
Apply relevant [quality gates](../../QUALITY-GATES.md). Report exact commands/results and unavailable checks; named new cases are requirements, not claims of existing passing tests.
|
|
|
|
## 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.
|