[GOV]: record GAP-077 implementation and validation status
This commit is contained in:
@@ -43,13 +43,17 @@ Use this file to record durable project decisions that affect implementation pat
|
||||
### DEC-20261024-01
|
||||
- **ID:** DEC-20261024-01
|
||||
- **Date:** 2026-10-24
|
||||
- **Status:** decided — GAP-077 opened and prompted (`NEXT_PROMPT.md` Appendix B → `TASK_GAP077_BACKTEST_HISTORICAL_GUARD_PROMPT.md`)
|
||||
- **Status:** implemented — GAP-077 source commit `e2439c0adfedf22cfd21f3039b309703458042c4`; `verify-build.bat` 590/590 tests; operator validation pending
|
||||
- **Context:** Operator reported that backtests have stopped taking trades. Reviewed `session_20261019_155354.log` (Strategy Analyzer, MNQ SEP26, Jan–Oct 2026) and the deployed `bin\Custom\Strategies\NT8StrategyBase.cs`.
|
||||
- **Finding — GAP-077 (HIGH):** the header reads `Account : Backtest`. Strategy Analyzer assigns a non-null `Backtest` account. `ProcessStrategyIntent()`'s catch-up guard `if (State == State.Historical && Account != null)` (`DEC-20260818-08`) therefore treats every backtest bar as live catch-up replay. Result: `REJECT SUMMARY: reason=HistoricalReplayCatchup count=117` — 117 intents generated, 117 blocked, zero `SUBMIT`/`FILL`. Every Strategy Analyzer run since 2026-08-18 has taken zero trades. `DEC-20260818-08`'s premise ("`Account == null` during genuine `State.Historical` backtests") is **corrected** by this entry; its Action Required backtest check was never run. `NT8StrategyBaseHistoricalGuardTests` asserts the defective literal and so enshrines the bug.
|
||||
- **Finding — GAP-077 (HIGH):** the header reads `Account : Backtest`. Strategy Analyzer assigns a non-null `Backtest` account. `ProcessStrategyIntent()`'s catch-up guard `if (State == State.Historical && Account != null)` (`DEC-20260818-08`) therefore treats every backtest bar as live catch-up replay. Result: `REJECT SUMMARY: reason=HistoricalReplayCatchup count=117` — 117 intents generated, 117 blocked, zero `SUBMIT`/`FILL`. Every Strategy Analyzer run since 2026-08-18 has taken zero trades. `DEC-20260818-08`'s premise ("`Account == null` during genuine `State.Historical` backtests") is **corrected** by this entry; its Action Required backtest check was never run. At task opening, `NT8StrategyBaseHistoricalGuardTests` still asserted the defective literal; this task replaces that assertion with the predicate-aware guard.
|
||||
- **Same false assumption elsewhere:** `ShouldAllowDailyTradeCountIncrement()` returns `Account == null` in Historical → `MaxDailyTrades` never counts in a backtest (fixing only the guard would allow unlimited trades/day); daily-trade-count persistence and `TrailingDrawdownMonitor` registration key on `Account != null` and would bind an account named `Backtest`; the session header labels backtests `LIVE/SIM` (written from `DataLoaded`); `LogRejectRateLimited()` drops all non-Realtime reasons except `HistoricalReplayCatchup`, so a backtest cannot self-document; the GAP-060 snapshot heartbeat wrote 15,594 duplicate `REJECT SUMMARY` lines in one backtest.
|
||||
- **Decision:** single `IsBacktestRun()` predicate (`IsInStrategyAnalyzer || Account.Name == "Backtest"`), routed through all of the above; live/SIM behaviour unchanged. Commit-only; deploy once at the end of Stage 0, after the P0-A orphan sweep — otherwise the first working backtest would still execute the 2026-07-13 orphan strategy (GAP-065), which is **still present** in `bin\Custom\Strategies` as of 2026-10-24 (modified 2026-07-13, last accessed 2026-10-19).
|
||||
- **Decision:** single `IsBacktestRun()` predicate (`IsInStrategyAnalyzer || Account.Name == "Backtest"`), routed through the catch-up guard, daily-trade counting, session mode, daily persistence, and trailing-drawdown registration/checks. Backtest rejection detail is enabled and summary snapshots are capped at one per trading date; live/SIM replay guards remain. Commit-only; deploy once at the end of Stage 0 after P0-A.
|
||||
- **Related Files:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `tests/NT8.Core.Tests/Adapters/NT8StrategyBaseHistoricalGuardTests.cs`, `session_20261019_155354.log`, `DEC-20260818-08` (corrected), GAP-076.
|
||||
- **Action Required:** run the prompt; operator validation per its final section (backtest trades > 0 and ≤1/day; live late-enable still blocked).
|
||||
- **Implementation (2026-10-26):** `e2439c0adfedf22cfd21f3039b309703458042c4`; full verification 590/590 (500 Core, 80 Integration, 10 Performance), with 6 existing CS1998 warnings and zero errors. Required Core `--no-build` run passed 500/500.
|
||||
- **IsInStrategyAnalyzer documentation check:** official [NinjaTrader IsInStrategyAnalyzer](https://docs.ninjatrader.com/ninjascript/isinstategyanalyzer.md) defines true when the current strategy is run from a Strategy Analyzer chart; its example evaluates the property inside `OnBarUpdate`, confirming runtime strategy context rather than chart-display-only state. Local `NinjaTrader.Core.xml` and `NinjaTrader.Gui.xml` were present but contain no `IsInStrategyAnalyzer` member entry. The documented property was used as directed; the Oct 19 `Account : Backtest` evidence-backed fallback remains.
|
||||
- **Account occurrence verdicts in `NT8StrategyBase.cs`:** changed to exclude Analyzer/backtest account persistence/side effects: 595-599 (daily persistence activation), 960/974-975 (drawdown monitor), 1801-1804 and 1838-1842 (monitor registration/state), 1944 (persistence-enabled context), 2020-2021 (`IsBacktestRun` name fallback), and 2101 (halt query). Kept as real-time-only micro-upgrade state: 863, 873, 892-899, 928-942. Kept as non-persistent account data/diagnostics: 1368-1372, 1626, 1709, 1945, 2031-2034, 2414, 2806. Drawdown status/file diagnostics at 1006, 1015, 1851, 1914 remain reachable only through the now backtest-excluded monitor paths.
|
||||
- **State.Historical occurrence verdicts in `NT8StrategyBase.cs`:** line 640 comment kept (describes the Realtime-only replay-burst branch); line 1624 changed to `IsBacktestRun()` for the session mode; line 2009 branch kept but its return changed to `IsBacktestRun()` for daily trade counts; line 2082 changed to `State == State.Historical && !IsBacktestRun()` for catch-up blocking; line 2197 kept (historical orders bypass the live circuit breaker, while live-account historical intents are blocked earlier). `_realtimeBarSeen` initialization and Realtime eligibility guards remain unchanged.
|
||||
- **Action Required:** after the operator-controlled P0-A deploy/recompile, validate Strategy Analyzer trades > 0 and ≤1 per trading date with no `daily_trade_count_Backtest_*.json`; validate late-enable SIM still logs `HistoricalReplayCatchup` and submits no historical order. GAP-076 remains empirically pending this run.
|
||||
|
||||
### DEC-20261024-02
|
||||
- **ID:** DEC-20261024-02
|
||||
|
||||
Reference in New Issue
Block a user