From 885e298fb78519c235395cd22e8782171daf01a5 Mon Sep 17 00:00:00 2001 From: mo Date: Wed, 26 Aug 2026 00:53:32 -0400 Subject: [PATCH] [GAP-062]: trend confirm direction fix complete - src/NT8.Strategies/Examples/SimpleORBStrategy.cs: publish side-specific trend confirmation values - src/NT8.Core/Intelligence/FactorCalculators.cs: score trend confirmation by intent side - tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs: add long/short symmetry coverage - SPRINT_BOARD.md: GAP-062 prompted -> implemented - docs/00-governance/current_status.md: updated GAP-062 status - docs/00-governance/decisions.md: recorded DEC-20260826-01 - TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md: committed task prompt Build: clean | Tests: 569 passing | Dual-deployed: yes, backup 20260826_005308 --- SPRINT_BOARD.md | 22 ++- TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md | 179 ++++++++++++++++++ docs/00-governance/current_status.md | 94 ++++++++- docs/00-governance/decisions.md | 117 +++++++++--- .../Intelligence/FactorCalculators.cs | 5 +- .../Examples/SimpleORBStrategy.cs | 27 ++- .../Intelligence/OrbConfluenceFactorTests.cs | 63 +++++- 7 files changed, 468 insertions(+), 39 deletions(-) create mode 100644 TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md diff --git a/SPRINT_BOARD.md b/SPRINT_BOARD.md index 115ea0b..3cbb851 100644 --- a/SPRINT_BOARD.md +++ b/SPRINT_BOARD.md @@ -1,5 +1,5 @@ # NT8 SDK — Sprint Board -**Last Updated:** 2026-08-18 (v7.0 review — six new tasks staged) +**Last Updated:** 2026-08-26 (GAP-062 implemented — trend_confirm direction fix; deploy skipped by prompt) **Truth source:** compiler output, test output, deployed-file comparisons, and runtime artifacts override board claims. ## Current gate state @@ -80,6 +80,10 @@ - `BasicRiskManager.GetTickValue` (6 symbols) and `BasicPositionSizer.GetTickValue` (8 symbols) disagreed: `BasicPositionSizer` supported `6E`/`6A`, while `BasicRiskManager` fell through to its `default: 12.50`. For `6A`, the real tick value is `$10.00`, creating a latent 25% risk-calculation error if traded. NQ/MNQ were unaffected and remain unchanged. - Prompt: `TASK_GAP052_TICK_VALUE_CONSOLIDATION_PROMPT.md`. Implemented Option A: shared platform-neutral `InstrumentTickValueTable` containing the union of existing symbols (`ES`, `MES`, `NQ`, `MNQ`, `CL`, `GC`, `6E`, `6A`). Basic and Advanced risk/sizing helpers now delegate to the shared table, and `6A` risk validation uses `$10.00` instead of falling through to `$12.50`. Verification: focused tests 26/26, `verify-build.bat` 552/552, Core Release no-build 463/463. Deployment skipped per operator instruction. +**[GAP-053] `executive_summary.md`/`roadmap.md` present ~12 completed tasks as open** | Stage 1 | ✅ READY +- `roadmap.md` already contains its own `STALE-LIST WARNING (GAP-053, added 2026-08-18)` naming TASK-06a, TASK-06b, GAP-003/004/005/006/008/009/010/019/022 as stale (all completed 2026-07-11/07-14), plus GAP-011/GAP-040 also resolved but left dangling. `executive_summary.md` (dated 2026-05-04, still references the retired v6 master doc) separately lists four of the same already-completed items as "Critical Open Issues." Documentation-only, zero trading-behaviour risk. +- Prompt: `TASK_GAP053_STALE_DOCS_PRUNE_PROMPT.md`. + **[GAP-056] `EnableAutoBreakeven`/`BreakevenTriggerTicks`/`BreakevenOffsetTicks` are fully inert** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt - Found during GAP-054 verification (`DEC-20260821-01`): GAP-054 removed the only code path that ever read these three parameters (the runner breakeven block that was clobbering the trailing stop). They remain declared, defaulted, and exposed in the NinjaTrader UI but do nothing — harmless, but an operator toggling `EnableAutoBreakeven` would reasonably expect an effect. - Prompt: `TASK_GAP056_INERT_BREAKEVEN_PARAMS_PROMPT.md`. Implemented Option A: retained the properties for saved workspace/settings compatibility, hid all three from the NT8 property grid with `[Browsable(false)]`, and labeled the SimpleORB settings export as `UNUSED`. No order-flow, sizing, risk, `SetStopLoss`, or `SetTrailStop` logic changed. Verification: focused tests 3/3, `verify-build.bat` 555/555, Core Release no-build 466/466. Deploy intentionally skipped by task prompt. @@ -90,15 +94,21 @@ **[GAP-050] MaxTradeRisk quantity term missing from IRiskManager contract** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt - Originally flagged as a live risk-math gap ("$600 vs $1,000 daily limit"). Investigation on 2026-08-25 found the live path is already safe: `SimpleORBNT8`/`NT8StrategyBase` constructs `BasicRiskManager` directly and reaches its quantity-aware 4-arg `ValidateOrder` overload via a runtime type-check. The real gap is that `IRiskManager` itself never declared a quantity-aware member — `AdvancedRiskManager` (unwired to anything live) and `NT8OrderAdapter` (unwired scaffolding, also validates before sizing) would silently reintroduce the 1-contract assumption if either is ever wired up. +- Operator decision 2026-08-25: **Option A** — add the 4-arg `ValidateOrder` to the `IRiskManager` interface itself, implement it on `AdvancedRiskManager`, remove the `as BasicRiskManager` type-check workaround in `NT8StrategyBase.cs`, and fix `NT8OrderAdapter`'s validate-before-size ordering. No live-behaviour change; live path stays byte-identical. - Prompt: `TASK_GAP050_ADVANCED_RISK_QTY_PROMPT.md`. Implemented Option A: `IRiskManager` now declares the quantity-aware 4-arg `ValidateOrder`; `AdvancedRiskManager` delegates Tier 1 through the quantity-aware `BasicRiskManager` overload while retaining 3-arg one-contract behavior; `NT8StrategyBase` uses the interface directly instead of an `as BasicRiskManager` type-check; `NT8OrderAdapter` sizes first, rejects zero-size, then validates risk with the sized contract count. Verification: focused Core 10/10, focused Integration 13/13, `verify-build.bat` 566/566, Core Release no-build 476/476. Deploy intentionally skipped by task prompt. **[GAP-061] Expose raw AVWAP/slope/trend-confirm inputs in STATE_CONTEXT telemetry** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt -- Found during the "zero trades this week" investigation (`DEC-20260825-04`): every real breakout this week and on 2026-08-18 capped at Grade B/C, driven by `Trend=0.30` on every best short setup. Source read confirmed the sharper asymmetry: `trend_confirm` is `avwapSlope > 0.0 ? 1.0 : 0.0`, while short-side slope alignment requires `avwapSlope < 0.0`, so a short cannot earn both bonuses. +- Found during the "zero trades this week" investigation (`DEC-20260825-04`): every real breakout this week and on 2026-08-18 capped at Grade B/C, driven by `Trend=0.30` on every best short setup. Traced to a provable-from-source asymmetry — `trend_confirm` (`SimpleORBStrategy.cs:970`) is set to `avwapSlope > 0.0 ? 1.0 : 0.0`, unconditionally rewarding a *positive* slope regardless of trade direction. For a short trade, this is mutually exclusive with the correctly-aligned (negative-slope) bonus — a short can never earn both, even with a cleanly confirmed downtrend. +- Scoped observability-only: exposes `Avwap`/`AvwapSlope`/`TrendConfirm` raw values in `STATE_CONTEXT` (same class as GAP-059) so the remaining open question (whether early ORB-timing structurally blocks the price-vs-AVWAP bonus too) can be checked against real numbers. Does not fix `trend_confirm`'s asymmetry — that's a separate, not-yet-decided follow-up. - Prompt: `TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md`. Implemented as observability-only: `STATE_CONTEXT` now includes `Avwap` (`F2`), `AvwapSlope` (`F4`), and `TrendConfirm` (`F1`) when those existing `context.CustomData` keys are present. Missing keys are omitted with no placeholders. No scoring, `trend_confirm`, `STATE:`, `STATE_DETAIL:`, risk, sizing, or order-flow logic changed. Verification: focused tests 7/7, `verify-build.bat` 561/561, Core Release no-build 472/472. Deploy intentionally skipped by task prompt. -### Also raised by the review, not yet prompted -GAP-051 (`MicroUpgradeThreshold` fires every session) · GAP-052 (two hardcoded tick-value tables) · -GAP-053 (`executive_summary.md` and `roadmap.md` Sprint 3 list present ~12 completed tasks as open) · -plus the standing dirty working tree — 17 modified, 5 untracked, including two live strategy files. + +**[GAP-062] `trend_confirm` is direction-blind, capping every short's Trend factor** | Stage 1 | ✅ IMPLEMENTED — deploy skipped by prompt +- Found while drafting GAP-061 (`DEC-20260825-04` addendum), independently re-confirmed by Kilocode's own GAP-061 commit writeback: `trend_confirm` (`SimpleORBStrategy.cs:970`) is `avwapSlope > 0.0 ? 1.0 : 0.0` — unconditionally rewards a positive slope regardless of trade direction. For a short, this is mutually exclusive with the correctly-aligned (negative-slope) `+0.3` bonus, capping every short's Trend score at 0.30 (or 0.70 with price below AVWAP) even with a cleanly confirmed downtrend. Matches real data exactly: every best real short setup this week and on 2026-08-18 scored `Trend=0.30`. With `MinTradeGrade=A`, this has silently vetoed every well-formed short setup. +- **Unlike GAP-050/GAP-061, this is a real scoring-behaviour change, not behaviour-neutral** — fixing it can newly qualify short setups that were previously capped below Grade A. Task requires symmetric before/after test proof (long-side unchanged, short-side now earns the same max score a symmetric long would) and explicit SIM before/after observation, not "none required." +- Prompt: `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md`. Implemented by publishing side-specific `trend_confirm_long`/`trend_confirm_short` inputs from `SimpleORBStrategy.UpdateConfluenceInputs()` and having `TrendAlignmentFactorCalculator` select the value matching `intent.Side`, leaving the `+0.4`/`+0.3`/`+0.3` additive score structure unchanged. Tests prove a short in a confirmed downtrend now reaches the same max Trend score as a symmetric long, a short against an uptrend does not earn trend confirmation, and long confirmed-uptrend behavior remains fully confirmed. Verification: focused Intelligence tests 89/89, `verify-build.bat` 569/569. Deploy intentionally skipped by task prompt; SIM before/after observation required because this is a scoring-behavior change. + +### Standing item +The dirty working tree — several modified/untracked files including live strategy files — is still unresolved; recommend operator check `git status` directly on the machine. --- diff --git a/TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md b/TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md new file mode 100644 index 0000000..3d23420 --- /dev/null +++ b/TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md @@ -0,0 +1,179 @@ +# TASK: GAP-062 — trend_confirm is direction-blind, capping every short's Trend factor +# Staged: 2026-08-26 (trade-frequency investigation, DEC-20260825-04; confirmed provable- +# from-source in GAP-061's own commit writeback) +# Sprint: Stage 1 — real scoring-behaviour change (see VALIDATION — this is NOT +# behaviour-neutral, unlike GAP-050/GAP-061) +# Owner: Kilocode +# Deploy: COMMIT ONLY — do NOT run deploy-to-nt8.bat or copy build output to +# the live NT8 install as part of this task. Verify-build and commit +# as usual; leave the deploy step for the operator to run manually +# once ready. +# ───────────────────────────────────────────────────────────────── + +## THE DEFECT + +`TrendAlignmentFactorCalculator.Calculate()` +(`src/NT8.Core/Intelligence/FactorCalculators.cs` ~116-186) scores the Trend +confluence factor additively out of three components: + +- `+0.4` if price is on the trade's side of AVWAP. +- `+0.3` if `avwapSlope`'s sign agrees with the trade direction + (`slopeAligned`). +- `+0.3` if `trend_confirm > 0.5`. + +`trend_confirm` is computed once per bar in +`SimpleORBStrategy.UpdateConfluenceInputs()` +(`src/NT8.Strategies/Examples/SimpleORBStrategy.cs:970`): + +``` +context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0; +``` + +This is **direction-blind** — it unconditionally rewards a *positive* slope, +regardless of which way the candidate trade is going. For a Sell/short +trade, `slopeAligned` requires `avwapSlope < 0.0`. These two conditions +(`avwapSlope < 0` for `slopeAligned`, `avwapSlope > 0` for `trend_confirm`) +are mutually exclusive by construction: **a short trade can never earn both +the `+0.3` slope-aligned bonus and the `+0.3` trend-confirm bonus, even when +the trend is cleanly and correctly bearish.** The maximum Trend score a +short with a genuinely confirmed downtrend can reach is `0.3` (or `0.7` if +price is also below AVWAP) — structurally capped below what a long in an +equally clean uptrend can reach (`1.0`). + +This is not a hypothesis. It was first identified while drafting GAP-061 +(`DEC-20260825-04` addendum), then independently re-confirmed by Kilocode's +own commit writeback for GAP-061 (`DEC-20260825-04`/`DEC-20260825-05`) after +a fresh read of the same source. It also matches real log data exactly: +every best real short setup on both 2026-08-18 and this week scored +`Trend=0.30` — never higher, regardless of how clean the actual downtrend +looked. With `MinTradeGrade=A`, this has been silently vetoing every +well-formed short setup this system produces. + +## READ-FIRST + +1. `DEC-20260825-04` in `docs/00-governance/decisions.md` — full + investigation trail, including the addendum where this was first found + and the addendum from GAP-061's own commit re-confirming it. +2. `DEC-20260825-05` — Claude's verification of the GAP-061 commit, + including the note that Kilocode's own re-read independently confirmed + this finding before implementing GAP-061's telemetry-only scope. +3. `src/NT8.Core/Intelligence/FactorCalculators.cs` ~116-186 — + `TrendAlignmentFactorCalculator.Calculate()`. Confirm the additive logic + and the `slopeAligned`/`trend_confirm` mutual exclusivity for shorts is + still accurate before changing anything. +4. `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` ~926-975 — + `UpdateConfluenceInputs()`, where `trend_confirm` is computed and written + to `context.CustomData` every bar. Confirm what direction information is + already available at this point (the candidate trade side, if any, or + whatever proxy for "which way are we about to trade" this method has + access to — read the surrounding lines to confirm exactly what's in + scope here before designing the fix). +5. `src/NT8.Adapters/Strategies/SimpleORBNT8.cs` ~356-370 (post-GAP-061) — + `GetStateTelemetryContextFields()` now surfaces `Avwap`/`AvwapSlope`/ + `TrendConfirm` raw values in `STATE_CONTEXT`. If deployed and observed + before this task starts, real `AvwapSlope` values from live/SIM + `STATE_CONTEXT:` lines are additional evidence worth checking against — + note in your writeback whether any such log data was available and what + it showed, but do not block on it; the source-level proof above stands + on its own. +6. `tests/NT8.Core.Tests/Intelligence/` — existing tests for + `TrendAlignmentFactorCalculator` (find by class name), to understand the + current expected-score fixtures you'll need to update. + +## THE CHANGE + +Make `trend_confirm` direction-aware: it should reward genuine trend +confirmation *in the direction of the candidate trade*, not merely "slope is +positive." + +The exact mechanism is your call, but it must satisfy all of the following: + +1. **Symmetry**: a long in a confirmed uptrend and a short in a confirmed + downtrend must be able to earn the same maximum Trend score (i.e. + `trend_confirm > 0.5` must be achievable for both directions when the + underlying trend genuinely supports that direction). +2. **No new inputs invented**: use `avwapSlope` (already computed) and + whatever direction signal `UpdateConfluenceInputs()` already has access + to (read THE READ-FIRST #4 first — do not thread new parameters through + the call chain if the direction is already derivable at that point; if it + genuinely isn't available yet at `UpdateConfluenceInputs()` time, explain + why in your writeback and propose the minimal way to get it there). +3. **Do not change the additive structure or weights** of + `TrendAlignmentFactorCalculator.Calculate()` (`+0.4`/`+0.3`/`+0.3`) — + only fix what `trend_confirm` measures. This task is about correcting + the input, not redesigning the scoring formula. +4. **Do not weaken long-side behavior.** A long trade's existing + `trend_confirm` value for a positive-slope uptrend must remain `1.0` + after this change (verify this explicitly in your tests) — the fix + should only correct the short-side blind spot, not change long scoring. + +A reasonable shape (illustrative, not prescriptive — use your own judgment +after reading the surrounding code): instead of a single unconditional +`avwapSlope > 0.0 ? 1.0 : 0.0`, compute `trend_confirm` per-side (e.g. by +storing both a long-confirm and short-confirm value, or by deferring the +comparison until the candidate trade's side is known at scoring time) so +that `TrendAlignmentFactorCalculator` reads the correct one for the +direction actually being evaluated. + +## DO NOT + +- Do not change the `+0.4`/`+0.3`/`+0.3` weights or the additive structure + in `TrendAlignmentFactorCalculator.Calculate()`. +- Do not change how the `+0.4` price-vs-AVWAP or `+0.3` `slopeAligned` + components are computed — only `trend_confirm`. +- Do not change `MinTradeGrade`, `GradeFilter`, `ConfluenceScorer`'s other + 9 factor calculators, or any risk/order-flow/sizing code. +- Do not change the `STATE:`/`STATE_DETAIL:`/`STATE_CONTEXT:` log line + formats (GAP-061's telemetry fields already surface `TrendConfirm` — this + task changes what value gets computed, not how it's logged). +- Do not touch `RegimeVeto`, the AVWAP hard veto for longs, or + `EnableShortTrendFilter` — separate mechanisms, out of scope. + +## TESTS (required) + +1. A test proving a short candidate trade in a confirmed downtrend + (`avwapSlope < 0`, direction-consistent) now earns `trend_confirm > 0.5` + and reaches the same maximum Trend score a symmetric long would reach in + a confirmed uptrend. +2. A test proving a short candidate trade against the trend + (`avwapSlope > 0`, i.e. price trending up while evaluating a short) + correctly does NOT earn `trend_confirm > 0.5` — the fix must not become + directionless in the other direction (always-true would be as wrong as + the current always-check-positive-slope bug). +3. A test proving long-side behavior is byte-identical to before this + change: a long in a confirmed uptrend still scores `trend_confirm = 1.0` + as it did previously. +4. Update (do not just add alongside) any existing + `TrendAlignmentFactorCalculator`/`UpdateConfluenceInputs` test fixtures + whose expected values assumed the old direction-blind formula — find + them via the existing test files identified in READ-FIRST #6. +5. Confirm the full existing suite still passes. + +## VALIDATION (operator) + +**Unlike GAP-050/GAP-061, this IS a real trading-behaviour change** — it +will change actual trade eligibility. Previously B/C-Grade-capped short +setups can now legitimately reach Grade A (and pass `MinTradeGrade`), which +means this fix can cause the strategy to start taking short trades it +previously silently rejected. Before deploying to SIM: + +1. Confirm the build/tests pass per above. +2. Do NOT deploy automatically — the operator will manually build, deploy, + and run this on SIM to observe: does at least one short setup that was + previously capped at Grade B/C now score Grade A on a comparable + confirmed-downtrend setup? Does long-side Grade distribution look + unchanged versus before? +3. Flag explicitly in your writeback that this is a scoring-behavior change + requiring SIM observation before/after, not a "none required" item like + the last two tasks. + +## GOVERNANCE + +Track as [GAP-062] in SPRINT_BOARD.md. Update +`docs/00-governance/decisions.md` with a new dated entry (next available +number after `DEC-20260825-05`) recording the implementation and explicitly +restating the symmetry proof from TESTS #1-#3 above so the operator has a +clean, test-verified basis for trusting the fix before running it live. +Reference: this task, `DEC-20260825-04`, `DEC-20260825-05`, +`TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md` (the investigation this follows +from). diff --git a/docs/00-governance/current_status.md b/docs/00-governance/current_status.md index 741cce2..9d9fd85 100644 --- a/docs/00-governance/current_status.md +++ b/docs/00-governance/current_status.md @@ -1,5 +1,97 @@ # Current Status — NT8 SDK -**Last Updated:** 2026-08-23 (GAP-045/046 risk guards implemented and deployed) +**Last Updated:** 2026-08-26 (GAP-062 implemented; deploy skipped pending SIM before/after observation) + +--- + +## 2026-08-26 — GAP-062 implemented; scoring behavior changed, deploy skipped + +Kilocode implemented `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md` as a real confluence-scoring fix. `SimpleORBStrategy.UpdateConfluenceInputs()` now publishes side-specific `trend_confirm_long` and `trend_confirm_short` values from the existing AVWAP slope, and `TrendAlignmentFactorCalculator` selects the value matching `intent.Side` while preserving the existing `+0.4` price-vs-AVWAP, `+0.3` slope-aligned, and `+0.3` trend-confirm additive structure. The legacy `TrendConfirm` telemetry field remains the same log key, but its backing value is now resolved against the pending/current breakout direction where available. + +Verification passed: focused Intelligence tests 89/89 and `verify-build.bat` 569/569. No `TrendConfirm`/`AvwapSlope` lines were present in the current NT8 session log directory, so there was no deployed GAP-061 telemetry evidence to compare before this source fix. Deploy was intentionally skipped per the task header. This is not behavior-neutral: short setups that were previously capped below Grade A can now qualify, so SIM before/after observation is required before trusting the change live. + +--- + +## 2026-08-25 — GAP-060/059/051/052 verified via diff review; deploy pending + +Kilocode reported all four complete (`6c672a5`/`7e82b2c`/`18877c3`/`8b9a2e2`). Read every diff directly rather than trusting the summaries. All four confirmed correct and matching their task prompts: GAP-060's snapshot suppression is now a proper date-aware window (not the old blanket midnight-10am gate), the once-after-ORB flag resets per trading day, and a heartbeat call makes the flush independent of a reject occurring — a real execution test proves `OrbRangeNotEstablished` was always being recorded correctly (the visibility gap was purely in the reporting layer). GAP-059 correctly sources ORB high/low from the live SDK tracker and removes the dead fields, verified with a real factor-calculator test using tonight's actual logged range. GAP-051 implements Option A (persisted advisory, safe fallback on corrupt/missing file). GAP-052 implements Option A and, as a legitimate bonus, found and consolidated two *additional* undocumented tick-value tables in `AdvancedRiskManager`/`AdvancedPositionSizer` that had the same drift risk — not something the original task asked for, but the right call. + +One process note, not a code defect: for GAP-060/GAP-059, `deploy-to-nt8.bat` was actually run and only failed because a running `NinjaTrader.exe` held a lock on `NT8.Core.dll` — the "commit only, do not deploy" instruction added to those two task files didn't reach Kilocode (it committed an older cached copy of the files without that line). GAP-051/052 correctly skipped deploy, per a direct operator instruction given mid-run rather than from the file text. Net effect tonight was harmless, but worth knowing the instruction didn't do its job on its own. Full detail in `decisions.md` DEC-20260825-01, including a separate note about uncommitted working-tree drift and a `.git/index.lock` warning surfaced during verification — not investigated further, worth an operator check before the next Kilocode run. + +--- + +## 2026-08-24 — Suspected missed 10:49 ET A-grade setup investigated: not a missed trade + +Mo flagged a likely-missed A setup just after 10:00 ET. Found two real `Grade=A` `STATE:` prints at `10:49:59` (Score=0.838) and `10:54:59` (Score=0.804), both `Direction=Buy DirectionSource=OpeningRangeMidpoint`. Confirmed this is the same synthetic-telemetry pattern as the earlier 09:30-10:00 finding, one tier further along: `OpeningRangeMidpoint` means the side was chosen purely by which half of the ORB range price sat in, not a confirmed breakout — `sdkOrb.PendingBreakoutDirection` was `0` at that moment. A genuinely actionable setup shows `DirectionSource=PendingBreakout` instead, and that value does appear correctly elsewhere in the same multi-day log on a later trading day, confirming the field works as designed. Zero `[SDK] Intent generated` prints anywhere in the entire session corroborates no real signal ever fired. Full evidence in `decisions.md` DEC-20260824-01. Recommended (not yet a task) a clarity improvement: flag Grade as informational-only in the dashboard/log whenever `DirectionSource != PendingBreakout`, so a high score doesn't read as a real signal at a glance. + +Also: staged `TASK_GAP060/059/051/052` prompts now explicitly instruct Kilocode to commit and verify-build only — no `deploy-to-nt8.bat` — while `Sim101` stays live under investigation. Deploy is a manual operator step once ready. + +--- + +## 2026-08-24 — No-trade RTH day reviewed: 09:30-10:00 telemetry explained, new REJECT-visibility defect found (GAP-060) + +Mo reported no trades taken, price never broke out, and asked about several Grade-A `STATE:` prints seen between 09:30-10:00 ET that appeared to reject because "it wasn't 10AM yet." Reviewed `session_20260823_230519.log` (continuous session, 2026-08-23 23:05 ET → 2026-08-24 20:20+ ET) directly. + +**Not a defect — confirmed by-design:** `SimpleORBStrategy.OnBar()` correctly and unconditionally rejects with `OrbRangeNotEstablished` for any bar before the ORB window (09:30-10:00 ET) closes — an ORB strategy cannot evaluate a breakout of a range that hasn't finished forming. The Grade-A `STATE:` lines Mo saw in that window are a separate, always-on diagnostic telemetry stream that scores a hypothetical default-long intent (`DirectionSource=DefaultLong`) for dashboard purposes only — confirmed via `STATE_CONTEXT` omitting `OrbHigh`/`OrbLow`/`OrbReady` entirely before 10:00 ET, appearing only from `10:04:59` on. Nothing tradeable was missed. + +**New finding, GAP-060:** While confirming the above, found the file log has a ~16-hour `REJECT SUMMARY` blackout — `23:55:01` (Aug 23 night) to `16:00:00` (Aug 24 afternoon) — covering the entire trading day Mo was asking about. Root cause traced to `MaybeWriteRejectSummarySnapshot`'s time-of-day gate (blocks the whole midnight-10am span daily, not just the ORB window), a session-lifetime (not per-day) "already written" flag that fires once on a multi-day run and never again, and a snapshot mechanism that's only ever triggered as a side effect of some other reject — no independent timer. Left open whether `OrbRangeNotEstablished` itself is being counted at all during this window (the one snapshot we do have, at 16:00, shows zero for that reason despite a full no-breakout day) — flagged for Kilocode to determine via a live/test trace rather than assumed. Full evidence in `decisions.md` DEC-20260823-08; task prompt staged as `TASK_GAP060_REJECT_SUMMARY_VISIBILITY_PROMPT.md`. Recommended ahead of GAP-059/051/052 in priority — this blocks diagnosing any future no-trade day from the file log alone. + +--- + +## 2026-08-23/24 — Live SIM results: two fixes confirmed live, one new telemetry-only defect found + +Continuing the same `Sim101` SIM session from DEC-20260823-04 through the market open and ORB window. Findings from reading the live `STATE:`/`STATE_DETAIL` lines directly: + +**Confirmed correct, live, in production (not just unit tests):** +- GAP-047 Part 2 — every `STATE:` line's factor weights read the designed values (`...x0.20`/`x0.15`/`x0.15`/`x0.20`/`x0.15`) exactly. +- GAP-049's direction fix — `GapDirectionAlignment` correctly reads "aligns with trade" for a down gap on a Sell setup, and "opposes trade" for a down gap on a Buy setup. Both directions confirmed correct in live output. + +**New finding, GAP-059:** `OrbRangeVsAtr` still reads "No daily bar context available" on every `STATE_DETAIL` line from 08:29 ET through at least 10:49 ET, despite `STATE_CONTEXT` confirming `OrbReady=True` with a real, formed opening range (`OrbHigh=29243.00 OrbLow=28946.75`). Traced to source: `SimpleORBNT8.OnBarUpdate()` computes the ORB range from `_openingRangeHigh`/`_openingRangeLow`, two fields that are declared and read but never assigned anywhere in the file — a pre-existing dead-field bug, not something GAP-049 introduced. The correct live values already exist in the same file (`sdkOrb.OpeningRangeHigh`/`OpeningRangeLow`, the same fields that correctly populate `STATE_CONTEXT`'s own `OrbHigh`/`OrbLow`). Confirmed telemetry-only — `_strategyConfig.Parameters["daily_bars"]` is read in exactly one place in the file (the telemetry builder), so real trade-signal scoring is unaffected. Full evidence and recommended fix in `decisions.md` DEC-20260823-05; task prompt staged as `TASK_GAP059_ORB_RANGE_TELEMETRY_PROMPT.md`. + +No SIGNAL/SUBMIT/FILL activity yet as of 10:49 ET — price has not broken the ORB range. GAP-045/046's sizing/risk behavior, GAP-048's reject taxonomy, and GAP-055's restart persistence all still await a real signal to validate. + +--- + +## 2026-08-23, late — Post-compile SIM validation: SDK init failure hit and resolved + +Operator compiled NinjaScript (picking up GAP-054/045-046/048/055/049 in one pass) and started the strategy on `Sim101`. First start silently failed: session-start diagnostics looked normal (they print unconditionally regardless of SDK health), but every bar rejected with `WarmupIncomplete detail=SdkInitialized=False StrategyNull=True`. Diagnosed via the exported settings + `RiskEnvelopeValidator.ValidateStartupConfiguration()` source: NQ's pre-existing `MaxStopTicks=50` (code default, not overridden) × `$5.00` tick value = `$250.00`, exceeding the configured `MaxTradeRisk=$200.00` — the original GAP-045 collision, now enforced as a hard startup throw rather than a per-trade rejection. This means the current NQ configuration cannot start the strategy at all until the pair is reconciled — a stronger consequence than the original GAP-045/046 review anticipated, since DEC-20260818-19/DEC-20260819-01 deferred the actual fix to a later MNQ cutover. + +Operator raised `MaxTradeRisk` to `$250.00` on `Sim101` only (SIM-only, interim bridge; does not touch the frozen gate account or reverse the MNQ-cutover plan). Restarted; confirmed SDK initialized successfully this time via the session header's `Risk: ... MaxTradeRisk=$250 ...` line, no further `SdkInitialized=False` rejects, and a clean run through NT8's historical catch-up replay burst (78 bars correctly discarded by the pre-existing replay-burst guard) to `[REALTIME ELIGIBILITY]`. Full detail in `decisions.md` DEC-20260823-04, including an incidental but genuine real-world confirmation that GAP-045/046's Assertion B works correctly both when violated and when reconciled. + +One real observability gap surfaced by this: SDK-initialization failures only reach NT8's Output/Log window, never the persistent session file — so a normal-looking startup in the file log is not proof the strategy is actually running. Worth a future low-priority task to route init-failure messages through `FileLog` too. + +Strategy is now at `[REALTIME ELIGIBILITY]` on `Sim101` with the corrected config. Group A validation (GAP-045/046 sizing/risk behavior, GAP-048 REJECT SUMMARY taxonomy, GAP-055 restart persistence, GAP-049 STATE_DETAIL gap alignment) has not yet been observed — in progress. + +--- + +## 2026-08-23 — GAP-049 IMPLEMENTED, manual NT8/live SIM STATE_DETAIL spot-check pending + +Kilocode executed `TASK_GAP049_TELEMETRY_DIRECTION_PROMPT.md` (commit `a005dee`). `SimpleORBNT8.BuildStateTelemetryIntent()` now clones `DailyBarContext` rather than attaching the shared object directly, sets clone-only `TradeDirection`/`BreakoutBarVolume`/`TodayOpen`/`AvgIntradayBarVolume` from the telemetry intent's own side plus the existing stable `session_open_price`/`avg_volume` context fields, and adds `orb_range_ticks` metadata. No `SIGNAL`/`SUBMIT`/`FILL`/`PNL_UPDATE`/`REJECT`/sizing/risk/order-submission path touched. + +Independent verification: read the full `SimpleORBNT8.cs` diff directly. Confirmed `DailyBarContext` is a `struct` (`FactorCalculators.cs` ~408) whose only fields this fix reassigns are scalars — the array fields (`Highs`/`Lows`/`Closes`/`Opens`/`Volumes`) are read but never mutated, so the value-type copy `daily = source` is a genuinely safe clone that satisfies DEC-20260818-06's no-shared-mutation constraint. Confirmed `session_open_price`/`avg_volume` are pre-existing fields already populated once per session by the real trade path (`SimpleORBStrategy.cs`), not new/fabricated inputs. + +P1-E gap-magnitude finding also verified as sound on its own internal evidence, independent of the external NQ price citation: the same session log reported the "-523.25" figure as different values throughout one RTH session (per `decisions.md` DEC-20260823-03, roughly -389.75 to -555.75), which by itself proves the old code was reading a drifting current-bar value rather than a fixed overnight open. + +Test coverage: `OrbConfluenceFactorTests.cs`'s new `GapDirection_LargeDownGapForSell_ScoresOneAndAligns` is a real execution test against the exact cited 30096.00/30077.00 values, confirmed to call the actual `GapDirectionAlignmentCalculator` and assert Score=1.0 / "aligns with trade." `SimpleORBNT8DefaultsTests.cs`'s two new tests are source-text assertions (grep the compiled method body), not execution tests — consistent with that file's pre-existing pattern for this NinjaScript-derived adapter class, which cannot be instantiated outside NT8; not a new GAP-058-style tautology, just the weaker coverage tier this codebase already uses where no execution seam exists. + +No errors found. `active_work.md` row 7 and the run book's Play 9 were stale (still read "READY") — updated to reflect implementation. + +--- + +## 2026-08-23 — Independent verification of all four Kilocode reports complete + +Read every diff directly (not just Kilocode's summary) for `80c5f53` (GAP-047 Part 2), `e36534b` (GAP-048), `6658d2d` (GAP-055), and `d652e29` (GAP-045/046), plus the new/changed test files and the governance-doc updates each commit carried. All four are code-complete, correctly scoped to their `TASK_*.md` prompts, and no functional defect was found. + +One minor finding: `SimpleORBRejectionLoggingTests.cs`'s third new test (`RejectLineFormat_DiffersOnlyByReasonToken`) is tautological — it never calls production code, only compares two hand-written literal strings. Logged as **GAP-058** (`decisions.md` DEC-20260823-02), tracking-only, does not block anything; the other two new tests in that file are sound and do exercise real code. + +**Update, same day:** GAP-058 fixed and committed (`f45adca`). Verified the diff directly — the test now invokes `SimpleORBStrategy.RecordSignalRejection` twice (once with `GradeFilter`, once with `RegimeVeto`) through the existing reflection helper and compares the two real emitted lines, rather than two hand-typed literals. `DEC-20260823-02` correctly flipped to `implemented` with an accurate implementation note. No production code touched. Test count unchanged at 535/535 (a replacement, not an addition), consistent with the report. + +All four implementations still carry a manual-validation step Kilocode itself flagged honestly, none of which has happened yet: +- GAP-047 Part 2 — none required; fully proven in `NT8.Core` unit tests, no NinjaTrader dependency. +- GAP-048 — one live/SIM diagnostic session confirming `REJECT SUMMARY` shows distinct reasons and the dashboard renders them. +- GAP-055 — one SIM trade, stop/restart same trading day, confirm the next signal rejects with `REJECT: reason=MaxDailyTrades`. +- GAP-045/046 — NQ SIM guard checks (misconfigured trailing-drawdown pair refuses startup, `MaxTradeRisk<=DailyLossLimit` enforced) plus a high-ATR signal behavior check. + +GAP-054 (runner trail) remains the one item with its own dedicated live validation path — NinjaTrader Market Replay — which the operator has explicitly deferred to a separate session ("Market Replay test later"). --- diff --git a/docs/00-governance/decisions.md b/docs/00-governance/decisions.md index 96af8f5..a7fd129 100644 --- a/docs/00-governance/decisions.md +++ b/docs/00-governance/decisions.md @@ -13,6 +13,94 @@ Use this file to record durable project decisions that affect implementation pat ## Decision Log +### DEC-20260826-01 +- **ID:** DEC-20260826-01 +- **Date:** 2026-08-26 +- **Status:** implemented — commit-only, pending SIM observation +- **Context:** GAP-062 followed `DEC-20260825-04` and `DEC-20260825-06`: short candidates could earn the negative-slope `slopeAligned` bonus or the old positive-slope `trend_confirm` bonus, but not both, because `trend_confirm` was computed as `avwapSlope > 0.0 ? 1.0 : 0.0` before the scorer evaluated trade side. No deployed GAP-061 telemetry evidence was available in the current NT8 session log directory (`TrendConfirm`/`AvwapSlope` not found), so implementation rested on the source-level proof and tests. +- **Decision:** Implement GAP-062 by publishing side-specific `trend_confirm_long` and `trend_confirm_short` values in `SimpleORBStrategy.UpdateConfluenceInputs()` using the already-computed AVWAP slope, then make `TrendAlignmentFactorCalculator` select the side-specific value matching `intent.Side`. Preserve the existing `TrendAlignmentFactorCalculator` score structure and weights exactly: `+0.4` price aligned to AVWAP, `+0.3` slope aligned to trade side, `+0.3` selected trend confirmation. Preserve the existing `STATE_CONTEXT` key shape by continuing to emit `TrendConfirm` as the legacy `trend_confirm` field, now resolved from pending/current breakout direction where available. +- **Symmetry proof:** Tests now prove the three required cases. A short candidate with price below AVWAP, `avwap_slope < 0`, and `trend_confirm_short = 1.0` reaches `Trend=1.0`, equal to a symmetric long with price above AVWAP, `avwap_slope > 0`, and `trend_confirm_long = 1.0`. A short candidate evaluated against an uptrend (`avwap_slope > 0`, `trend_confirm_short = 0.0`) does not earn trend confirmation and scores only the price-alignment component in the fixture. A long in a confirmed uptrend still reads `trend_confirm = 1.0` in factor details and reaches `Trend=1.0`, preserving long-side behavior. +- **Consequences:** This is a real scoring-behavior change, not observability-only. Previously B/C-capped short setups can now legitimately reach Grade A and pass `MinTradeGrade=A` when AVWAP slope genuinely confirms the short. Deploy was intentionally skipped per `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md`; operator SIM before/after observation is required before trusting this live. +- **Verification:** `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --filter "FullyQualifiedName~Intelligence" --verbosity minimal` passed 89/89. `verify-build.bat` passed 569/569. Existing CS1998 warnings in unrelated OMS/mock test files remain present, but the verification script reported `All checks passed`. +- **Related Files:** `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md`, `src/NT8.Strategies/Examples/SimpleORBStrategy.cs`, `src/NT8.Core/Intelligence/FactorCalculators.cs`, `tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs`, `SPRINT_BOARD.md`, `docs/00-governance/current_status.md`. + +### DEC-20260825-06 +- **ID:** DEC-20260825-06 +- **Date:** 2026-08-26 +- **Status:** decided — hold lifted, task prompted +- **Context:** `DEC-20260825-04`'s investigation into "zero trades this week" found every real, pullback-confirmed breakout capped at Grade B/C, driven by `Trend=0.30` on every best short setup on both 2026-08-18 and the week of 2026-08-25. Drafting GAP-061 (observability-only) surfaced a provable-from-source cause: `trend_confirm` (`SimpleORBStrategy.cs:970`) is `avwapSlope > 0.0 ? 1.0 : 0.0` — direction-blind, unconditionally rewarding a positive slope regardless of trade side. For a short trade, this is mutually exclusive by construction with the correctly-aligned (negative-slope) `+0.3` bonus in `TrendAlignmentFactorCalculator.Calculate()`, so a short can never earn both `+0.3` bonuses even with a cleanly confirmed downtrend — capping the Trend factor at 0.30 (or 0.70 with price also below AVWAP), well below the 1.0 a symmetric long can reach. Kilocode's own GAP-061 commit writeback independently re-confirmed this finding after a fresh source read (`DEC-20260825-05`). The fix itself was deliberately held out of GAP-061's observability-only scope pending an explicit operator decision, since it changes real scoring behavior. Operator reviewed a full audit of all 10 confluence factor calculators (Trend is the only one with this defect; the other 9 are either direction-agnostic by design or already correctly symmetric) and, given the standing goal of profitability on SIM with zero trades taken this week, decided to lift the hold and proceed. +- **Decision:** Lift the GAP-062 hold. Prompted `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md`, instructing Kilocode to make `trend_confirm` direction-aware (reward genuine trend confirmation in the direction of the candidate trade, not merely "slope is positive") without changing `TrendAlignmentFactorCalculator`'s additive `+0.4`/`+0.3`/`+0.3` structure or weights, and without changing long-side behavior (a long in a confirmed uptrend must still score `trend_confirm = 1.0`). Required tests proving three things: (1) a confirmed-downtrend short now earns `trend_confirm > 0.5` and reaches the same max Trend score a symmetric long would, (2) a short trading against the trend still correctly does NOT earn it (the fix must not become directionless in the other direction), (3) long-side scoring is byte-identical to before. Explicitly flagged, unlike GAP-050/GAP-061, that this is a real trading-behaviour change requiring SIM observation before/after deployment — not "none required." +- **Consequences:** Previously B/C-Grade-capped short setups with a genuinely confirmed downtrend can now legitimately reach Grade A and pass `MinTradeGrade`, meaning the strategy may begin taking short trades it previously silently rejected all week. This is the intended effect — the scoring was wrong, not the filter — but it is a live-behaviour change and must be observed on SIM (Grade distribution before/after, at least one previously-capped short now scoring A on a comparable setup) before being trusted, per the task's VALIDATION section. +- **Related Files:** `TASK_GAP062_TREND_CONFIRM_DIRECTION_PROMPT.md`, `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` (`UpdateConfluenceInputs()`), `src/NT8.Core/Intelligence/FactorCalculators.cs` (`TrendAlignmentFactorCalculator`), `docs/00-governance/decisions.md`, `SPRINT_BOARD.md`. +- **Action Required:** Await Kilocode's implementation and commit. Per standing practice, verify by reading the actual diff and the new tests directly — do not trust the commit summary. Once verified and deployed, observe SIM Grade distribution on short setups before/after to confirm the fix behaves as intended in practice, not just in unit tests. + +### DEC-20260825-05 +- **ID:** DEC-20260825-05 +- **Date:** 2026-08-25 +- **Status:** verification complete — all five confirmed correct +- **Context:** Kilocode reported GAP-050, GAP-061, GAP-057, GAP-056, and GAP-053 complete (commits `a99ce1d`, `a673475`, `0607d44`, `cdd9aa2`, `8a1c3d1`). Per standing practice, verified each by reading the actual diffs rather than trusting the commit summaries. +- **GAP-050:** Confirmed, exact match to the task and the operator's Option A decision. `IRiskManager` now declares the 4-arg `ValidateOrder`; `AdvancedRiskManager` adds it (3-arg now delegates to 4-arg with `candidateContracts=1`, Tier 1 forwards to `_basicRiskManager`'s 4-arg overload, Tier 2/3/3.5 untouched, added a `candidateContracts < 0` guard not explicitly requested but harmless); `NT8StrategyBase.cs`'s `as BasicRiskManager` type-check workaround is gone, replaced with a direct interface call; `NT8OrderAdapter.ExecuteIntent` now sizes before validating and passes the real contract count. New tests are genuinely load-bearing, not just compile checks: `AdvancedRiskManagerTests` proves the same intent is rejected at 3 contracts and allowed at 1; `NT8OrderAdapterIntegrationTests` proves the sized quantity actually reaches the risk manager and the 3-arg overload is never called; `NT8StrategyBaseRiskContractTests` source-asserts the type-check is gone. Live path (`BasicRiskManager`, direct construction) behaviorally unchanged — confirmed by reading the diff, not just trusting the note. +- **GAP-061:** Confirmed, exact match. `SimpleORBNT8.GetStateTelemetryContextFields()` adds `Avwap`/`AvwapSlope`/`TrendConfirm` via a new defensive `AddStateContextDouble` helper — null/missing-key/non-numeric safe, omits rather than placeholders. Tests explicitly assert `trend_confirm`'s calculation string is absent from the diff and that `STATE:`/`STATE_DETAIL:` formats are untouched — good self-verification of scope. Kilocode's own re-read independently reconfirmed the `trend_confirm` direction-blindness finding from `DEC-20260825-04` before implementing, rather than taking the task prompt's claim at face value — appended directly to that entry. +- **GAP-057:** Confirmed via stat + spot check — test-only, new `NT8StrategyBaseRunnerTrailTests.cs`, Option B (source-text seam) as specified, no production files touched. +- **GAP-056:** Confirmed via full diff. `NT8StrategyBase.cs`'s three breakeven properties now carry `[Browsable(false)]` plus an "unused" description; `SimpleORBNT8.cs`'s settings export labels the line `UNUSED (retained for compatibility)`. Exactly Option A as specified, no logic touched. +- **GAP-053:** Confirmed via stat — `executive_summary.md`/`roadmap.md` diffs only, no source or test files touched, matches docs-only scope. +- **Related Files:** commits `a99ce1d`/`a673475`/`0607d44`/`cdd9aa2`/`8a1c3d1`. +- **Action Required:** None for correctness. Deploy remains a separate manual operator step for all five (each skipped deploy per its task's header, as instructed). + +### DEC-20260825-04 +- **ID:** DEC-20260825-04 +- **Date:** 2026-08-25 +- **Status:** finding recorded, no code change — awaiting operator direction +- **Context:** Zero trades this week (Mon 8/24 + Tue 8/25 RTH). Investigated the continuous SIM session log (`session_20260823_230519.log`) directly rather than guessing. Found 63 genuine pullback-confirmed breakout evaluations this week (`DirectionSource=PendingBreakout` in `STATE:` telemetry, meaning `SimpleORBStrategy`'s real two-bar breakout-confirmation logic actually fired, not the pre-ORB/synthetic diagnostic tiers). Grade distribution among those 63: 0 A, 9 B, 10 C, 39 D, 5 F — every one was correctly filtered by `MinTradeGrade=A` (`SimpleORBStrategy.cs:677`, `GradeFilter`). All 9 B-grade instances came from one continuous bearish stretch (10:04:59-11:05:00 ET), scores 0.70-0.77. Reading the real per-factor breakdown (`STATE_DETAIL`) for those: `Trend=0.30` (full weight 1.00) was the single largest drag on every one — if Trend had scored near the other core factors (~0.80-1.00), several would plausibly have cleared Grade A. `PriorDayCloseStrength=0.40` and `NarrowRange=0.20` (both post-GAP-047-weighted) were secondary drags. This is a scoring/calibration observation, not a diagnosed defect — Trend genuinely measures AVWAP slope/alignment/confirmation and may be correctly scoring a genuinely weak-trend day; no code was changed and none is recommended without operator direction, since retuning `MinTradeGrade` or factor weights is a curve-fitting-risk decision, not a bug fix. +- **Separate finding (process, not scoring):** Investigating why zero `GradeFilter`/`OrbRangeNotEstablished`/`MaxDailyTrades` reasons ever appeared in this week's `REJECT SUMMARY` output (despite the real per-bar logic needing to produce them constantly) led to tracing the GAP-060 fix's own state machine (`_orbRejectSummarySnapshotWritten` fires once per trading day in the fixed version) against this log's actual behavior (fires once ever, then silent for the rest of the week) — this matches the **pre-fix** GAP-060 behavior exactly, not the fixed one. Conclusion: the currently-running SIM strategy (continuously live since 23:05:19 on 2026-08-23) is still running the **pre-GAP-060-fix binary**, because deployment was blocked by the `NinjaTrader.exe` file lock (`DEC-20260825-01`) and never completed. The fix is correct in source and committed; it has simply never reached the running strategy. This also means this week's `STATE:`-telemetry-based analysis above is the only visibility we had — the intended `REJECT SUMMARY` cadence has not actually been restored yet. +- **Decision:** None — reporting only. Recommended to operator: (1) redeploy now that NinjaTrader is closed, so `REJECT SUMMARY` visibility (GAP-060) is actually restored before the next SIM session; (2) separately decide whether the `Trend` factor / `MinTradeGrade=A` combination warrants review — that is a strategy-tuning call, not something to change unilaterally. +- **Related Files:** `session_20260823_230519.log` (device log folder), `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` (~347-690, `OnBar`/`GradeFilter` check), `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` (~700-856, RTH/ETH telemetry branch; ~1560-1595, reject snapshot state machine), `src/NT8.Core/Intelligence/ConfluenceScorer.cs`, `src/NT8.Core/Intelligence/GradeFilter.cs`. +- **Action Required:** Operator decision on whether/how to revisit `Trend` calibration or `MinTradeGrade`; redeploy GAP-060/059/051/052 (and GAP-050/053/056/057 once Kilocode lands them) now that NinjaTrader is closed. + +- **Update (2026-08-25, same day):** Pulled the only other trading day with usable `STATE:` telemetry (`EnableStateTelemetry`/DASH-002 only existed from ~2026-08-16 onward) — `session_20260818_065020.log`, 2026-08-18. Same pattern, slightly worse: 239 real `DirectionSource=PendingBreakout` evaluations, capping at Grade C (0 A, 0 B, 77 C, 132 D, 30 F; best score 0.655). That session predates GAP-047 (confluence weights still `x1.00` across the board — confirmed directly in the `Factors=` string). This week's best (`Score=0.774`, Grade B) is a real improvement over 8/18's best (`Score=0.655`, Grade C) — consistent with GAP-047 helping — but still short of `MinTradeGrade=A`. +- **Common driver on both days:** `Trend=0.30` on every one of the highest-scoring real breakouts, both days, both `Regime=Bearish`/`Direction=Sell`. Read `TrendAlignmentFactorCalculator.Calculate()` (`src/NT8.Core/Intelligence/FactorCalculators.cs` ~116-186): the Trend factor is additive — `+0.4` if price is on the trade's side of AVWAP, `+0.3` if AVWAP slope aligns with direction, `+0.3` if `trend_confirm > 0.5`. A score of exactly `0.30` means only one `+0.3` component fired and the `+0.4` price-vs-AVWAP component did not, on both days. Working hypothesis, **not verified against raw `avwap`/`avwap_slope` values** (not present in `STATE_CONTEXT` telemetry output, so this needs either a temporary diagnostic field or a debugger session to confirm): an ORB breakout is, by construction, an *early-session* entry (right after the 09:30-10:00 window closes) — a session-anchored AVWAP has had very little time to diverge from price that early, so the `+0.4` "price is clearly on the trade's side of AVWAP" component may be structurally hard to earn on a textbook, well-timed ORB breakout even when the breakout itself is real and directionally correct. If true, this is a design tension between the ORB strategy's entry timing and the Trend factor's assumption of a well-developed AVWAP — not a coding defect in either piece individually. +- **Not decided, options for operator:** (1) leave as-is and gather more days of evidence before concluding anything — two days is a thin sample; (2) instrument `STATE_CONTEXT` with the raw `avwap`/`avwap_slope`/`trend_confirm` values so this hypothesis can be confirmed or refuted directly from the log instead of inferred (small, safe, observability-only change, same class as GAP-059); (3) if confirmed, consider whether `TrendAlignmentFactorCalculator`'s AVWAP-divergence assumption should be reweighted or time-adjusted for early-session entries specifically, or whether `MinTradeGrade` should account for this — both are real strategy-design decisions, not something to change without operator sign-off given the risk of curve-fitting to a two-day sample. +- **Update (2026-08-25, same day) — operator selected option (2).** Drafting the instrumentation task surfaced something sharper than the AVWAP-divergence hypothesis: `trend_confirm` (`SimpleORBStrategy.cs:970`, `context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0`) is direction-blind, not just a hypothesis needing log confirmation — it's provable directly from source. `TrendAlignmentFactorCalculator` awards `+0.3` for `slopeAligned` (short trades need `avwapSlope < 0.0`) and a separate `+0.3` for `trendConfirm > 0.5` (which requires `avwapSlope > 0.0`, unconditionally). These two are mutually exclusive for any short trade by construction — a short can never earn both bonuses, even with a cleanly confirmed downtrend, capping the achievable Trend score at `0.3` (or `0.7` with price also below AVWAP) regardless of trend quality. This matches both real days' `Trend=0.30` results exactly. Tracked as **GAP-061**, scoped observability-only per the operator's instruction — exposes `Avwap`/`AvwapSlope`/`TrendConfirm` in `STATE_CONTEXT` (does not fix the asymmetry) so the remaining unconfirmed piece (price-vs-AVWAP timing) can be checked with real numbers, and so the `trend_confirm` finding is visible in log evidence too. Whether to fix the asymmetry itself is a separate, not-yet-made decision — flagged explicitly in the task's writeback requirement so the operator gets a clean basis to decide. +- **Prompt:** `TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md`. +- **GAP-061 Implementation Note (2026-08-25):** Implemented the selected observability-only instrumentation in `SimpleORBNT8.GetStateTelemetryContextFields()`. `STATE_CONTEXT` now appends `Avwap` (`F2`), `AvwapSlope` (`F4`), and `TrendConfirm` (`F1`) from existing `context.CustomData` keys when present, omitting each field entirely when the key is missing or non-numeric. The ORB-readiness gate and existing `OrbHigh`/`OrbLow`/`OrbWindowStart`/`OrbWindowEnd`/`OrbReady` fields are unchanged. No `UpdateConfluenceInputs()`, `TrendAlignmentFactorCalculator`, `trend_confirm`, scoring, `STATE:`, `STATE_DETAIL:`, risk, sizing, or order-flow logic changed. Source re-check confirms the direction-blindness finding remains: `trend_confirm` is still `avwapSlope > 0.0 ? 1.0 : 0.0`, so short trades can earn the negative-slope `slopeAligned` bonus or the positive-slope `trend_confirm` bonus, but not both. Verification: focused `SimpleORBNT8DefaultsTests` passed 7/7; `verify-build.bat` passed with 561/561 tests (472 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 472/472. Deploy intentionally skipped by task prompt. + + + +### DEC-20260825-03 +- **ID:** DEC-20260825-03 +- **Date:** 2026-08-25 +- **Status:** decided — Option A, prompted to Kilocode +- **Context:** GAP-050 (`MaxTradeRisk` has no quantity term) was staged 2026-08-18 as an operator-decision item. Investigation on 2026-08-25 (prompted by "layout the options") found the original framing ("$600 vs $1,000 daily limit") is stale for the live path: `SimpleORBNT8`/`NT8StrategyBase` constructs `BasicRiskManager` directly (`NT8StrategyBase.cs:1763`) and its order-eval ternary (~2131-2136) reaches the quantity-aware 4-arg `ValidateOrder(intent, context, config, candidateContracts)` overload via an `as BasicRiskManager` runtime type-check. `IRiskManager` itself, however, never declared a quantity-aware member — only the 3-arg `ValidateOrder(intent, context, config)`. `AdvancedRiskManager` implements `IRiskManager` but has no 4-arg overload and delegates Tier 1 to its inner `BasicRiskManager` via the 1-contract-assumed 3-arg call; confirmed via grep that `new AdvancedRiskManager(` appears nowhere in `src/` outside its own file (only constructed in isolation by `AdvancedRiskManagerTests.cs`/`RiskSizingIntegrationTests.cs`) — not wired to live trading. `NT8OrderAdapter.ExecuteIntent` also validates before sizing (backwards even if quantity-aware) and is itself only reachable through `BaseNT8StrategyWrapper`, whose own doc comment calls it "a template that would be extended in actual NT8 strategy files" — not extended anywhere in `src/`. Net: today's SIM/live trading is not exposed; the real defect is an interface contract gap covered only by a type-check, plus two unwired call sites that would silently reintroduce it if ever activated. +- **Decision:** Operator selected **Option A** — fix it properly at the interface rather than leaving the type-check workaround in place. Add the 4-arg `ValidateOrder` to `IRiskManager` itself, implement it on `AdvancedRiskManager` (Tier 1 forwarded to the inner `BasicRiskManager`'s 4-arg overload, Tier 2/3/3.5 bodies unchanged), remove the `as BasicRiskManager` cast in `NT8StrategyBase.cs` in favor of a direct interface call, and fix `NT8OrderAdapter.ExecuteIntent`'s validate-before-size ordering. Explicitly out of scope: wiring `AdvancedRiskManager`/`NT8OrderAdapter` into the live strategy — that is a separate decision this task does not make. +- **Consequences:** No live-behaviour change expected — the live path's underlying call is identical, just reached without the type-check. Closes the risk of a future silent regression if `AdvancedRiskManager` or `NT8OrderAdapter` are ever wired into a live path. Requires new quantity-aware tests on `AdvancedRiskManager` and `NT8OrderAdapter`. +- **Related Files:** `src/NT8.Core/Risk/IRiskManager.cs`, `src/NT8.Core/Risk/BasicRiskManager.cs`, `src/NT8.Core/Risk/AdvancedRiskManager.cs`, `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `src/NT8.Adapters/NinjaTrader/NT8OrderAdapter.cs`, `TASK_GAP050_ADVANCED_RISK_QTY_PROMPT.md` +- **Action Required:** GAP-050 implemented; deploy remains a separate manual operator step. +- **GAP-050 Implementation Note (2026-08-25):** Implemented Option A. `IRiskManager` now declares the quantity-aware 4-arg `ValidateOrder`; `BasicRiskManager` already satisfied the contract with no logic change; `AdvancedRiskManager` now has a 4-arg overload that forwards Tier 1 to `_basicRiskManager.ValidateOrder(..., candidateContracts)` and the 3-arg overload delegates to the 4-arg overload with `candidateContracts=1`; `NT8StrategyBase` now calls `_riskManager.ValidateOrder(intent, context, _riskConfig, sizingResult.Contracts)` directly instead of casting to `BasicRiskManager`; `NT8OrderAdapter.ExecuteIntent()` now sizes first, returns on `Contracts <= 0`, and then validates risk with the sized quantity. Added tests for quantity-aware AdvancedRiskManager rejection/allowance, backward-compatible 3-arg behavior, NT8OrderAdapter sized risk validation, and NT8StrategyBase source-level interface usage. Verification: focused Core tests passed 10/10; focused Integration tests passed 13/13; `verify-build.bat` passed with 566/566 tests (476 Core, 80 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 476/476. Deploy intentionally skipped by task prompt. + +### DEC-20260825-02 +- **ID:** DEC-20260825-02 +- **Date:** 2026-08-25 +- **Status:** implemented +- **Context:** GAP-053 was flagged by the original v7.0 review as `executive_summary.md`/`roadmap.md`'s Sprint 3 list presenting ~12 completed tasks as open. `roadmap.md` already contains its own `STALE-LIST WARNING (GAP-053, added 2026-08-18)` naming the specific stale items (TASK-06a, TASK-06b, GAP-003/004/005/006/008/009/010/019/022, plus GAP-011/GAP-040 separately) — it has sat unpruned since the warning was added. `executive_summary.md` (dated 2026-05-04, still referencing the retired v6 master doc) separately lists four of the same already-completed items under "Critical Open Issues." +- **Decision:** Track as **GAP-053**. Documentation-only, zero trading-behaviour risk. Task requires independently re-verifying each named-stale item's completion (via `SPRINT_BOARD.md`'s historical record and the cited `DEC-20260711-01..09`/`DEC-20260713-02` entries) before pruning — not just trusting the warning's own claims — and flagging anything that doesn't check out rather than pruning it anyway. +- **Related Files:** `docs/00-governance/executive_summary.md`, `docs/00-governance/roadmap.md`, `TASK_GAP053_STALE_DOCS_PRUNE_PROMPT.md` +- **Implementation Note (2026-08-25):** GAP-053 pruned the stale May/July status snapshots from `executive_summary.md` and `roadmap.md`. Verified before pruning against `SPRINT_BOARD.md` historical records and decision entries: TASK-06a, TASK-06b, GAP-003, GAP-004, GAP-005, GAP-006, GAP-008, GAP-009, GAP-010, GAP-011, and GAP-019 are complete from the 2026-07-11 historical record; GAP-022 is partial with 5/8 verified on 2026-07-14 and remaining connection-state scenarios tracked as GAP-022-FOLLOWUP; GAP-040 is implemented/firing in production as of 2026-08-18. `executive_summary.md` now points at the v7.0 master reference, moves the four v6 critical issues into a resolved-since-v6 section, and lists current open items instead. `roadmap.md` no longer contains the `STALE-LIST WARNING` or the open-looking July list; it now records the pruned resolved history and leaves GAP-030/GAP-007 separate. No source code or tests changed. +- **Action Required:** None. Documentation-only; no operator validation required. + +### DEC-20260825-01 +- **ID:** DEC-20260825-01 +- **Date:** 2026-08-25 +- **Status:** verification complete — all four confirmed correct; deploy still pending +- **Context:** Kilocode reported GAP-060, GAP-059, GAP-051, and GAP-052 complete (commits `6c672a5`, `7e82b2c`, `18877c3`, `8b9a2e2`). Per standing practice, verified each by reading the actual diffs rather than trusting the summary. +- **GAP-060:** Confirmed. `MaybeWriteRejectSummarySnapshot`'s blanket `TimeOfDay < 10:00 AM` gate replaced with a proper `[suppressionStart, suppressionEnd)` window check (`IsRejectSummarySnapshotSuppressed`), overridden in `SimpleORBNT8` to bind to the actual configured ORB window instead of a hardcoded one. The once-after-ORB flag now resets per `barTime.Date` via a new `_rejectSummarySnapshotTradingDate` field. A new unconditional `MaybeWriteRejectSummarySnapshot(Time[0])` call was added to the `OnBarUpdate` heartbeat (before context/intent evaluation), so cadence no longer depends solely on a reject occurring. The open question from the task was resolved as possibility (a) — a new real execution test (`OnBar_RthNoBreakout_RecordsOrbRangeNotEstablishedBeforeAndAfterOrbClose`) drives `SimpleORBStrategy.OnBar()` directly and proves `OrbRangeNotEstablished` is correctly set in `context.CustomData` both during ORB-building and after close with no breakout — confirming the missing visibility was purely the summary-reporting layer, not a second strategy-level defect. New tests in `NT8StrategyBaseRejectSummaryTests.cs` are source-text assertions (consistent with the established, previously-accepted pattern for this NinjaScript-derived class that cannot be instantiated for execution tests). +- **GAP-059:** Confirmed. `SimpleORBNT8.OnBarUpdate()` no longer reads the dead `_openingRangeHigh`/`_openingRangeLow` fields — both removed entirely (test asserts their absence from source). ORB high/low now come from `(_sdkStrategy as SdkSimpleORB).OpeningRangeHigh/OpeningRangeLow`, gated on `OpeningRangeReady`, matching the pattern already used correctly elsewhere in the file. New test `OrbRangeVsAtr_RealisticSdkOrbRangeTicks_ReturnsRatioReason` is a genuine execution test against `OrbRangeVsAtrFactorCalculator.Calculate()` using tonight's real logged ORB values (29243.00/28946.75) and confirms the factor no longer returns the neutral "no daily bar context" fallback. +- **GAP-051:** Confirmed, Option A as specified. New `_microUpgradePersistenceLoaded`/`InitializeMicroUpgradeSuggestedState()` load a dedicated `micro_upgrade_suggested_.json` once per realtime run; `WriteMicroUpgradeSuggestedFile()` persists it only after the existing advisory message fires. Corrupt/missing file correctly falls back to allowing the reminder (over-reminding over silent suppression, as specified) rather than throwing. `Account == null` performs no file I/O. Does not touch GAP-055's own persistence file. +- **GAP-052:** Confirmed, Option A as specified, plus a legitimate scope extension worth flagging: Kilocode found that `AdvancedRiskManager.cs` and `AdvancedPositionSizer.cs` carried their own additional, independently-drifted copies of the same tick-value table (not mentioned in the task, which only named `BasicRiskManager`/`BasicPositionSizer`) and consolidated all four into the new `NT8.Core.Common.InstrumentTickValueTable`, containing the correct union (`6A=$10.00`, `6E=$12.50`). Two real execution tests: one asserts full parity across `InstrumentTickValueTable`/`BasicRiskManager`/`BasicPositionSizer`'s `GetSupportedSymbols()` for every symbol, the other drives `BasicRiskManager.ValidateOrder()` end-to-end for a real `6A` intent and confirms the computed trade risk now uses `$10.00`/tick. Platform-neutrality question from the task's READ-FIRST was correctly answered: `NT8.Core` cannot reference `Instrument.MasterInstrument`, so Option A (not B) was the only viable choice — documented explicitly in the implementation note. +- **Process finding (not a code defect):** For GAP-060 and GAP-059, `deployment\deploy-to-nt8.bat` was actually *run* and only failed because `NinjaTrader.exe` (PID 18800) held a lock on `NT8.Core.dll` — not because Kilocode honored the "commit only, do not deploy" instruction added to those two task prompt files. Confirmed by reading the committed copies of `TASK_GAP060_...md`/`TASK_GAP059_...md` in the relevant commits directly: neither contains the "Deploy: COMMIT ONLY" line added earlier — Kilocode ran from an older cached copy of those two files. For GAP-051 and GAP-052 (run afterward), the commit messages read "skipped per operator instruction," meaning the no-deploy instruction reached Kilocode as a direct/verbal instruction from the operator partway through the run, not from the file text either. Net effect tonight: harmless, because the file lock acted as an accidental safety net — but the instruction itself did not do the job as intended, and would not protect against a future run where NinjaTrader happens not to be holding the DLL. +- **Also flagged, not investigated further:** the device repo's working tree currently shows several files (`SPRINT_BOARD.md`, four `TASK_GAP0*.md` files, and four `docs/00-governance/*.md` files) as modified-but-uncommitted relative to `HEAD`, and a `git status`/`git diff` invocation from this session surfaced a `.git/index.lock` unlink permission warning. This session did not attempt any git write operations to investigate or resolve it. Recommend the operator check `git status` directly on the machine before the next Kilocode run or deploy attempt, in case there's a leftover lock from an interrupted operation. +- **Related Files:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `src/NT8.Adapters/Strategies/SimpleORBNT8.cs`, `src/NT8.Core/Common/InstrumentTickValueTable.cs`, `src/NT8.Core/Risk/BasicRiskManager.cs`, `src/NT8.Core/Risk/AdvancedRiskManager.cs`, `src/NT8.Core/Sizing/BasicPositionSizer.cs`, `src/NT8.Core/Sizing/AdvancedPositionSizer.cs`, commits `6c672a5`/`7e82b2c`/`18877c3`/`8b9a2e2` +- **Action Required:** Once NinjaTrader is closed, rerun `deployment\deploy-to-nt8.bat`, manually compile NinjaScript, and validate all four in the next SIM session (REJECT SUMMARY cadence throughout RTH for GAP-060; `OrbRangeVsAtr` no longer "no daily bar context" for GAP-059; a same-account restart no longer re-logging `TIER_UPGRADE_SUGGESTED` for GAP-051; no operator validation needed for GAP-052 since NQ/MNQ are unaffected). Separately, confirm the working-tree/git-lock state on the machine directly before the next Kilocode run. + ### DEC-20260823-08 - **ID:** DEC-20260823-08 - **Date:** 2026-08-24 @@ -24,34 +112,6 @@ Use this file to record durable project decisions that affect implementation pat - **Related Files:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` (`MaybeWriteRejectSummarySnapshot`/`LogRejectRateLimited`/`ResetRejectTracking`/`WriteSessionHeader` ~1444-1517), `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` (`OnBar` ~355-432, `RecordSignalRejection` ~1015-1026), `session_20260823_230519.log` - **Implementation Note (2026-08-25):** GAP-060 implemented as logging/observability only. `NT8StrategyBase.MaybeWriteRejectSummarySnapshot()` no longer has a blanket midnight-to-10:00 AM suppression gate; suppression now delegates to an ORB-window-aware helper and `SimpleORBNT8` overrides that helper so the suppressed window is today's configured 09:30 + `OpeningRangeMinutes`. The once-after-ORB snapshot flag now resets per `barTime.Date`, allowing a new post-ORB summary every day in a continuous multi-day session. `OnBarUpdate()` now calls `MaybeWriteRejectSummarySnapshot(Time[0])` on the live bar heartbeat after the first realtime-bar guard, so 15-minute summary cadence can flush from regular processed bars and is not solely dependent on a newly logged reject. Existing `_rejectDetailsLogged` one-detail-line-per-reason rate limiting, reject reason strings, `REJECT:`/`REJECT SUMMARY:` formats, order flow, sizing, risk, and real trade decisions were unchanged. Open question resolved as possibility **(a)**: the missing `OrbRangeNotEstablished` visibility was adapter summary reporting, not a second SimpleORB rejection defect. A focused `SimpleORBStrategy.OnBar()` test proves the no-breakout RTH path records `OrbRangeNotEstablished` both while the ORB is building and after ORB close when no breakout confirms. Verification: focused GAP-060 tests passed 8/8; `verify-build.bat` passed with 543/543 tests (454 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 454/454. - **Action Required:** Deployment remains pending. `deployment\deploy-to-nt8.bat` was attempted on 2026-08-25 but failed because NinjaTrader.exe PID 18800 locked `NT8.Core.dll`; operator instructed Kilocode to commit without deploy. After NinjaTrader is closed, rerun deployment, start NT8, manually compile NinjaScript, and in the next SIM session spanning a full trading day confirm `REJECT SUMMARY` appears throughout RTH at a reasonable cadence. -### DEC-20260825-03 -- **ID:** DEC-20260825-03 -- **Date:** 2026-08-25 -- **Status:** implemented — Option A, deploy skipped by prompt -- **Context:** GAP-050 (`MaxTradeRisk` has no quantity term) was staged 2026-08-18 as an operator-decision item. Investigation on 2026-08-25 found the original framing ("$600 vs $1,000 daily limit") is stale for the live path: `SimpleORBNT8`/`NT8StrategyBase` constructs `BasicRiskManager` directly and already reaches the quantity-aware 4-arg `ValidateOrder(intent, context, config, candidateContracts)` overload via an `as BasicRiskManager` runtime type-check. `IRiskManager` itself, however, never declared a quantity-aware member. `AdvancedRiskManager` implemented `IRiskManager` but had no 4-arg overload and delegated Tier 1 to its inner `BasicRiskManager` through the 1-contract-assumed 3-arg call. `NT8OrderAdapter.ExecuteIntent` validated before sizing, so it also could not pass quantity. These scaffolding paths are not currently wired to live SimpleORB trading, but would silently reintroduce the 1-contract assumption if activated. -- **Decision:** Operator selected Option A: fix the contract at `IRiskManager`, add the quantity-aware implementation to `AdvancedRiskManager`, remove the live-path type-check workaround from `NT8StrategyBase`, and fix `NT8OrderAdapter.ExecuteIntent` to size before risk validation. Do not wire `AdvancedRiskManager` or `NT8OrderAdapter` into live trading in this task. -- **Implementation Note (2026-08-25):** `IRiskManager` now declares the quantity-aware 4-arg `ValidateOrder`; `BasicRiskManager` already satisfied the contract with no logic change; `AdvancedRiskManager` now has a 4-arg overload that forwards Tier 1 to `_basicRiskManager.ValidateOrder(..., candidateContracts)` and the 3-arg overload delegates to the 4-arg overload with `candidateContracts=1`; `NT8StrategyBase` now calls `_riskManager.ValidateOrder(intent, context, _riskConfig, sizingResult.Contracts)` directly instead of casting to `BasicRiskManager`; `NT8OrderAdapter.ExecuteIntent()` now sizes first, returns on `Contracts <= 0`, and then validates risk with the sized quantity. Added tests for quantity-aware AdvancedRiskManager rejection/allowance, backward-compatible 3-arg behavior, NT8OrderAdapter sized risk validation, and NT8StrategyBase source-level interface usage. Verification: focused Core tests passed 10/10; focused Integration tests passed 13/13; `verify-build.bat` passed with 566/566 tests (476 Core, 80 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 476/476. Deploy intentionally skipped by task prompt. -- **Related Files:** `src/NT8.Core/Risk/IRiskManager.cs`, `src/NT8.Core/Risk/AdvancedRiskManager.cs`, `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `src/NT8.Adapters/NinjaTrader/NT8OrderAdapter.cs`, `tests/NT8.Core.Tests/Risk/AdvancedRiskManagerTests.cs`, `tests/NT8.Core.Tests/Adapters/NT8StrategyBaseRiskContractTests.cs`, `tests/NT8.Integration.Tests/NT8OrderAdapterIntegrationTests.cs`, `TASK_GAP050_ADVANCED_RISK_QTY_PROMPT.md` -- **Action Required:** Deploy remains a separate manual operator step. No operator validation required before commit because the live path's underlying quantity-aware `BasicRiskManager` call is unchanged. -### DEC-20260825-04 -- **ID:** DEC-20260825-04 -- **Date:** 2026-08-25 -- **Status:** GAP-061 implemented; trend calibration follow-up undecided -- **Context:** Zero-trade investigation found real short-side breakout evaluations capped below Grade A, with `Trend=0.30` as the common driver on the best setups. Source read confirmed `TrendAlignmentFactorCalculator` adds `+0.4` for price on the trade side of AVWAP, `+0.3` for slope aligned with trade direction, and `+0.3` for `trend_confirm > 0.5`. -- **Finding:** `trend_confirm` is direction-blind in `SimpleORBStrategy.UpdateConfluenceInputs()` (`context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0`). For short trades, slope alignment requires `avwapSlope < 0.0`, while `trend_confirm` requires `avwapSlope > 0.0`; a short can therefore earn one or the other, but not both, even in a clean bearish trend. GAP-061 does not fix this scoring asymmetry; it only exposes raw telemetry for operator review. -- **Decision:** Implement the selected observability-only instrumentation. Do not change `trend_confirm`, scoring, `MinTradeGrade`, risk, sizing, or order flow in this task. -- **Implementation Note (2026-08-25):** `SimpleORBNT8.GetStateTelemetryContextFields()` now appends `Avwap` (`F2`), `AvwapSlope` (`F4`), and `TrendConfirm` (`F1`) from existing `context.CustomData` keys when present, omitting each field entirely when the key is missing or non-numeric. The ORB-readiness gate and existing `OrbHigh`/`OrbLow`/`OrbWindowStart`/`OrbWindowEnd`/`OrbReady` fields are unchanged. No `UpdateConfluenceInputs()`, `TrendAlignmentFactorCalculator`, `trend_confirm`, scoring, `STATE:`, `STATE_DETAIL:`, risk, sizing, or order-flow logic changed. Verification: focused `SimpleORBNT8DefaultsTests` passed 7/7; `verify-build.bat` passed with 561/561 tests (472 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 472/472. Deploy intentionally skipped by task prompt. -- **Related Files:** `src/NT8.Adapters/Strategies/SimpleORBNT8.cs`, `tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs`, `TASK_GAP061_AVWAP_TELEMETRY_PROMPT.md` -- **Action Required:** Operator decision still needed on whether to fix direction-blind `trend_confirm` or revisit Trend/MinTradeGrade calibration after reviewing real `STATE_CONTEXT` values from a deployed session. -### DEC-20260825-02 -- **ID:** DEC-20260825-02 -- **Date:** 2026-08-25 -- **Status:** implemented -- **Context:** GAP-053 was flagged by the original v7.0 review as `executive_summary.md`/`roadmap.md`'s Sprint 3 list presenting ~12 completed tasks as open. `roadmap.md` already contained its own `STALE-LIST WARNING (GAP-053, added 2026-08-18)` naming the specific stale items (TASK-06a, TASK-06b, GAP-003/004/005/006/008/009/010/019/022, plus GAP-011/GAP-040 separately), and `executive_summary.md` still listed four of the same already-completed items under "Critical Open Issues." -- **Decision:** Prune only independently verified stale items from `executive_summary.md` and `roadmap.md`. Documentation-only, zero trading-behaviour risk. -- **Implementation Note (2026-08-25):** Verified against `SPRINT_BOARD.md` historical records and decision entries before pruning: TASK-06a, TASK-06b, GAP-003, GAP-004, GAP-005, GAP-006, GAP-008, GAP-009, GAP-010, GAP-011, and GAP-019 are complete from the 2026-07-11 historical record; GAP-022 is partial with 5/8 verified on 2026-07-14 and remaining connection-state scenarios tracked as GAP-022-FOLLOWUP; GAP-040 is implemented/firing in production as of 2026-08-18. `executive_summary.md` now points at the v7.0 master reference, moves the four v6 critical issues into a resolved-since-v6 section, and lists current open items instead. `roadmap.md` no longer contains the `STALE-LIST WARNING` or the open-looking July list; it records the pruned resolved history and leaves GAP-030/GAP-007 separate. No source code or tests changed. -- **Related Files:** `docs/00-governance/executive_summary.md`, `docs/00-governance/roadmap.md`, `TASK_GAP053_STALE_DOCS_PRUNE_PROMPT.md` -- **Action Required:** None. Documentation-only; no operator validation required. ### DEC-20260823-07 - **ID:** DEC-20260823-07 - **Date:** 2026-08-23/24 @@ -124,6 +184,7 @@ Use this file to record durable project decisions that affect implementation pat 2. **GAP-057 — no test seam exposes NinjaScript's `SetStopLoss`/`SetTrailStop` managed-order calls.** `TASK_GAP054_RUNNER_TRAIL_PROMPT.md` asked for a regression test asserting no `SetStopLoss` call is issued after `SetTrailStop` for a runner signal, with instructions to propose the smallest seam if none exists. Kilocode correctly did not fabricate coverage, but a concrete seam proposal wasn't written up. This is the same defect class as GAP-054 (silent exit-order clobbering) — worth closing so a future change to this block gets real regression coverage instead of relying on manual source review, as this review just did. - **Decision:** Track both, do not action either as part of GAP-054. No operator decision required to log them. - **Related Files:** `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `TASK_GAP054_RUNNER_TRAIL_PROMPT.md` +- **Action Required:** None immediate. Stage as low-priority follow-up prompts when convenient. - **GAP-056 Implementation Note (2026-08-25):** Implemented Option A for the inert breakeven parameters. `EnableAutoBreakeven`, `BreakevenTriggerTicks`, and `BreakevenOffsetTicks` remain declared/defaulted for saved workspace and settings compatibility, but are now `[Browsable(false)]` and their `Display` descriptions state they are currently unused. `SimpleORBNT8` settings export now labels the values as `UNUSED (retained for compatibility)`. This is reversible and avoids breaking persisted templates; Option B removal was not chosen because there was no concrete need to delete the fields and no benefit worth risking workspace/settings references. Added source-level tests proving the properties are hidden/marked unused and not read by `OnBarUpdate()` or `SubmitOrderToNT8()`. Verification: focused GAP-056 tests passed 3/3; `verify-build.bat` passed with 555/555 tests (466 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 466/466. Deploy intentionally skipped by task prompt. - **GAP-057 Implementation Note (2026-08-25):** Implemented Option B, a source-text regression seam, because extracting a real `IOrderManagementCalls` wrapper would require routing live NinjaScript `SetStopLoss`/`SetTrailStop`/entry calls through new production indirection inside `SubmitOrderToNT8`, creating unnecessary order-timing risk for a test-only task. Added `NT8StrategyBaseRunnerTrailTests`: one test proves no `SetStopLoss(_runnerSignalName...)` appears after the runner `SetTrailStop(_runnerSignalName...)` calls in `SubmitOrderToNT8`; one proves the post-entry runner monitor in `OnBarUpdate()` contains no `SetStopLoss`/`SetTrailStop` calls; one proves the source-text seam did not add an order-management wrapper and the real implementation still uses direct NinjaScript managed-order calls. No production source changed for GAP-057. Verification: focused GAP-057 tests passed 3/3; `verify-build.bat` passed with 558/558 tests (469 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 469/469. Deploy intentionally skipped by task prompt. - **Action Required:** GAP-056 and GAP-057 complete. GAP-054 still requires SIM/replay validation before RUNNER-001 or live gate evidence. diff --git a/src/NT8.Core/Intelligence/FactorCalculators.cs b/src/NT8.Core/Intelligence/FactorCalculators.cs index 74622b5..2dc3280 100644 --- a/src/NT8.Core/Intelligence/FactorCalculators.cs +++ b/src/NT8.Core/Intelligence/FactorCalculators.cs @@ -144,13 +144,14 @@ namespace NT8.Core.Intelligence var avwap = GetDouble(context.CustomData, "avwap", bar.Close); var avwapSlope = GetDouble(context.CustomData, "avwap_slope", 0.0); - var trendConfirm = GetDouble(context.CustomData, "trend_confirm", 0.0); + var isLong = intent.Side == OrderSide.Buy; + var trendConfirmKey = isLong ? "trend_confirm_long" : "trend_confirm_short"; + var trendConfirm = GetDouble(context.CustomData, trendConfirmKey, 0.0); details.Add("avwap", avwap); details.Add("avwap_slope", avwapSlope); details.Add("trend_confirm", trendConfirm); - var isLong = intent.Side == OrderSide.Buy; var priceAligned = isLong ? bar.Close > avwap : bar.Close < avwap; if (priceAligned) score += 0.4; diff --git a/src/NT8.Strategies/Examples/SimpleORBStrategy.cs b/src/NT8.Strategies/Examples/SimpleORBStrategy.cs index 94529cf..4c28195 100644 --- a/src/NT8.Strategies/Examples/SimpleORBStrategy.cs +++ b/src/NT8.Strategies/Examples/SimpleORBStrategy.cs @@ -967,7 +967,9 @@ namespace NT8.Strategies.Examples context.CustomData["current_bar"] = bar; context.CustomData["avwap"] = avwap; context.CustomData["avwap_slope"] = avwapSlope; - context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0; + context.CustomData["trend_confirm_long"] = avwapSlope > 0.0 ? 1.0 : 0.0; + context.CustomData["trend_confirm_short"] = avwapSlope < 0.0 ? 1.0 : 0.0; + context.CustomData["trend_confirm"] = ResolveTrendConfirmForTelemetry(bar, avwapSlope); context.CustomData["current_atr"] = Math.Max(0.01, bar.High - bar.Low); context.CustomData["normal_atr"] = Math.Max(0.01, normalAtr); context.CustomData["recent_execution_quality"] = 0.8; @@ -981,6 +983,29 @@ namespace NT8.Strategies.Examples } } + private double ResolveTrendConfirmForTelemetry(BarData bar, double avwapSlope) + { + int direction = _pendingBreakoutDirection; + + if (direction == 0 && _openingRangeReady) + { + double openingRange = _openingRangeHigh - _openingRangeLow; + double volatilityBuffer = openingRange * (_stdDevMultiplier - 1.0); + if (volatilityBuffer < 0.0) + volatilityBuffer = 0.0; + + if (bar.Close > _openingRangeHigh + volatilityBuffer) + direction = 1; + else if (bar.Close < _openingRangeLow - volatilityBuffer) + direction = -1; + } + + if (direction < 0) + return avwapSlope < 0.0 ? 1.0 : 0.0; + + return avwapSlope > 0.0 ? 1.0 : 0.0; + } + private void ResetSession(DateTime sessionStart) { _currentSessionDate = sessionStart.Date; diff --git a/tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs b/tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs index 7615077..88e534d 100644 --- a/tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs +++ b/tests/NT8.Core.Tests/Intelligence/OrbConfluenceFactorTests.cs @@ -280,6 +280,62 @@ namespace NT8.Core.Tests.Intelligence Assert.AreEqual(1.0, result.Score, 0.000001); } + [TestMethod] + public void TrendAlignment_ShortConfirmedDowntrend_ScoresSameAsSymmetricLong() + { + var calc = new TrendAlignmentFactorCalculator(); + var shortContext = CreateContext(); + shortContext.CustomData.Add("avwap", 5005.0); + shortContext.CustomData.Add("avwap_slope", -0.25); + shortContext.CustomData.Add("trend_confirm_long", 0.0); + shortContext.CustomData.Add("trend_confirm_short", 1.0); + + var longContext = CreateContext(); + longContext.CustomData.Add("avwap", 4999.0); + longContext.CustomData.Add("avwap_slope", 0.25); + longContext.CustomData.Add("trend_confirm_long", 1.0); + longContext.CustomData.Add("trend_confirm_short", 0.0); + + var shortResult = calc.Calculate(CreateIntent(OrderSide.Sell), shortContext, CreateBar()); + var longResult = calc.Calculate(CreateIntent(OrderSide.Buy), longContext, CreateBar()); + + Assert.AreEqual(1.0, shortResult.Details["trend_confirm"]); + Assert.AreEqual(1.0, shortResult.Score, 0.000001); + Assert.AreEqual(longResult.Score, shortResult.Score, 0.000001); + } + + [TestMethod] + public void TrendAlignment_ShortAgainstUptrend_DoesNotEarnTrendConfirm() + { + var calc = new TrendAlignmentFactorCalculator(); + var context = CreateContext(); + context.CustomData.Add("avwap", 5005.0); + context.CustomData.Add("avwap_slope", 0.25); + context.CustomData.Add("trend_confirm_long", 1.0); + context.CustomData.Add("trend_confirm_short", 0.0); + + var result = calc.Calculate(CreateIntent(OrderSide.Sell), context, CreateBar()); + + Assert.AreEqual(0.0, result.Details["trend_confirm"]); + Assert.AreEqual(0.4, result.Score, 0.000001); + } + + [TestMethod] + public void TrendAlignment_LongConfirmedUptrend_RemainsFullyConfirmed() + { + var calc = new TrendAlignmentFactorCalculator(); + var context = CreateContext(); + context.CustomData.Add("avwap", 4999.0); + context.CustomData.Add("avwap_slope", 0.25); + context.CustomData.Add("trend_confirm_long", 1.0); + context.CustomData.Add("trend_confirm_short", 0.0); + + var result = calc.Calculate(CreateIntent(OrderSide.Buy), context, CreateBar()); + + Assert.AreEqual(1.0, result.Details["trend_confirm"]); + Assert.AreEqual(1.0, result.Score, 0.000001); + } + // --- Pullback Confirmation Tests --- [TestMethod] @@ -664,10 +720,15 @@ namespace NT8.Core.Tests.Intelligence } private static StrategyIntent CreateIntent() + { + return CreateIntent(OrderSide.Buy); + } + + private static StrategyIntent CreateIntent(OrderSide side) { return new StrategyIntent( "ES", - OrderSide.Buy, + side, OrderType.Market, null, 8,