Skip to content

fix(orders): defer process_orders_on_close market entry off the entry bar#51

Merged
luisleo526 merged 1 commit into
mainfrom
fix/pooc-no-samebar-bias-exit
Jun 30, 2026
Merged

fix(orders): defer process_orders_on_close market entry off the entry bar#51
luisleo526 merged 1 commit into
mainfrom
fix/pooc-no-samebar-bias-exit

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

Problem

Under process_orders_on_close, strategy.entry market orders were filled immediately at the bar close (to keep strategy.position_avg_price correct for a following strategy.exit). That made a same-bar bias-exit fire on the entry bar, producing zero-duration trades TradingView never emits: TV processes the market entry on close, then evaluates exits on the next bar (calc-then-fill).

Fix

Remove the immediate same-bar execute_market_entry for plain market entries under POOC; the order goes through the normal queue and the exit is evaluated the following bar, matching TV's ordering. Priced (limit/stop) entries are unaffected (the existing POOC corpus probes use limit entries → unchanged).

Validation

result
officialjackofalltrades-quant-synthesis 23 zero-duration trades → 0; strict entry|exit match 65.0% → 72.8%, price-exact 96.9% → 100%
corpus 251 excellent / 1 anomaly / 0 fail (held; POOC removal not load-bearing for corpus tiers)
ctest 76/76 incl. test_pooc_exit_not_triggered_on_entry_bar (reverting the fix → test fails)
check_c_abi_runtime.py exit 0

Rebased on #50; re-validated the combined tree (legalrice trail_price + this POOC fix): corpus 251/1, both strategies hold.

🤖 Generated with Claude Code

… bar

Under process_orders_on_close, strategy.entry market orders were filled
immediately at the bar close (to keep strategy.position_avg_price correct for a
following strategy.exit). But that made a same-bar bias-exit fire on the entry
bar, producing zero-duration trades TradingView never emits: TV processes the
market entry on close, then evaluates exits on the NEXT bar.

Remove the immediate same-bar execute_market_entry for plain market entries
under POOC; the order goes through the normal queue and the exit is evaluated
the following bar, matching TV's calc-then-fill ordering. Priced (limit/stop)
entries are unaffected.

officialjackofalltrades-quant-synthesis: 23 zero-duration trades -> 0; strict
entry|exit match 65.0%->72.8%, price-exact 96.9%->100%. Corpus held 251
excellent / 1 anomaly; ctest 76/76 incl. test_pooc_exit_not_triggered_on_entry_bar
(reverting the fix makes it fail). No new C-ABI export.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@luisleo526 luisleo526 merged commit 902a95b into main Jun 30, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/pooc-no-samebar-bias-exit branch June 30, 2026 13:35
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