# TASK: GAP-045 / GAP-046 — Risk-envelope coherence guards # Staged: 2026-08-18 (v7.0 review, Findings 2, 3, 4) # ACCEPTED: 2026-08-19 — see DEC-20260818-19 and DEC-20260819-01. Both operator # decisions made: (1) resolve collision via MNQ, (2) MaxTradeRisk is # per-position (total), not per-contract. Part 3 below is rewritten accordingly # and is now fully actionable. Per DEC-20260819-01, implement and validate # Parts 1-3 on the CURRENT NQ CONFIGURATION FIRST; the MNQ instrument cutover # itself is a separate follow-on step, not part of this task. # Sprint: Stage 0 — Unblock (P0-A2) + Stage 1 (P1-C) # Owner: Kilocode # ───────────────────────────────────────────────────────────────── ## CONTEXT — two live outages on 2026-08-18, both from parameter pairs that ## are individually valid and jointly impossible GAP-046, from 14:30 ET onward, 27 rejections: REJECT: reason=TrailingDrawdownBreach detail=EnableTrailingDrawdown=True but AccountStartingBalance is not configured Confirmed in settings_Simple_ORB_NT8_20260818_142340.txt: EnableTrailingDrawdown: True / AccountStartingBalance: $0.00 The guard behaviour is CORRECT. There is simply no startup assertion, so a configuration error becomes a silent all-day trading outage. GAP-045, at 10:10 ET, five valid Sell signals rejected: REJECT: reason=KillSwitch detail=Risk manager rejected: Trade risk too high: $225.00 `BasicRiskManager.CalculateTradeRisk()` returns `StopTicks * tickValue` with NO quantity term, evaluated BEFORE sizing. On NQ ($5.00/tick) `MaxTradeRisk=$200` caps the stop at 40 ticks, while `MaxStopTicks=50` (=$250) is configured. The top 20% of the ATR stop range is unreachable, and the days it excludes are the high-ATR days on which ORB expansions are largest. ## PART 1 — Startup assertions (Kilocode, no approval needed) Extend the GAP-003 pattern (`RiskPerTrade > MaxTradeRisk` throws at validation time with both values named). Add, in the same place and same style: A. `EnableTrailingDrawdown == true` MUST imply `AccountStartingBalance > 0`. B. `MaxStopTicks * tickValue(symbol) <= MaxTradeRisk`. C. `MinContracts <= MaxContracts` and `MinContracts >= 1`. D. RESOLVED (was gated on Part 3, now decided): under the per-position semantics adopted in DEC-20260818-19, `MaxTradeRisk` already represents worst-case single-trade dollar risk regardless of contract count. The assertion is `MaxTradeRisk <= DailyLossLimit` (NOT `MaxTradeRisk * MaxContracts <= DailyLossLimit` — that formula belonged to the old per-contract semantics and must not be used). Implement as a throw, same style as A-C. Each assertion must name BOTH values and the symbol in its message. Fail at startup, not at 10:10 on a breakout. ## PART 2 — Distinguish misconfiguration from a real breach `TrailingDrawdownBreach` currently covers both "the account breached its floor" and "you did not configure a floor." Add a distinct reject reason `TrailingDrawdownNotConfigured` for the second case so REJECT SUMMARY counts are meaningful. (This overlaps TASK_GAP048 — coordinate; do not duplicate.) ## PART 3 — RESOLVED 2026-08-19 (DEC-20260818-19, DEC-20260819-01) — now actionable Both decisions have been made by the operator. This part is no longer staged for approval — implement it, in this order, ON THE CURRENT NQ CONFIGURATION. Do not fold the MNQ instrument cutover itself into this task; that is DEC-20260819-01's separate follow-on step, staged after everything below is validated. Decision 1 (collision) → **(c) MNQ**, staged as its own later cutover. Nothing in this task changes the traded instrument. What this task DOES do now, in preparation: confirm MNQ is present and correctly valued in BOTH hardcoded tick-value tables (GAP-052 — `BasicRiskManager.GetTickValue` and `BasicPositionSizer.GetTickValue`). If MNQ is missing from either table, add it (tick size 0.25, tick value $0.50) as part of this task's Read-First verification — this does not require an operator decision, it's a data-table completeness fix blocking the already-decided cutover. Do NOT change the live NQ `MaxTradeRisk`/`MaxStopTicks` values as a workaround for the collision — the collision is being resolved by instrument, not by retuning NQ. Decision 2 (semantics) → **per-position (total)**, not per-contract. Implement the real ordering change now approved: `BasicRiskManager`'s Tier 1 check must move to AFTER `BasicPositionSizer` determines quantity, or must take an estimated/candidate quantity from the sizer, so the enforced inequality becomes `StopTicks * tickValue * Qty <= MaxTradeRisk` — replacing today's `StopTicks * tickValue <= MaxTradeRisk` with no `Qty` term. This is the ordering change the original entry said must not be made without approval; it is now approved. Read `BasicPositionSizer.CalculateFixedRisk` and `BasicRiskManager.ValidateOrder` together before touching either — get the call sequence right rather than bolting a Qty multiply onto the existing check in place, since the existing check runs before sizing today and that ordering is the actual defect. Resulting worst-case single-trade risk: `MaxTradeRisk` itself (not `MaxTradeRisk * MaxContracts`), matching Part 1 Assertion D above. This is a strict safety improvement over the previously-undefined $600 worst case. ## READ-FIRST - `src/NT8.Core/Risk/BasicRiskManager.cs` — `ValidateOrder`, `CalculateTradeRisk`, `GetTickValue` - `src/NT8.Core/Sizing/BasicPositionSizer.cs` — `CalculateFixedRisk`, `GetTickValue` (NOTE: there are TWO independent hardcoded tick-value tables — GAP-052. Do not add a third. Confirm MNQ is present and correct — tick size 0.25, tick value $0.50 — in BOTH tables; add it if missing per Part 3 Decision 1. Whether consolidating the two tables belongs in this task or its own is still open — flag it, don't decide it.) - `NT8StrategyBase.cs` — the trailing-drawdown monitor and where GAP-003's assertion currently lives ## TESTS (required) - Each assertion: violating pair throws with both values in the message; satisfying pair passes; disabled feature with an unset companion passes. - A property test over the declared `[Range]` bounds of MaxStopTicks, MaxTradeRisk, MaxContracts, MinContracts, RiskPerTrade and DailyLossLimit asserting that no allowed combination permits a single-trade loss above `MaxTradeRisk` (the now-defined per-position worst case). - A test asserting the Tier 1 check's new ordering: for a case where the old (pre-Qty) check would have passed but the new `Qty`-aware check must reject (e.g. sizer would pick 2 contracts and `StopTicks * tickValue * 2 > MaxTradeRisk`), confirm the trade IS rejected under the new logic. This is the regression test proving the ordering change actually closed GAP-050. - A test confirming MNQ resolves correctly in both `GetTickValue` tables. ## VALIDATION (operator) - Set `EnableTrailingDrawdown=True` with `AccountStartingBalance=0` and confirm the strategy refuses to start with a clear message, rather than running all day and rejecting every entry. - On NQ (current instrument, before cutover): confirm a signal that would have produced the 2026-08-18 10:10 ET rejection (`Trade risk too high: $225.00`) now either submits with a sizer-selected quantity that respects `MaxTradeRisk`, or is rejected with a reason that clearly reflects the per-position check rather than the old per-contract one. - Confirm `MaxTradeRisk <= DailyLossLimit` throws at startup when violated. - Do NOT validate the MNQ cutover itself here — that's DEC-20260819-01's separate step, after this task's NQ validation passes. ## GOVERNANCE Track as [GAP-045] and [GAP-046] in SPRINT_BOARD.md. decisions.md entries DEC-20260818-19 and DEC-20260819-01: accepted 2026-08-19. Reference: NT8_SDK_Master_Document_v7.0 Findings 2/3/4, Sections 5.3, 5.13, 9.3, 9.4.