Gate stop-entry fills at the open under margin; decline insolvent frozen opens cleanly#99
Merged
Merged
Conversation
…zen opens cleanly Two probe-pinned admission fixes: KI-62 margin gate: under active margin simulation TradingView checks every stop-entry fill at the fill moment against the fill bar's OPEN price (decline iff qty * open * margin% > available equity, side-symmetric, intrabar extremes ignored) and CANCELS declined orders outright — arm-once entries die silently while Pine-level reissue revives them, so re-posted shorts fill at the first bar whose open crosses the stop. Pinned by pf-probe-ki62-margin-deferral at 99.17% (this branch scores 99.9%, 1,436/1,438); cross-confirmed on over-allocated fixed-qty stops by pf-probe-ki65-dual-entry-precedence (canonical 93.8 -> 100.0). Declined fills bypass the one-shot 1x-long affordability trim; MARKET/LIMIT/RAW/exit orders and margin=0 paths are untouched by construction. KI-72: a frozen percent-of-equity order sized at non-positive equity previously slipped past the sizing-equity guard as a negative quantity and opened a corrupt negative-qty position (negative trade rows, blown cumulative PnL, healthy internal accounting). Such opens now decline cleanly and symmetrically, with declined-reversal close-legs suppressed via the existing ledger-restore path. Gates: new suites test_margin_stop_admission + test_short_reversal_emission (REDs stash-proven); ctest 98/98; two expectation flips justified in-test by the ki65 evidence (over-allocated stop declines; the limit sibling keeps admit+trim); corpus 252 = 240/11/1 exact; byte-identical sentinels (lukeborgerding, freddycandle/taro, KI-34 set, keepscratch/coof probes, margin=0 activation probe 2,410/2,410); pct=100 cohort zero DOWNs; full 412-slug private sweep 2 up / 0 down (waranyutrkm-asian-box weak->strong 99.7, ahtisham weak->strong 99.8; inside-day anomaly 72.5 -> 100.0). Known unpinned cells (recorded): over-allocated FIXED-qty stops (ki65- evidenced, no dedicated probe cell); stop-entry reversal admission uses pre-close realized-only equity (theoretical over-decline on profitable reversals); frozen qty exactly 0 declines (was fill-price refloor). 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.
Summary
Two probe-pinned admission fixes (batch-4 clean-room TV probes):
KI-62 margin gate. Under active margin simulation TradingView checks every stop-entry fill at the fill moment against the fill bar's open (decline iff
qty * open * margin% > available equity, side-symmetric; intrabar extremes ignored) and cancels declined orders outright — arm-once entries die silently while Pine-level reissue revives them, so re-posted shorts fill at the first bar whose open crosses the stop. Pinned at 99.17% on a 6-cell dedicated probe (this branch scores 99.9%, 1,436/1,438); independently cross-confirmed on over-allocated fixed-qty stops by a second probe (canonical 93.8 → 100.0). Declined fills bypass the 1×-long affordability trim; MARKET/LIMIT/RAW/exit orders and margin=0 paths untouched by construction (byte-identical sentinels prove it).KI-72. A frozen percent-of-equity order sized at non-positive equity slipped past the sizing-equity guard as a negative quantity and opened a corrupt negative-qty position (negative trade rows, blown cumulative PnL, healthy internal sums). Such opens now decline cleanly and symmetrically, with declined-reversal close-legs suppressed via the existing ledger-restore path.
Verification
test_margin_stop_admission+test_short_reversal_emission; REDs stash-proven (5 suites RED on base). ctest 98/98.Known unpinned cells (recorded, non-blocking)
🤖 Generated with Claude Code