Skip to content

Reject unaffordable frozen all-in flat market entries at fill#88

Merged
luisleo526 merged 1 commit into
mainfrom
fix/frozen-flat-gap-reject
Jul 10, 2026
Merged

Reject unaffordable frozen all-in flat market entries at fill#88
luisleo526 merged 1 commit into
mainfrom
fix/frozen-flat-gap-reject

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

TradingView's broker DROPS (does not trim) a percent_of_equity=100, omitted-qty strategy.entry MARKET 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

  • TV-export census across 76 all-in strategies: ~74k reconstructed true-flat entries, zero over-slack admissions; rejected shorts fill at price-FAVORABLE gaps (discriminator = notional shortfall, not adverse gap sign).
  • Exemplar parity: TV 0/556 gap admissions vs engine 132/684; reject-and-cancel with re-entry only on fresh signals (all 7 next-bar re-entries coincide with signal refire).

Gates (author + independent fresh-context R7, both green)

  • RED discipline proven by stash-cycle: new suite fails 15/6 pre-fix; three repurposed legacy pins fail pre-fix; all green post-fix.
  • Full ctest 87/87 (86 baseline + new suite).
  • Corpus gate 252/252 ok — 239 excellent / 12 strong / 1 anomaly, baseline-identical.
  • Private validation corpus full sweep (412): 9 tiers UP / 0 DOWN, error inventory slug-identical to baseline; margin-factor, fx, slack-boundary, paired-close, and reversal sentinels all held.

🤖 Generated with Claude Code

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>
@luisleo526 luisleo526 merged commit 7a8fc3b into main Jul 10, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/frozen-flat-gap-reject branch July 10, 2026 17:53
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