Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Backtest date bug?

When I run backtests, the date is off by one day on the chart. Transaction details are correct, but the chart isn't.

For example, September 2016 has no results for 2, 9, 16, 23, and 30 which are all Friday's. It skips those dates as if it were the weekend - but in transaction details, the proper trade logs exist.

Anyone else have this issue? Be careful using backtest chart data.

3 responses

Am I being a noob or do we have an issue here?

It's not so much a 'bug' but a 'feature' :) or as Einstein put it "it's all relative".

If you look at the timeline across the bottom of the chart those dates match up with the transaction dates in the logs and transaction details. Those are fixed at the time the backtest was run. The dates across the bottom can be interpreted as 'as of midnight on this date' here are the gains, transactions, etc. This is a 'make believe' date generated by the backtest. BUT NOTE! It's based upon the timezone on your computer when the backtest was run, and as of the actual New York market time.

I'm in US Central Time (and we go on daylight saving time in the summer) so if I trade at 'market open' I see a trade 8:31AM, not 9:31AM. That's because the trade occurred at 9:31AM ET but we're an hour earlier. Once a backtest is run these dates remain fixed and independent of any changes to the computer timezone.

You are probably looking at the small date in the upper right next to 'week / month / all'. That date is 'real time'. It looks at your computers current timezone. And here's the rub. It uses your computers current timezone BUT interprets the backtest results as if they are all Universal Time Coordinated (ie -0 UTC).

So, you probably live somewhere in the US and ran a backtest that perhaps starts on Jan 4, 2016. The transaction dates are all relative to your computer time and look 'correct'. But, when you look at the little date in the corner it seems like it's a day BEHIND. That's because it's interpreting the backtest as midnight Jan 4, 2016 UTC. Since you are several hours ahead, you are still in Jan 3, 2016.

You can check this. Run a backtest (using your current timezone). Look at the resulting little date. It appears a day off. Now, simply change your computers timezone to Greenwich Mean Time. Look at the resulting little date and it will align perfectly (though it still may be off depending upon how your computer handles Daylight Saving Time).

Perhaps a bug? I tend to think of it as a reminder that the world isn't US centric.

One other anomaly with the logs is that they also report the time as of local 'PC time'. This has caused some confusion for users in, say, China where the trading day gets split between two calendar days because they are 12 hours different.

Killer clarification. Thank you for taking the time to write that.

Really though, there has to be a better way to make this more consistent with market hours. It shouldn't matter where I run my backtest from - the data should be the same whether I'm at home on the west coast, visiting a friend in China, or using Elon's WiFi on Mars. The market is open from X to X, EST. No need to muddy the waters.

At least give us a check box to make it perform one way or the other. I mean, amiright?