Freeze script-visible position through a same-bar POOC close#94
Merged
Conversation
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>
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
Under
process_orders_on_close=true, an in-linestrategy.close/close_allfill madestrategy.position_sizeread 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=trueexcluded), report it throughsigned_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)
🤖 Generated with Claude Code