Skip to content
All library documents

Why Uncanceled Orders Can Cause Repeated Backtest Fills

Article vn.py community

Summary

This forum exchange explains why a strategy may show several long or short closing trades instead of one apparent exit. The proposed cause is that the strategy submitted multiple sell orders with distinct order IDs and left them active. When later market data met their execution conditions, multiple pending orders could fill, producing repeated closes.

The reply explains that orders remain active until they are canceled, both in the backtest simulation and at the exchange. If an earlier order is no longer needed when the strategy submits a new one, it should be canceled; a cancel-all operation is mentioned as a simple way to clear orders previously sent by the strategy. The discussion is operational guidance rather than a systematic treatment of order management. It does not detail exchange-specific cancellation behavior, partial fills, race conditions, or how to track each order’s status, so those details may require separate handling in a live system.

Key ideas

  • Distinct pending orders can produce multiple fills when market conditions later satisfy them.
  • A submitted order generally remains active until it is filled or canceled.
  • Backtests may model the persistence of orders similarly to live trading.
  • Cancel orders that are no longer relevant before issuing replacements.
  • The exchange and strategy framework may affect the finer details of cancellation behavior.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.