- governance: stage v7.0 review prompts, run book, roadmap/current-status/decision updates, and sprint board state - adapters: capture DASH/trailing-drawdown/state-telemetry strategy work already present in the worktree - tools: capture dashboard console/KPI parser updates, logtriage notes, and runnersweep output Build: previously clean | Tests: previously 511 passing | Includes all open staged files
94 lines
4.4 KiB
Markdown
94 lines
4.4 KiB
Markdown
# TASK: GAP-055 — MaxDailyTrades does not survive a strategy restart
|
|
# Staged: 2026-08-18 (v7.0 review, Finding 7)
|
|
# Sprint: Stage 0 — Unblock (P0-F)
|
|
# Owner: Kilocode
|
|
# ─────────────────────────────────────────────────────────────────
|
|
|
|
## THE DEFECT
|
|
|
|
`_dailyTradeCount` is a plain in-memory field in `SimpleORBStrategy.cs` (~39),
|
|
zeroed at construction (~269) and on session rollover (~756, ~961). Nothing
|
|
persists it. Any strategy stop/start resets the daily cap to zero.
|
|
|
|
GAP-032 fixed the WITHIN-session reset on position-flat. It did not address
|
|
restarts, and this is NOT closed by it.
|
|
|
|
## RUNTIME PROOF — the cap was breached on 2026-08-17
|
|
|
|
The CME trading date 2026-08-17 begins at 18:00 ET on Sunday 2026-08-16.
|
|
Two trades were taken on that date, with `MaxDailyTrades = 1`:
|
|
|
|
2026-08-16 19:12 session_20260816_181528.log +$277.72
|
|
2026-08-17 11:04 session_20260817_110049.log +$267.72
|
|
|
|
They ran in different NT8 sessions, so the counter started at zero for the
|
|
second. NT8 itself treated them as ONE trading day — the first PNL_UPDATE of
|
|
the 11:04 trade reads `DayPnL=$271.96` (= $277.72 less the $5.76 entry
|
|
commission) and the session closes at `DayPnL=$545.44`, the sum of both.
|
|
|
|
Same class as the 7/28 breach that helped void Gate Run #2 (HIST-45).
|
|
|
|
## WHY IT MATTERS NOW
|
|
|
|
Gate discipline explicitly contemplates restarts — recompiles, workspace
|
|
changes, connection recovery. A gate run under `MaxDailyTrades = 1` therefore
|
|
cannot currently guarantee its own cap, which makes the resulting sample
|
|
uninterpretable in exactly the way the previous two gate runs were.
|
|
|
|
## READ-FIRST
|
|
|
|
1. Read `SimpleORBStrategy.cs` around 39, 214, 269, 440-480, 660-680, 750-760, 955-965.
|
|
2. Read how `_currentSessionDate` is derived and where the trading-date boundary
|
|
is decided. Establish whether it uses the calendar date or NT8's session date.
|
|
3. Read how the trailing-drawdown monitor persists its Conservative halt file
|
|
(`{LogDirectory}/drawdown_halt_<AccountName>.json`, DEC-20260818-17) — reuse
|
|
that pattern rather than inventing a second persistence mechanism.
|
|
|
|
## THE CHANGE
|
|
|
|
1. Persist `{ trading_date, daily_trade_count, account, strategy_name, symbol }`
|
|
to `{LogDirectory}/daily_trade_count_<AccountName>_<StrategyName>.json` each
|
|
time the count increments.
|
|
2. On `State.Realtime` entry, rehydrate: if the persisted trading date matches
|
|
the current trading date, restore the count; otherwise start at zero and
|
|
overwrite the file.
|
|
3. Align the trading-date boundary with the CME session rollover (18:00 ET),
|
|
not the calendar date. If `SessionManager` or NT8's own session iterator
|
|
already exposes the session date, USE IT — do not hardcode 18:00.
|
|
4. Log the rehydration explicitly at session start:
|
|
`DAILY_TRADE_COUNT restored: date=<yyyy-MM-dd> count=<n> max=<n>`
|
|
or `DAILY_TRADE_COUNT reset: new trading date <yyyy-MM-dd>`.
|
|
|
|
MUST NOT change signal generation, grading, risk validation, sizing or order
|
|
submission. This is a counter-persistence change only.
|
|
|
|
## EDGE CASES TO HANDLE EXPLICITLY
|
|
|
|
- Missing, unreadable or corrupt file → start at zero, log a WARNING, do not throw.
|
|
- `LogDirectory` blank → use the same default-path fallback as session logs and
|
|
provenance (DEC-20260817-01). Do not silently skip.
|
|
- Strategy Analyzer / backtest (`Account == null`) → do NOT read or write the
|
|
file. Backtest behaviour must be byte-for-byte unchanged.
|
|
- Two strategy instances on the same account and symbol → out of scope here;
|
|
note the behaviour you implement and flag it, do not try to solve it.
|
|
|
|
## TESTS (required)
|
|
|
|
1. Same trading date + existing file → count restored.
|
|
2. New trading date + existing file → count reset to zero, file overwritten.
|
|
3. Corrupt file → count zero, warning logged, no exception.
|
|
4. Backtest path → no file read, no file write.
|
|
5. The 08-16 19:12 / 08-17 11:04 scenario specifically: two sessions spanning
|
|
an 18:00 ET boundary on the same CME date resolve to ONE trading date.
|
|
|
|
## VALIDATION (operator)
|
|
|
|
Start the strategy, take one SIM trade, stop the strategy, restart it the same
|
|
trading day, and confirm the next signal is rejected with
|
|
`REJECT: reason=MaxDailyTrades`.
|
|
|
|
## GOVERNANCE
|
|
|
|
Track as [GAP-055] in SPRINT_BOARD.md. Add a decisions.md entry.
|
|
Reference: NT8_SDK_Master_Document_v7.0 Finding 7, Section 9.3 (P0-F).
|