Reject unaffordable frozen all-in flat market entries at fill#88
Merged
Conversation
TradingView's broker DROPS (does not trim) a percent_of_equity=100,
omitted-qty strategy.entry MARKET order that is placed true-flat, is
still flat at fill, carries zero opening commission, and whose frozen
signal-close quantity costs more at the fill price than the sizing
equity plus one lot of slack. The engine previously admitted every such
fill at the sizing notional ("undeclinable"), opening over-notional
positions TV never takes.
The rule is direction-symmetric and mutually disjoint with the two
existing frozen all-in branches: commissioned overage keeps the
entry-bar affordability trim (margin-call row), and sub-lot overage
keeps filling and holding (exemption). The placement flag
opening_affordability_exemption_candidate is widened to both sides with
the direction-appropriate margin term; its long-only affordability
consumer re-checks is_long and margin_long, so its semantics are
unchanged.
Evidence: TV-export census across 76 all-in strategies (~74k
reconstructed true-flat entries, zero over-slack admissions; rejected
shorts fill at price-FAVORABLE gaps, pinning the discriminator as
notional shortfall, not adverse gap sign); exemplar parity TV 0/556
gap admissions vs engine 132/684, all reject-and-cancel with re-entry
only on fresh signals.
Tests: new test_frozen_flat_gap_reject (short-side REDs, no-trim-rows,
dangling-exit, within-slack/pct!=100/gap-down/commissioned guards);
three prior unlimited-gap-admission pins repurposed to the rejection;
stale "margin is never checked at fill" comments narrowed to their
explicit-qty / pct<100 evidence base.
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.
What
TradingView's broker DROPS (does not trim) a
percent_of_equity=100, omitted-qtystrategy.entryMARKET order that is placed true-flat, still flat at fill, carries zero opening commission, and whose frozen signal-close quantity costs more at the fill price than sizing equity + one lot of slack. The engine previously admitted every such fill at the sizing notional, opening over-notional positions TV never takes.Direction-symmetric; mutually disjoint with the two existing frozen all-in branches (commissioned overage → entry-bar trim; sub-lot overage → fill and hold). Placement flag widened to both sides with the direction-appropriate margin term; the long-only KI-61 consumer re-checks
is_long/margin_long, so its semantics are unchanged (pinned by existing tests).Evidence
Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code