Skip to content
All library documents

A Price-Threshold Grid Strategy with a Persistent Order Queue

Article BigQuant

Summary

The example code implements a simple long-only threshold strategy for one security. It opens an initial position, then compares each close with the most recent recorded purchase price. A decline beyond the configured buy threshold adds another purchase; a rise beyond the sell threshold removes the most recent recorded entry. Position size is based on a fixed cash amount and rounded down to whole 100-share lots. A CSV file stores the order queue between runs.

This is illustrative code, not evidence of a profitable grid system. The shown order-submission calls are commented out, so the functions update records without placing live trades as written. The example also contains a mismatch between threshold values and comments, and its missing-file path returns no queue even though later logic expects one. It has no explicit transaction costs, exposure cap, stop-loss, or portfolio-level controls. The lot calculation rejects nonpositive prices, which also limits its use with instruments that can trade at or below zero.

Key ideas

  • The strategy adds a purchase after a threshold decline from the latest recorded entry and removes the latest entry after a threshold rise.
  • Each purchase uses a fixed cash amount converted to whole 100-share lots.
  • A CSV-backed queue tracks recorded entries, but the illustrated order calls are disabled.
  • The example has initialization, execution, and risk-control limitations that prevent treating it as a complete tested strategy.

Tags

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