Skip to content
All library documents

Implementing a 10% Stop-Loss Cooldown in a Backtest

Article BigQuant

Summary

This BigQuant example attempts to close a stock position after its price falls more than 10% below cost, then exclude that instrument from target holdings until a cooldown expires. It tracks expiration dates in a pool, removes expired entries each day, filters the daily target list, and applies the remaining targets on signal dates. The code also includes a separate market-wide risk signal that liquidates holdings and pauses trading briefly.

The document is framed as a report that the intended 14-day freeze did not work in a backtest, but it provides no diagnosis or test output explaining the failure. The implementation uses calendar days as an approximation for trading days, and the stop-loss exit is issued before the rebalance-date check while target-list rebalancing happens only on signal dates. These details may affect observed behavior and merit verification in the trading engine. The example does not provide performance evidence or establish that the cooldown operates as intended.

Key ideas

  • The code checks each held position for a loss exceeding 10% of its recorded cost and submits an order to close it.
  • Cooldown expiry is stored as a date and processed by removing instruments whose expiry has arrived.
  • Instruments in the cooldown pool are removed from the target list before rebalancing.
  • The stated 14-day period is implemented as calendar days, which may differ from 14 trading sessions.
  • The page reports a backtest failure but does not explain its cause or show validation results.

Tags

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