Skip to content

Reconcile layered exits and corpus warmup metadata#62

Merged
luisleo526 merged 2 commits into
mainfrom
campaign/layered-exit-reconcile
Jul 5, 2026
Merged

Reconcile layered exits and corpus warmup metadata#62
luisleo526 merged 2 commits into
mainfrom
campaign/layered-exit-reconcile

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

Summary

  • reconcile layered strategy.exit reservations when a matching entry opens from flat
  • add engine-side state to defer and reconcile post-entry exit reservations
  • update validation corpus warmup metadata for the 4EMA stack probe

Validation

  • cmake build / ctest / JOBS=8 run_corpus.sh completed in campaign R7 (recorded in scraper progress notes)
  • corpus verification currently reports 230 excellent, 21 strong, 0 moderate, 0 weak, 0 minimal, 1 anomaly

luisleo526 and others added 2 commits July 5, 2026 14:26
…m flat

Layered strategy.exit legs (a qty_percent<100 partial + a default/100% sibling
on the same from_entry) armed on the entry-signal bar while the strategy.entry
market order is still pending — position FLAT — both stored qty=NaN, because
compute_exit_reserved_qty defers reservation when the position is flat and there
was no fill-time reconciliation. At fill the 100% leg then closed the ENTIRE
position instead of the remaining half (the engine emitted one trade with 2x the
qty where TradingView emits two legs).

On the FLAT->open entry fill, reconcile the deferred exit reservations for the
from_entry group: only when it has >=2 pending exit legs and at least one is a
partial, reserve each leg's floored percent slice in arm order and give the 100%
sibling the remainder, freezing an explicit per-leg qty so each closes a fixed
amount regardless of fill order — mirroring how TradingView binds each bracket
leg to a slice of the entry. Lone brackets and pure 100% OCA TP/SL pairs are
untouched (stay qty=NaN -> full remaining close).

Corpus unchanged (excellent=229, ctest 78/78); fixes the 2x over-close on
scale-out-on-entry-bar strategies.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013tuvZmenDcKuPu8LVqfqag
@luisleo526 luisleo526 merged commit 3f06004 into main Jul 5, 2026
5 checks passed
@luisleo526 luisleo526 deleted the campaign/layered-exit-reconcile branch July 5, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant