[GAP-055]: MaxDailyTrades persistence complete
- SimpleORBStrategy.cs: persist and rehydrate daily trade count by trading date - NT8StrategyBase.cs: pass live account/log metadata for persistence - SimpleORBNT8.cs: seed persistence metadata in strategy config - MaxDailyTradesTests.cs: cover restore, reset, corrupt file, backtest no-I/O, CME date - docs/00-governance: record validation evidence and manual SIM follow-up Build: clean | Tests: 521 passing; Core 432 passing | Deploy: backup 20260823_143311
This commit is contained in:
@@ -60,7 +60,9 @@ Use this file to record durable project decisions that affect implementation pat
|
||||
- **Decision:** Persist `{trading_date, daily_trade_count, account, strategy_name, symbol}` to `{LogDirectory}/daily_trade_count_<AccountName>_<StrategyName>.json` on each increment, and rehydrate at `State.Realtime` entry when the persisted trading date matches. Reuse the persistence pattern already established for the Conservative trailing-drawdown halt file (DEC-20260818-17) rather than inventing a second mechanism. Align the trading-date boundary with the CME session rollover (18:00 ET) rather than the calendar date, using `SessionManager` or NT8's own session date if either already exposes it. Strategy Analyzer/backtest (`Account == null`) must neither read nor write the file so backtest behaviour is byte-for-byte unchanged.
|
||||
- **Consequences:** Gate discipline explicitly contemplates restarts (recompiles, workspace changes, connection recovery), so without this a gate run under `MaxDailyTrades=1` cannot guarantee its own cap and its sample is uninterpretable in the same way the previous two were. Adds a small file-I/O dependency to the realtime path; a missing or corrupt file must degrade to count-zero plus a WARNING, never an exception.
|
||||
- **Related Files:** `src/NT8.Strategies/Examples/SimpleORBStrategy.cs`, `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `TASK_GAP055_MAXDAILYTRADES_PERSIST_PROMPT.md`, `docs/00-governance/decisions.md`
|
||||
- **Action Required:** Accepted. Execute `TASK_GAP055_MAXDAILYTRADES_PERSIST_PROMPT.md`; then verify by taking one SIM trade, restarting the strategy the same trading day, and confirming the next signal is rejected with `REJECT: reason=MaxDailyTrades`.
|
||||
- **Implementation Note (2026-08-23):** Implemented as opt-in live/SIM persistence from the adapter into `SimpleORBStrategy`. `NT8StrategyBase` enables persistence only when `Account != null`, passes account/name/resolved log directory metadata at `State.Realtime`, and also includes the metadata on realtime contexts. `SimpleORBNT8` seeds the same metadata into the shared `StrategyConfig`. `SimpleORBStrategy` rehydrates once per trading date on the first realtime-eligible bar after session reset, restores when the file date matches, resets and overwrites when the date differs, writes after every daily-count increment, and logs either `DAILY_TRADE_COUNT restored: date=<yyyy-MM-dd> count=<n> max=<n>` or `DAILY_TRADE_COUNT reset: new trading date <yyyy-MM-dd>`. Missing/corrupt/unreadable files degrade to count zero plus `DAILY_TRADE_COUNT warning...` without throwing. Trading date follows the adapter/session date already used by `BuildSessionInfo()`/`MarketSession.SessionStart`, so 2026-08-16 19:12 ET and 2026-08-17 11:04 ET both resolve to trading date 2026-08-17. Backtest/Strategy Analyzer contexts with `Account == null` do not read or write state even if persistence parameters are present. The file key is exactly the approved `{AccountName}_{StrategyName}` path; `symbol` is recorded in the payload, but multiple same-account/same-strategy instances intentionally share the counter and distinct per-instance keys remain out of scope.
|
||||
- **Verification (2026-08-23):** Added tests for same-date restore, new-date reset/overwrite, corrupt-file warning/no throw, `Account == null` no-read/no-write behavior, and the 2026-08-16 19:12 / 2026-08-17 11:04 same-CME-date restart scenario. `verify-build.bat` passed 521/521 tests (432 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 432/432; `deployment\deploy-to-nt8.bat` completed with backup `20260823_143311` and noted `NinjaTrader.Custom.dll` was not present to invalidate.
|
||||
- **Action Required:** Manually compile in NinjaTrader, then validate in SIM by taking one trade, stopping/restarting the strategy on the same trading day, and confirming the next signal is rejected with `REJECT: reason=MaxDailyTrades`.
|
||||
|
||||
### DEC-20260818-20
|
||||
- **ID:** DEC-20260818-20
|
||||
|
||||
Reference in New Issue
Block a user