[GAP-045/GAP-046]: risk envelope guards complete
- BasicRiskManager.cs: add sized per-position risk validation and startup validator - NT8StrategyBase.cs: fail fast on incoherent risk config and validate after sizing - BasicRiskManagerTests.cs: cover assertions, sized risk, property sweep, MNQ tables - docs/00-governance: record validation evidence and NQ SIM follow-up Build: clean | Tests: 535 passing; Core 446 passing | Deploy: backup 20260823_144817
This commit is contained in:
@@ -88,7 +88,9 @@ Use this file to record durable project decisions that affect implementation pat
|
||||
- **Decision (proposed, two parts):** **Decision 1 — resolve the collision.** Choose one of: (a) `MaxTradeRisk = $250`, making `MaxStopTicks=50` reachable and raising per-contract worst case 25%; (b) `MaxStopTicks = 40`, leaving nothing unreachable but tightening the stop relative to ATR on volatile days and raising stop-out rate; (c) validate on MNQ at $0.50/tick, where 50 ticks = $25 per contract, the collision disappears entirely and sizing becomes granular enough for `MaxContracts` to do real work. **Decision 2 — define the semantics.** State explicitly whether `MaxTradeRisk` is a per-contract stop-distance ceiling (what the code does today) or a per-position risk limit (what the name and the master document imply). If per-position, the Tier 1 check must move to after sizing or take an estimated quantity — a real ordering change that must not be made without this entry being accepted first. Independently of both, add startup assertions in the GAP-003 style for: `EnableTrailingDrawdown ⇒ AccountStartingBalance > 0`; `MaxStopTicks × tickValue ≤ MaxTradeRisk`; `MinContracts ≤ MaxContracts`; and a bound relating `MaxTradeRisk × MaxContracts` to `DailyLossLimit`.
|
||||
- **Consequences:** Either value change alters `ConfigHash` and requires a fresh freeze capture and a new `DEC-GATE3-CONFIG`. Option (c) is a larger strategic change than a parameter edit and interacts with the roadmap's instrument sequencing; it is also the only option that removes the class of problem rather than an instance of it. Until Decision 2 is answered, the system's true worst-case single-trade loss is undefined in the documentation and under-enforced in the code, which is the largest open drawdown exposure in the project.
|
||||
- **Related Files:** `src/NT8.Core/Risk/BasicRiskManager.cs`, `src/NT8.Core/Sizing/BasicPositionSizer.cs`, `src/NT8.Adapters/Strategies/NT8StrategyBase.cs`, `TASK_GAP045_GAP046_RISK_GUARDS_PROMPT.md`
|
||||
- **Action Required:** Both decisions made — see above. Execute `TASK_GAP045_GAP046_RISK_GUARDS_PROMPT.md` in full (Part 3 is now unblocked) on the current NQ configuration. Hold the MNQ instrument cutover itself for DEC-20260819-01's sequencing.
|
||||
- **Implementation Note (2026-08-23):** Executed `TASK_GAP045_GAP046_RISK_GUARDS_PROMPT.md` Parts 1-3 on the current NQ configuration without changing the traded instrument or retuning NQ values. Added `RiskEnvelopeValidator.ValidateStartupConfiguration()` and wired `NT8StrategyBase` startup to fail fast when: `EnableTrailingDrawdown=True` with `AccountStartingBalance<=0`; `MaxStopTicks * TickValue > MaxTradeRisk`; `MinContracts<1` or `MinContracts>MaxContracts`; or `MaxTradeRisk>DailyLossLimit`. Messages include the symbol and both conflicting values. GAP-048 had already split the nonconfigured trailing-drawdown reject reason to `TrailingDrawdownNotConfigured`, so no duplicate taxonomy change was needed. Confirmed MNQ exists at `$0.50` in both hardcoded tick-value tables; no table patch was needed. Implemented the approved per-position semantics by adding a sized `BasicRiskManager.ValidateOrder(..., candidateContracts)` overload and moving `NT8StrategyBase.ProcessStrategyIntent()` to calculate size before risk validation, then enforce `StopTicks * tickValue * Qty <= MaxTradeRisk` against the selected quantity. Existing `IRiskManager.ValidateOrder()` remains compatible and still validates one contract for older callers.
|
||||
- **Verification (2026-08-23):** Added tests for each startup assertion's fail/pass behavior, quantity-aware Tier 1 rejection, the old pre-quantity passing case now rejecting at two contracts, a bounded property-style sweep over declared ranges, and MNQ tick-value parity in both risk and sizing tables. `verify-build.bat` passed 535/535 tests (446 Core, 79 Integration, 10 Performance); `dotnet test tests\NT8.Core.Tests\NT8.Core.Tests.csproj --configuration Release --no-build --verbosity minimal` passed 446/446; `deployment\deploy-to-nt8.bat` completed with backup `20260823_144817` and noted `NinjaTrader.Custom.dll` was not present to invalidate.
|
||||
- **Action Required:** Manually compile in NinjaTrader. Validate on NQ before MNQ cutover: verify the misconfigured trailing-drawdown pair refuses startup, `MaxTradeRisk<=DailyLossLimit` is enforced, and a former 10:10-style high-ATR signal either sizes within `MaxTradeRisk` or rejects from the quantity-aware per-position check. Do not perform the MNQ cutover in this validation step.
|
||||
|
||||
### DEC-20260818-18
|
||||
- **ID:** DEC-20260818-18
|
||||
|
||||
Reference in New Issue
Block a user