I've tweaked an existing open source example algo that trades on moving daily averages to trade on certain different leveraged SPY ETFs. In some backtesting, I getĀ this. There is no way this is not a glitch. Looking through the orders, I possibly found theĀ culprit. Why is this happening, and how can I prevent it to prevent it messing with the actual performance of my algorithm in the backtest?

Author