Skip to content

Freeze script-visible position through a same-bar POOC close#94

Merged
luisleo526 merged 1 commit into
mainfrom
fix/pooc-position-visibility
Jul 11, 2026
Merged

Freeze script-visible position through a same-bar POOC close#94
luisleo526 merged 1 commit into
mainfrom
fix/pooc-position-visibility

Conversation

@luisleo526

Copy link
Copy Markdown
Collaborator

What

Under process_orders_on_close=true, an in-line strategy.close/close_all fill made strategy.position_size read the post-close value for the rest of that bar's script execution — so flat-gated entries later in the same execution were placed and filled. TV keeps the pre-close view until the next bar and never places them.

Pinned by a committed clean-room probe: TV's 1,277 entries equal the blocked-reentry prediction exactly (0/1,278 on exit bars) vs the engine's 399/1,381 exit-bar re-entries; the same probe pinned the daily lookahead pivot and the var-confirm machine as already TV-exact (1,245/1,245) — the visibility gate is the only divergence in the class.

Mechanism: freeze the pre-close {side, qty} when an in-line POOC close fills (immediately=true excluded), report it through signed_position_size() — zero engine-internal callers, broker path byte-identical — cleared at the bar's flush with defensive resets at run-init/coof-recompute. The corpus-refuted cancel-extension is untouched; reversals still flip. Direct-field reads not frozen (documented residual pending a codegen accessor-routing pin).

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

  • REDs by stash-cycle: 9/5 pre-fix (flat-gate sees 0 mid-bar, re-enters) → 14/14 post; full ctest 92/92.
  • Corpus 252/252 — 240/11/1 zero movement; POOC probe family exact (same-id probe 732=732).
  • Private sweeps: targeted 10/10 and full 412 both 0 up / 0 down; POOC sentinel byte-identical.

🤖 Generated with Claude Code

Under process_orders_on_close=true, a strategy.close/close_all filling
in-line mid-execution made strategy.position_size read the post-close
value for the rest of that bar's script execution, so flat-gated
entries later in the same execution were placed and filled — TV keeps
the pre-close view until the next bar and never places them.

Pinned by a clean-room probe (committed with its TV export): TV's
1,277 entries equal the blocked-reentry prediction exactly, with zero
entries on exit bars, while the engine re-entered on 399 of 1,381; the
same probe pinned the daily lookahead pivot value and the var-confirm
machine as already TV-exact (1,245/1,245), so the visibility gate is
the only divergence in this class.

Mechanism: the pre-close side and quantity are frozen when an in-line
POOC close fills (immediately=true excluded) and reported through
signed_position_size() — which has no engine-internal callers, so
broker behavior is byte-identical — until the bar's flush clears it,
with defensive resets at run-init and coof recompute. The refuted
cancel-extension is untouched; opposite-direction reversals (not
flat-gated) still flip. Direct-field reads (bare opentrades count,
position_avg_price value) are not frozen — documented residual pending
a codegen accessor-routing pin.

Corpus: 252/252, 240/11/1 zero movement; POOC probe family exact.
Private sweeps: targeted and full 412 both 0 up / 0 down.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@luisleo526 luisleo526 merged commit eaf5e97 into main Jul 11, 2026
5 checks passed
@luisleo526 luisleo526 deleted the fix/pooc-position-visibility branch July 11, 2026 10:18
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