Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Different backtest results from change in date range

I'm working on my first algo, and am seeing very different results in backtesting from making the backtest range one year longer/shorter, with identical code. Any obvious reason this may be? I realize the results will change depending on the date range, but by that much?

6 responses

Here's with date range starting 2010

And one starting 2016

Would need to check further into the backtests, but one of the most popular issues is the partial fills making algos look better than expected the longer they trade and accumulate $.

Hi Tyler thanks for replying, and that makes a lot of sense. I'll look into that.

Didn't look too closely at your buy/sell logic, however it seems to buy and hold. Also seems to hold a very small number of securities. For instance, the backtest started in 2009 only holds these securities for the entire backtest.

Top 10 long positions of all time max
NFLX-23709 89.93%
SNDK-13940 41.84%
GS-20088 25.58%
INTC-3951 25.40%
SPGI-4849 6.49%

However, the backtest started in 2010 only holds a small number of different positions.

GWW-3421 445714.12%
SIVB-6897 390766.38%
KIM-4238 367189.08%
GPN-22443 293007.23%
SMG-6736 220444.39%
AIV-11598 208328.91%
XRAY-8352 200792.97%
RRD-2248 167383.92%
POR-28318 144055.90%
SMTC-6961 130942.73%
LVLT-18587 124467.96%
PPS-9438 121368.51%
LHO-18582 103105.51%
MDAS-35268 81826.22%
OZRK-17264 71834.75%
CVA-2169 63976.66%
POWI-18085 63449.25%
MIC-26898 57717.33%
ENS-26530 47597.93%
NATI-12701 46612.99%
EPL-38761 45499.03%
IPI-36093 44402.39%
CIR-20696 38161.27%
CW-2015 36651.76%
GEF-14379 36098.04%
MPW-27443 32673.83%
HELE-3522 31618.50%
PSSI-11369 27705.48%
RBN-6529 24178.99%
TFSL-33718 23044.93%
RUE-38944 18536.92%
VQ-32905 17376.81%
DNN-33702 9116.56%
TBL-7323 476.53%
SPGI-4849 67.81%
IMKT_A-3890 27.59%
FFIN-10148 26.39%
MOG_A-4960 18.69%
ESND-7866 14.12%
SPXC-7086 12.75%

Your logic must buy and then never sell until some favorable conditions are met. The 2009 backtest happens to get lucky and buys some great stocks and never sells. The 2010 backtest wasn't so lucky and buys some not so favorable stocks but still holds onto them until they run your portfolio into the ground.

Generally, try to turn your portfolio over (or at least re-evaluate what is held) at least every month or two. Otherwise, as you noted, the backtests will be highly dependant upon initial starting conditions.

Good luck.

Thanks Dan, that helps a lot. I think I know what's happening now.