Skip to content
All library documents

Optimizing Indicator Calculations for Short Strategy Histories

Article vn.py community

Summary

The document raises a programming question about whether indicator functions should return only a strategy’s most recent 30 data points when the strategy does not need a longer history. It uses a Bollinger Band function as an example: the function derives a moving average and standard deviation, then returns upper and lower bands, either as arrays or scalar values. The proposed change would limit the returned data in non-array mode, with similar edits considered for other functions.

No answer, benchmark, or measured performance result is included, so the document does not show that truncating outputs would make calculations faster. It also leaves open whether limiting returned values would reduce computation or merely shorten the result, and whether other callers rely on the full history. The useful takeaway is the optimization question itself: distinguish the cost of calculating an indicator from the cost of storing or returning its output, then profile the actual strategy before changing shared utility behavior.

Key ideas

  • The question concerns limiting indicator outputs to the most recent 30 observations.
  • Bollinger Bands are presented as an example built from a moving average and standard deviation.
  • Shortening returned arrays may not reduce the cost of calculating the full indicator history.
  • The document contains no benchmark or answer to establish whether the proposed change improves performance.

Tags

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