Decline unaffordable explicit-qty flat market entries at fill#92
Merged
Conversation
TradingView re-checks an explicit-qty MARKET entry at its fill: an entry placed true-flat whose quantity notional at the slipped next-open fill exceeds the placement-time equity is declined outright, with ZERO slack — commission plays no part in the predicate (fee-only overage is admitted and entry-bar-trimmed as before). The engine previously admitted every explicit entry that passed the signal-time gate, so all-in idioms (qty = equity/close, floored to step) opened phantom positions on every adverse one-tick gap. The signal-time gate is unchanged and remains the first line of defense; the new fill-time re-check is a disjoint branch scoped to explicit-qty (non-NaN) MARKET entries created flat with no same-bar paired close, margin-scaled, with the slipped-signal-close notional as a floor so process_orders_on_close and no-gap fills are structural no-ops. The frozen-default path (its own admission rules, one-lot slack) is intentionally not unified — its slack is pinned separately. Evidence: new clean-room probe (floor-quantized all-in, zero commission, 4,740 from-flat attempts across 13 months): TV admits 0 above-slack and 0 in-band overshoots vs 566 in-band rejects — decline iff fill notional exceeds equity, 99.94% concordance; exemplar strategy shows perfect 306/306 admit/decline separation and converges from moderate to excellent (pnl p90 22.65% -> 0.12%). Four legacy synthetic fixtures that asserted fill-then-trim/hold for this exact class are repurposed to the TV-pinned decline; the trim semantics they exercised remain pinned by the frozen-path and default-sized suites. 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
TV re-checks an explicit-qty MARKET entry at its fill: an entry placed true-flat whose quantity notional at the slipped next-open fill exceeds placement-time equity is declined outright, with zero slack — commission plays no part (fee-only overage is admitted and entry-bar-trimmed as before). The engine previously admitted every explicit entry that passed the signal-time gate, so all-in idioms (
qty = min(risk, equity/close)floored to step) opened phantom positions on every adverse one-tick gap.Implementation: disjoint fill-time branch scoped to explicit-qty (non-NaN) MARKET entries created flat with no same-bar paired close; margin-scaled arithmetic; the slipped-signal-close notional floors the threshold so
process_orders_on_closeand no-gap fills are structural no-ops. Signal-time gate unchanged. The frozen-default path (own rules, one-lot slack — pinned separately) is intentionally not unified.Evidence
Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code