- report resolved DaysToLoad and loaded bars per series - report factor warm-up readiness without blocking startup - warn when SimSimple runs with kill switch disabled Build: clean | Tests: 500 passing | Dual-deployed: yes
68 lines
3.7 KiB
Markdown
68 lines
3.7 KiB
Markdown
# Patterns and Anti-Patterns
|
|
**Last Updated:** 2026-04-05
|
|
|
|
Capture recurring implementation patterns that impact compile stability.
|
|
|
|
## Pattern Entry Template
|
|
- **Context:** where this applies
|
|
- **Good pattern:** concise example/description
|
|
- **Anti-pattern:** concise example/description
|
|
- **Why it matters:** one sentence
|
|
|
|
## Starter Patterns
|
|
1. **NT8 override signatures**
|
|
- Good pattern: copy exact signature from official NT8 docs before coding.
|
|
- Anti-pattern: infer or copy from outdated examples.
|
|
- Why it matters: prevents `CS0115` and runtime integration drift.
|
|
|
|
2. **Access modifier on overrides**
|
|
- Good pattern: use `protected override` for NT8 lifecycle/event methods.
|
|
- Anti-pattern: `public override` or `private override`.
|
|
- Why it matters: prevents `CS0507`.
|
|
|
|
3. **C# 5 compatibility discipline**
|
|
- Good pattern: `string.Format`, explicit null checks, block-bodied members.
|
|
- Anti-pattern: string interpolation, null-conditional, expression-bodied members.
|
|
- Why it matters: prevents avoidable language-version compile failures.
|
|
|
|
4. **Managed order sequencing**
|
|
- Good pattern: set stop/target before entry on the same bar.
|
|
- Anti-pattern: entry first, then stop/target.
|
|
- Why it matters: avoids silent behavior defects and rejected assumptions.
|
|
|
|
5. **Scope-first fixes**
|
|
- Good pattern: smallest safe change in scoped files only.
|
|
- Anti-pattern: broad cleanup or adjacent-file edits during bugfix.
|
|
- Why it matters: reduces regression risk and review churn.
|
|
|
|
6. **Test project references must be explicit**
|
|
- Good pattern: verify `.csproj` `<ProjectReference>` list before writing tests that
|
|
cross project boundaries; add the reference first, then write the test.
|
|
- Anti-pattern: assume test project already references all SDK projects.
|
|
- Why it matters: CS0234 only surfaces at compile time, not during prompt authoring.
|
|
|
|
7. **Re-arm logic tied to bar, not position close**
|
|
- Good pattern (SIM): `_tradeTaken` re-arm on next bar after intent, guarded by
|
|
`MaxOpenPositions` and `DailyLossLimit` to prevent runaway risk.
|
|
- Anti-pattern (live): using bar-based re-arm when `MaxDailyTrades > 1` in live trading
|
|
— can generate a second intent while first position is still open.
|
|
- Why it matters: see DEC-20260429-01 in `docs/00-governance/decisions.md`.
|
|
- Action required: wire re-arm to position-close callback in `NT8StrategyBase` before go-live.
|
|
|
|
8. **Compiled-code provenance stamp** (2026-07-14)
|
|
- Good pattern: persist the running assembly version plus `ManifestModule.ModuleVersionId` alongside the parameter-only configuration hash.
|
|
- Anti-pattern: treat an unchanged parameter hash as proof that unchanged code is running.
|
|
- Why it matters: a mid-gate recompile/redeploy can preserve settings while changing executable behavior; the module MVID makes that drift detectable in session and trade artifacts.
|
|
|
|
## 2026-08-03 [GAP-031] — Submission-sourced trade provenance
|
|
- **DO:** Serialize grade, score, ORB range, and resolved mode from the accepted intent and the exact submission decision.
|
|
- **DON'T:** Recompute trade facts later from configuration defaults or assumed quantities.
|
|
|
|
## 2026-08-03 [GAP-032] — Session-scoped daily trade limits
|
|
- **DO:** Increment on accepted intent and reset only when the trading session date changes.
|
|
- **DON'T:** Re-arm a daily trade allowance when a position returns flat.
|
|
|
|
## 2026-08-03 [GAP-033] — Non-blocking startup readiness evidence
|
|
- **DO:** Log resolved series load settings, actual bar counts, factor thresholds, and gate safety configuration at lifecycle transitions.
|
|
- **DON'T:** Turn an observability requirement into a new trading guard or mutate runtime configuration from logging code.
|