ENGINEERING NOTESREPRODUCIBLE FINDINGS / EXPLICIT LIMITS PORTFOLIO

CASE 02 / SIMULATION INTEGRITY

When the opening price
crosses the stop.

A missing input let our simulator cap a gap loss at the requested stop. Supplying the opening quote changed the synthetic result from −1 R to −3 R—and made the assumption visible.

Reviewed
10 September 2026
System
Our OHLC fill model
Method
Python · deterministic replay
Finding
Execution-model defect

SYNTHETIC INPUT

100 → 85

Entry 100 · stop 95 · next open 85

WITHOUT OPENING QUOTE

−1.00 R

Assumed exit at the requested stop

WITH OPENING QUOTE

−3.00 R

Modeled exit at the available open

01

A stop became an assumed fill

The simulator walked each candle's high, low and close to resolve targets, stops and timeouts. When a stop was touched, it priced the exit at that stop. But the next candle could open beyond the threshold. Without an opening-price input, the model could turn an adverse gap into a neatly bounded loss.

The defect was in our simulator's contract. A configured stop describes a trigger; it does not establish an available execution price. Investor.gov explains that a stop order's execution can differ from its stop price. That reference supplies the general distinction, not validation of our particular market data or fill assumptions.

The first quote in a candle is ordered evidence. Its later high and low are not.

02

One candle is enough

  1. Open the gap fixture with entry 100, stop 95 and next opening price 85. Spread is zero to isolate the defect.
  2. Run the comparison. The old rule exits at 95. The corrected opening-aware rule exits at 85.
  3. Move the opening quote to 95 or higher. The reduced fixture assumes a later stop touch, so an opening gap no longer worsens that stop fill.
REPRODUCED AGAINST THE REVIEWED PURE FILL FUNCTION
PropertyOpening omittedOpening supplied
Initial risk distance100 − 95 = 5100 − 95 = 5
Modeled exit9585
Return / initial risk(95 − 100) / 5(85 − 100) / 5
Result−1.00 R−3.00 R

This is an invented arithmetic example, checked against the repository's isolated fill function. It is not a real position or a measured loss. The public interactive lab implements a smaller comparison, not the full simulator.

03

Use the open before the extrema

The fill function accepts an optional opening-price series. Its backtest and forward-evaluation callers now supply candle opens. For a long position, an opening quote at or below the active stop takes that opening quote as the modeled exit. The short path is symmetric. A target reached at the open fills at the target, without inventing favorable price improvement.

LONG-POSITION LOGICREDUCED EXCERPT
# Previous intrabar assumption:
if low <= stop:
    exit_price = stop

# Opening-aware sequence:
opening_bid = opening_proxy - spread / 2
if opening_bid <= active_stop:
    exit_price = opening_bid
elif opening_bid >= target:
    exit_price = target
else:
    evaluate_intrabar_barriers()

The quote basis also matters. Under this model's midpoint-proxy convention, a long entry uses proxy plus half-spread and its exit uses proxy minus half-spread. Short positions use the reverse sides. The same convention applies to barrier touches and breakeven activation, so a displayed midpoint touching a target does not automatically imply an executable fill.

After the open, OHLC cannot reveal the order of the extremes. The simulator checks an already-active stop before moving it to breakeven. If the opening quote itself activates breakeven, that event is known to precede the later extremes. These are explicit conservative ordering rules, not a reconstruction of ticks.

04

Check the accounting path, too

A helper fix is insufficient if its callers omit the new input or downstream metrics still clamp losses. The regression suite covers both the fill function and its integration with simulated returns. The tests load reviewed functions with synthetic inputs, without starting broker clients.

  • Long and short stop gaps can lose more than one initial risk unit. Gap fills use the executable side of the spread.
  • An opening stop precedes a later rebound; an opening target precedes later adverse extremes and receives no assumed improvement.
  • Gaps through a previously moved breakeven stop still lose money. Opening-time activation and ambiguous intrabar activation are separate cases.
  • Normal opens preserve previous nongap results. Missing opens remain compatible but explicitly cannot model gaps; short or nonfinite opening series are rejected.
  • Both simulation arms pass their opening data through, and risk-weighted returns retain losses larger than −1 R.

The public fixture isolates the default gap example. It does not represent the full coverage of the private execution suite, and no historical test total is presented as a live test counter.

05

A better model with stated limits

The change removes one favorable execution assumption. It does not establish a profitable strategy or a complete execution simulator. Existing experiments need a clearly labeled replay before results produced under different fill conventions can be compared.

MATERIAL LIMITS

The input source may contain bid candles rather than true midpoint candles; that basis still needs normalization. Fixed spreads, opening quotes and OHLC do not describe order-book depth, queue priority, partial fills, additional slippage, broker rejection, commissions or swaps. Opening-price execution remains a modeling assumption. A conservative bar-order rule can bound one ambiguity while leaving other uncertainties unresolved.

For simulation, data-platform and reliability roles, the engineering value is the chain of evidence: identify a missing input, state an ordering contract, update every caller, verify adverse outcomes and keep an observable result separate from an assumption. The repair makes the model more inspectable, even when it makes the result worse.

PRIMARY REFERENCE & PUBLIC ARTIFACT

  1. Investor.gov: Stop Order — stop triggers and execution-price uncertainty.
  2. SEC investor bulletin on stop orders — execution can deviate from the trigger price.
  3. Interactive synthetic gap fixture and offline reproduction — reduced, inspectable public examples.
RELATED CASE / PROTOCOL INTEGRITYTwo trust checks before an event counts.