Exit manager: never manage a fill with zero post-entry bars

Live 2026-07-06: every fresh entry was market-exited seconds after
filling (ELAB round-tripped in 3s, SEER in 77s, PLUG in 85s) — all
logged as exit_trail. Root cause: seconds after a fill there is no
completed minute bar with timestamp >= the fill time, and _bars_since's
empty result fell back to the WHOLE DAY's bars, so manage_live's
high-water included the pre-entry HOD and the trail read as already
breached on any name trading off its high. The whole-day fallback is
removed: with no post-entry bars the manager now leaves the position
alone (the bracket's initial stop is the protection) until the first
post-entry bar lands. Regression test verified to fail on the old code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
momentum devandClaude Opus 4.8 committed 2026-07-06 12:25:06 -04:00
1 parent 857c64ea48
commit 842b54c802
2 files changed
+38 -1

No files matched your search

+7 -1
View File
@@ -311,7 +311,13 @@ class LiveExitManager:
since = _bars_since(bars, tr.entry_ts)
if len(since) == 0:
since = bars
# no completed bar since the entry fill yet: the old whole-day fallback
# fed manage_live PRE-entry bars, so its high-water included the day's
# HOD and the trail read as already breached on any name trading off
# its high — instantly market-exiting fresh entries (3-second round
# trips on 2026-07-06). The bracket's initial stop already protects
# the position; do nothing until the first post-entry bar lands.
continue
d = manage_live(tr.entry_price, tr.init_stop, since, self.cfg, tr.scaled)
# (1) first-red: exit the whole position now