Backtest Stability

I have a script which I got working after some help from the forums. While backtesting, I noticed that sometimes the backtest completely fails and sometimes, it is able to trade on a few days and generates the corresponding PnL. Why could this be happening?

  • The strategy might not execute on some days due to the logic and thereby it's fine.
  • But two backtests with same parameters should give identical results?

Am I missing something out in the process?



  • ptunneyptunney Posts: 246

    The backtest is stable. Given the same inputs it produces the same results.
    When you say "fails" what do you mean, what error do you get?
    Your initial script was for GOOG and MSFT. Did you increase the number of symbols from there?
    Failures tend to occur for one of three reasons...a) issues with your code b) you ran out of memory c) you ran out of time.
    Plus an extremely rare one of issues with the system.
    The most common reason is a) and I say that with my own code in mind as well.
    Print statements are your friend. Try running small and printing every time you make a decision/trade. That is where most of the a-ha moments come when checking your code. You suddenly realize that a value you thought you were checking was not giving the result you expected or a calculation was not working the way you expected.


  • Alright, let me look into the printing aspect !!

Sign In or Register to comment.