Reconcile layered exits and corpus warmup metadata#62
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation