Skip to content
All library documents

Fixing Float Bar Counts in a BigQuant Trailing Stop

Article BigQuant

Summary

The document reports a BigQuant backtest failure caused by passing a floating-point value where the history function requires an integer bar count. In the shown trailing-stop logic, the holding period is calculated as the number of elapsed days since the last purchase, then supplied to a history query for daily high prices. That elapsed-day value can be a float, which triggers the stated type error.

The strategy fragment uses the highest high since purchase to set a trailing stop seven percent below that high, and closes a position when the current market price falls below the stop. The traceback and example identify the likely source of the error, but the document does not provide a corrected implementation or describe how non-trading days, partial periods, or insufficient history should be handled. It is a troubleshooting example, not evidence that the stop method performs well.

Key ideas

  • The history lookup expects an integer bar count, but the example supplies an elapsed-day value that can be a float.
  • The code obtains the holding period from the difference between the current date and the last sale date.
  • The trailing stop is set below the highest daily high since the position was opened.
  • The example exits a position when its market price falls below the calculated stop.

Tags

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