Backtest fills at the close or next open
A close-based signal becomes known after the bar closes. A next-open market model fills at the open of the following price bar. To model a close fill credibly, use a signal available before the applicable close-order deadline or label the close convention as a simulation assumption. Backtrader market order timing · LEAN bar time and availability
Compare one fill at a time
Assume one buy signal when the close is 100. The next bar opens at 104. Use a fixed later exit at 110 for both experiments and zero fees.
| Fill convention | Entry | Exit | Profit per unit |
|---|---|---|---|
| Signal-bar close | 100 | 110 | 10 |
| Next open | 104 | 110 | 6 |
The price gap alone accounts for the four-unit difference. An opposite gap can make the next-open fill cheaper. Run both variants on the same signals and log signal time, submission time, fill time and reference price. Drop or separately mark a signal on the last bar when there is no following open.
If a library indexes candles by start time, add the bar interval to get the earliest availability of the close. Check seams between subperiods and whether session breaks or holidays shift the next eligible open. Repeatable next-open fixture in three Python engines.