173 lines
10 KiB
Markdown
173 lines
10 KiB
Markdown
# TASK: GAP-054-FOLLOWUP — runner trailing stop did not protect a real trade's large favorable excursion
|
||
# Staged: 2026-09-02 (urgent — supersedes GAP-054's "IMPLEMENTED, UNVALIDATED" status with a real,
|
||
# adverse live-trade result from 2026-09-01)
|
||
# Sprint: Stage 2 — diagnostic-first; do not change order-submission behavior until root cause is confirmed
|
||
# 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. This is a live-money-relevant defect; nothing changes on the running
|
||
# strategy without an explicit operator decision on this task's findings first.
|
||
# ─────────────────────────────────────────────────────────────────
|
||
|
||
## THE DEFECT (why this is urgent)
|
||
|
||
GAP-054 (`DEC-20260818-18`, commit `28c30bc`) removed the auto-breakeven block in
|
||
`OnBarUpdate()` that was clobbering the runner's `SetTrailStop()`-managed exit
|
||
with a static `SetStopLoss()` call. That fix is confirmed present in current
|
||
source — `OnBarUpdate()`'s `_runnerActive` block (`NT8StrategyBase.cs` ~805-814)
|
||
is comment-only, no `SetStopLoss`/`SetTrailStop` call remains there. GAP-057
|
||
added a regression-test seam proving the same. SPRINT_BOARD.md has carried
|
||
GAP-054 as `🟡 IMPLEMENTED, UNVALIDATED — still blocks RUNNER-001` since
|
||
2026-08-21 because the required SIM validation (one trade reaching +25 ticks
|
||
or more, confirming the runner exits materially above entry rather than at a
|
||
static stop) never happened — NinjaTrader was closed at the time and it was
|
||
never revisited.
|
||
|
||
**A real SIM trade on 2026-09-01 (`SDK_NQ_R_254a84ddcec7`, session
|
||
`session_20260831_082648.log`, lines ~12806-12910) finally provided that
|
||
validation, and the result contradicts the intended fix:**
|
||
|
||
- Entered Long 1 NQ @ 29164.00 at 10:30:00.255 ET. `SetStopLoss` (39 ticks) and
|
||
`SetTrailStop` (12 ticks, `RunnerActivationMode=Auto` resolved
|
||
`Mode2RunnerOnly` since quantity=1) were both called at entry per
|
||
`SubmitOrderToNT8()`, in the correct order, per current source.
|
||
- Operator observed the position run to approximately **+$1200 unrealized**
|
||
(a Maximum Favorable Excursion of roughly 240+ ticks — nearly the entire
|
||
day's move) before this task was staged.
|
||
- Position closed flat at 12:30:47.070 ET. `PNL_UPDATE DayPnL=($200.76)`.
|
||
- **$200.76 is not an approximate number — it is the exact same P&L as a full
|
||
stop-out at the original 39-tick stop** (39 × $5.00/tick = $195.00 + ~$5.76
|
||
commission = $200.76), and matches a separate full-stop loss from a
|
||
different trade on 2026-08-27 (also exactly $200.76 on a 39-tick stop) to
|
||
the penny.
|
||
- If the 12-tick trailing stop had actually ratcheted up as the position ran
|
||
to +$1200, the exit should have locked in somewhere around +$1140 to
|
||
+$1200, not round-tripped all the way back through breakeven into what
|
||
looks like the original static stop distance.
|
||
|
||
This is the same *symptom* GAP-054 was built to fix — a huge MFE reduced to
|
||
a small/negative result because the runner's exit order behaved like a
|
||
static stop rather than a trail — but GAP-054's own fix is confirmed present
|
||
in source. Either (a) the fix does not address the actual mechanism at
|
||
NinjaTrader's order-management layer (as opposed to the `OnBarUpdate()`
|
||
clobbering it did fix), (b) `SetTrailStop()` is not attaching or updating on
|
||
the platform side for this account/instrument/mode for some other reason, or
|
||
(c) something not yet identified. **This task is diagnostic-first: do not
|
||
assume which of these it is.**
|
||
|
||
## WHY THIS IS INVISIBLE FROM THE FILE LOG (a compounding, separate gap)
|
||
|
||
No log line anywhere — for this trade, or any other trade this week —
|
||
confirms a stop or trail order actually attached, modified, or triggered on
|
||
the platform. `SetStopLoss`/`SetTrailStop` are native NinjaScript managed-order
|
||
calls; they do not route through this SDK's own `_executionAdapter`, which is
|
||
the only thing GAP-025 (`ORDER {signal} State=...` FileLog lines) covers.
|
||
GAP-025 is committed (`49bcd0b`) but its `ORDER` lines have never appeared in
|
||
any live session log checked this week — confirm during this task whether
|
||
GAP-025 was ever actually deployed to the running NT8 install (compare
|
||
`deployment/backups/` timestamps against session log dates), since its task
|
||
header specified commit-only and deploy is a separate manual operator step.
|
||
Even if GAP-025 is deployed, it may not help here: confirm whether NT8 names
|
||
platform-generated stop/trail orders with the `SDK_` prefix `OnOrderUpdate`
|
||
filters on, or something else — if something else, GAP-025's fix would not
|
||
make trail modifications visible regardless of deploy status, and that gap
|
||
needs its own follow-up.
|
||
|
||
## READ-FIRST
|
||
|
||
1. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~2296-2340 —
|
||
`SubmitOrderToNT8()`'s runner-leg block: `SetStopLoss`, then
|
||
`EnableATRTrailing`/`RunnerTrailTicks`-gated `SetTrailStop`, then
|
||
`EnterLong`/`EnterShort`. Confirm this is unchanged from what GAP-054's
|
||
own implementation note describes.
|
||
2. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~805-814 — the
|
||
`OnBarUpdate()` `_runnerActive` block GAP-054 made comment-only. Confirm
|
||
nothing re-added a call here since.
|
||
3. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1269-1345 —
|
||
`OnOrderUpdate`/`OnExecutionUpdate`, GAP-025's logging additions. Confirm
|
||
what order-name pattern `OnOrderUpdate` filters on, and whether a
|
||
NinjaScript-generated stop/trail order (as opposed to an SDK-submitted
|
||
entry order) would ever match it.
|
||
4. `deployment/deploy-to-nt8.bat` and `deployment/backups/` — establish
|
||
whether GAP-025 and GAP-054 are both actually present in the currently
|
||
*running* NT8 install, not just committed to source. `git log --oneline`
|
||
shows both commits (`28c30bc`, `49bcd0b`); that does not by itself prove
|
||
either reached the deployed DLL the 2026-09-01 trade actually ran against.
|
||
5. `session_20260831_082648.log` (device log directory) lines ~12795-12910 —
|
||
the full trade this task is investigating. Note there is no line of any
|
||
kind between the `FILL` at 10:30:00.255 and the `PNL_UPDATE ... Flat` at
|
||
12:30:47.070 — two hours of a live, materially profitable position with
|
||
zero intermediate log evidence of what its stop/trail was doing.
|
||
6. NinjaTrader's own installed API documentation
|
||
(`C:\Program Files\NinjaTrader 8\bin\NinjaTrader.Core.xml`, already cited
|
||
in `DEC-20260818-18`'s implementation note) for `SetTrailStop` — re-read
|
||
it specifically for any precondition, calculation-mode interaction, or
|
||
per-bar recalculation behavior that could cause a trail to silently
|
||
revert to its originally-set distance from the entry price rather than
|
||
the current high-water mark. `Calculate = OnBarClose` is noted elsewhere
|
||
in this codebase as an existing source of behavioral surprises for
|
||
related managed-order calls (see the `BreakevenTriggerTicks` note in
|
||
`DEC-20260818-18`) — check whether it interacts with `SetTrailStop`
|
||
similarly.
|
||
|
||
## THE INVESTIGATION (do this before proposing any fix)
|
||
|
||
1. Confirm actual deploy status of GAP-054 and GAP-025 against the DLL the
|
||
2026-09-01 trade ran under (build timestamp, `deployment/backups/`
|
||
manifest dates, or any other verifiable artifact — do not infer from
|
||
commit history alone).
|
||
2. If GAP-054 was deployed and the `OnBarUpdate()` clobbering is genuinely
|
||
absent from what ran this trade, the defect is somewhere else: either the
|
||
`SetTrailStop()` call at entry itself, NinjaTrader's own handling of it in
|
||
`Mode2RunnerOnly`/`RunnerActivationMode=Auto`, or an interaction with
|
||
another feature (`EnableATRTrailing=False` was confirmed active this
|
||
session, so this trade used the fixed-tick trail path with
|
||
`RunnerTrailTicks=12` — confirm this value from the settings export
|
||
matches what was actually passed).
|
||
3. If GAP-054 was NOT actually deployed (only committed), that alone would
|
||
fully explain this trade's behavior — the live DLL would still contain
|
||
the old breakeven-clobbering block. This is the simplest explanation and
|
||
must be ruled in or out first before looking anywhere else.
|
||
4. Determine what, if anything, can make a runner-leg stop/trail
|
||
modification or the *absence* of one visible in `FileLog` going forward,
|
||
so the next occurrence doesn't require inferring from PnL math again.
|
||
`NT8StrategyBase` already exposes `OnOrderUpdate`/`OnExecutionUpdate`
|
||
(GAP-025) — determine whether extending its order-name filter (or adding
|
||
a distinct log line at the point `SetTrailStop`/`SetStopLoss` are called,
|
||
which is production code but purely additive logging, zero behavior
|
||
change) would close this gap, and propose the smallest change that would.
|
||
Do not implement it as part of this task without operator sign-off if it
|
||
requires touching the same lines GAP-057's regression seam protects —
|
||
flag the tension between "add visibility here" and GAP-057's existing
|
||
test asserting no `SetStopLoss` call appears after `SetTrailStop` in that
|
||
block, and confirm any logging addition does not become a second call
|
||
that trips it.
|
||
|
||
## DO NOT
|
||
|
||
- Do not change order-submission, sizing, or risk logic based on a
|
||
hypothesis alone — this task's deliverable is a confirmed root cause and a
|
||
proposed fix for operator decision, not a live behavior change.
|
||
- Do not deploy anything as part of this task, regardless of what is found.
|
||
- Do not modify `SetStopLoss`/`SetTrailStop` call sites without first
|
||
confirming whether GAP-054/GAP-025 are actually deployed — fixing a defect
|
||
that turns out to be "the fix was never deployed" would be solving the
|
||
wrong problem.
|
||
|
||
## VALIDATION (operator, after root cause is confirmed and a fix, if any, is proposed)
|
||
|
||
Whatever the fix turns out to be, it must be validated the way GAP-054 always
|
||
required and never got: one real SIM trade reaching a large favorable
|
||
excursion (ideally replicating today's scale, not just the original +25-tick
|
||
threshold), with the exit price/PnL confirming the trail actually ratcheted
|
||
rather than reverting to the original stop distance — this time with log
|
||
evidence, not PnL-math inference, proving it.
|
||
|
||
## GOVERNANCE
|
||
|
||
Track as **GAP-054-FOLLOWUP** in `SPRINT_BOARD.md`, directly under the
|
||
existing GAP-054 entry (do not create a new top-level section — this is the
|
||
validation GAP-054 was always waiting on, now with an adverse real-world
|
||
result instead of a pending checkbox). Reference `DEC-20260818-18` (original
|
||
GAP-054 decision) and the new decision entry
|
||
(`DEC-20260902-01`) in the commit and in `decisions.md`.
|