chore: checkpoint remaining pre-gate worktree changes

- governance: stage v7.0 review prompts, run book, roadmap/current-status/decision updates, and sprint board state

- adapters: capture DASH/trailing-drawdown/state-telemetry strategy work already present in the worktree

- tools: capture dashboard console/KPI parser updates, logtriage notes, and runnersweep output

Build: previously clean | Tests: previously 511 passing | Includes all open staged files
This commit is contained in:
2026-08-21 14:53:15 -04:00
parent 28c30bca82
commit d84949caa3
31 changed files with 4844 additions and 142 deletions

View File

@@ -0,0 +1,130 @@
# TASK: GAP-054 — Auto-breakeven destroys the runner's trailing stop
# Staged: 2026-08-18 (v7.0 review, Finding 6)
# ACCEPTED: 2026-08-19 — see DEC-20260818-18. Option 0 approved. Runner-scoping
# sub-question resolved to "unconditional skip, no new flag" (see decision entry).
# Sprint: Stage 2 — Runner. BLOCKS RUNNER-001.
# Owner: Kilocode (implementation)
# ─────────────────────────────────────────────────────────────────
## THE DEFECT
In NinjaScript, `SetStopLoss()` and `SetTrailStop()` are MUTUALLY EXCLUSIVE per
signal name — the later call replaces the earlier exit order for that signal.
At entry, `SubmitOrderToNT8()` (NT8StrategyBase.cs ~2178-2196) arms the runner
correctly:
SetStopLoss (_runnerSignalName, Ticks, intent.StopTicks, false)
SetTrailStop(_runnerSignalName, Ticks, RunnerTrailTicks, false) // wins
EnterLong/EnterShort(runnerQty, _runnerSignalName)
Then in `OnBarUpdate()` (~797-804):
if (EnableAutoBreakeven && !_breakevenMoved && profitTicks >= BreakevenTriggerTicks)
{
SetStopLoss(_runnerSignalName, CalculationMode.Price, bePrice, false);
_breakevenMoved = true;
}
That `SetStopLoss` call REPLACES the live trailing stop with a static stop at
entry + BreakevenOffsetTicks. The runner never trails again for that trade.
The comment four lines below correctly warns against re-calling SetTrailStop
here (it would reset the anchor to bar-close price — real defect, 2026-04-13).
That warning is still valid. The SetStopLoss call above it was not recognised
as doing worse.
## RUNTIME PROOF — all four broker-confirmed trades
| Trade | Session log line | Profit at BE | 12t trail would sit | Stop actually went |
|-------|-----------------------------------------------------------|--------------|---------------------|--------------------|
| 08-07 | BREAKEVEN runner stop -> 29826.00 profit=28ticks | +28t | +16t | +1t |
| 08-10 | BREAKEVEN runner stop -> 29848.50 profit=25ticks | +25t | +13t | +1t |
| 08-16 | BREAKEVEN runner stop -> 30200.08 profit=24ticks | +24t | +12t | +1t |
| 08-17 | BREAKEVEN runner stop -> 30271.00 profit=26ticks | +26t | +14t | +1t |
The breakeven action moves the stop BACKWARDS — it gives back 11-15 ticks of
already-locked profit and then freezes. Conservative floor estimate: the runner
would have banked 55 ticks (~$275 gross / ~$252 net) instead of $25 / $1.96.
## READ-FIRST — do not start coding until you have confirmed all of these
1. Read `NT8StrategyBase.cs` around lines 785-830 and 2170-2205 in full.
2. Confirm from NinjaTrader's own documentation that SetStopLoss and
SetTrailStop are mutually exclusive per signal name. Cite the doc page in
your writeback. If NinjaTrader documents different behaviour, STOP and
report — the whole task premise depends on this.
3. Confirm `_runnerActive`, `_breakevenMoved` and `_runnerSignalName` lifecycle:
where each is set, cleared, and read.
## THE CHANGE — Option 0 (APPROVED — DEC-20260818-18, 2026-08-19)
Stop applying auto-breakeven to the RUNNER leg. A trailing stop already provides
monotonically improving protection and does it better at every point.
- In the `OnBarUpdate` breakeven block, do NOT call `SetStopLoss()` on
`_runnerSignalName`.
- Do NOT call `SetTrailStop()` there either — the existing warning stands.
- `EnableAutoBreakeven`, `BreakevenTriggerTicks` and `BreakevenOffsetTicks`
must remain as parameters and must continue to work unchanged for the
scaler leg. RESOLVED (DEC-20260818-18, 2026-08-19): skip breakeven on the
runner leg unconditionally — do NOT add a new `EnableRunnerBreakeven` flag
or any other toggle. If `_runnerSignalName` is the leg in question, the
breakeven block simply does not act on it, full stop.
- Keep the `BREAKEVEN ...` FileLog line only if it still describes something
that happened. If the block no longer acts, remove the log line rather than
logging a no-op.
DO NOT change: scaler leg stop/target handling, `intent.StopTicks`, the dynamic
ATR stop, sizing, risk validation, or order submission ordering.
## SECONDARY DEFECTS IN THE SAME BLOCK — fix only if Option 0 leaves the block live
- `entryPrice` is `Position.AveragePrice` — the BLENDED average across scaler
and runner legs, not the runner's own fill. On 2026-08-16 this produced a
breakeven price of 30200.08, which is not a valid NQ price (tick 0.25).
If any breakeven logic survives, it must use the runner leg's own entry and
must round to `TickSize`.
- `Calculate = OnBarClose` means `BreakevenTriggerTicks = 20` actually fires at
24-28 ticks. Document this in the parameter's `Description` attribute so the
value stops meaning something it does not mean.
## TESTS (required)
Add to `tests/NT8.Core.Tests/` or `tests/NT8.Integration.Tests/`:
1. A regression test asserting that, for a runner signal name, no `SetStopLoss`
call is issued after a `SetTrailStop` has been issued for that same signal.
Use the existing `MockNT8OrderAdapter` / recording-adapter pattern; if no
seam exists to observe these calls, say so explicitly and propose the
smallest seam rather than fabricating coverage (GAP-022 precedent).
2. A test asserting the scaler leg's stop/target behaviour is unchanged.
3. If any breakeven logic survives: a test that the breakeven price is a valid
multiple of `TickSize`, and that it derives from the runner's entry.
## VALIDATION (operator, after deploy + manual NinjaScript compile)
- SIM/replay only — NOT the live frozen account — until this passes.
- Take one SIM trade that reaches +25 ticks or more. Confirm NO
`BREAKEVEN runner stop ->` line appears for the runner.
- Confirm the runner's exit is materially better than entry + 1 tick, and that
the exit reason in the NT8 execution grid reads as a trail stop, not a
fixed stop.
- Confirm the scaler leg still exits at its profit target unchanged.
## SEQUENCING — IMPORTANT
This task BLOCKS RUNNER-001 (`tools/runnersweep`). Sweeping
breakeven-trigger x trail-distance against a runner whose trail is disabled
would return a trail axis with no effect and a confident, meaningless
recommendation. Fix this first, then sweep.
It also supersedes the framing in DEC-20260810-02 and DEC-20260815-01, both of
which describe this as a parameter-placement problem. Record a superseding
decision entry when the option is chosen.
## GOVERNANCE
Track as [GAP-054] in SPRINT_BOARD.md. Add a decisions.md entry recording the
option chosen, the NinjaTrader documentation citation, and the expected effect.
Reference: NT8_SDK_Master_Document_v7.0 Finding 6, Sections 4.8 and 9.5 (P2-0).