fix(engine): TV extrema positional windows + bracket lifecycle on declined reversals + 1x-long entry-fill margin chronology - #150
Merged
Merged
Conversation
…sals A declined in-position opposite MARKET reversal (the KI-54/KI-72 fill re-check declines — the tradeless reversal) cancels the live position's standing PRICED strategy.exit brackets on TradingView. The engine kept the original bracket live and stop-filled early, forking position state for days on every tradeless opposite signal. - KILL: the decline marks the position's standing priced brackets dormant — never the "__close__" close/close_all family, never stale exits bound to a not-yet-filled entry id (the #147 stale-exit family). - DORMANT: a dormant bracket stays in the book but never matches a fill (classify_order_eligibility Skip in the ordinary kernel; an apply-time mirror in the KI-60 COOF kernel, whose candidate set is pre-classified before any candidate is applied, so a mid-segment kill is invisible to classify there). - REVIVE-A: a fresh same-(id,from_entry) strategy.exit re-issue replaces the dormant bracket wholesale and arms the new call's prices (the ordinary replacement path — no new code). - REVIVE-B: a margin-call partial re-registers the surviving position's dormant brackets at their last-armed prices. - MC-CASCADE: when the margin-call event price already makes a revived full-percent default stop marketable, the entire remainder closes at that event price through the bracket's id on the slice bar. Derivation: 162/162 alive-at-breach episodes, 118/118 TV stop-skips, 19/19 revive-B exact-stop fills, 18/18 cascade fills at the event extreme; tape validation collapses the count mismatch to 0 with the whole suite green and the corpus byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ll, before same-bar intrabar exits TradingView evaluates the margin_long=100 opening-affordability check AT THE ENTRY FILL, chronologically before the same bar's intrabar exits. The #149 chronology hook (margin_call_slice_before_priced_exit) deliberately excluded 1x longs — compute_liquidation_price() is na there — so a same-bar priced exit filled the FULL position first and the end-of-bar one-shot opening event found the position already reduced or gone: the "Margin call" trim row (ordinary floor-before-4x restore, including the sub-lot one-contract fallback, filled at the RAW matched entry base — a pnl-0 row) was lost, and the equity fork cascaded through every later default-sized fill. The hook now routes the 1x-long class to an opening-slice helper that books the trim with process_margin_call's opening-affordability LONG branch arithmetic verbatim, then lets the triggering exit close the reduced remainder. The one-shot event is consumed only when a slice is actually booked. Unchanged byte-for-byte: bars where no same-bar priced exit fills (end-of-bar placement), POOC close fills, the scoped SHORT opening event (end-of-bar plus adverse-retry), the leveraged adverse-extreme chronology class, and every no-deficit evaluation. The deficit class: a lot-floored percent=100 reversal admitted on an uptick inside its floor remainder overshoots post-close equity by tick*(qty+closed) - remainder (sub-lot -> one-contract fallback); a commissioned explicit open reaches the same discontinuity through its entry fee. Tape validation collapses the count mismatch (the pure cascade family) to 0 with the whole suite green and the corpus byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Gate
pr-gatePASS — engine corpus zero regressions, scraped entering excellent+strong >= leaving.Verdict:
/Users/haoliangwen/code/pineforge-lab/pr-gate-verdict.json🤖 Generated with Claude Code