FSD – Why lookahead and recursive issues happened

The cause of both issues is actually quite simple. In backtest, you get plenty of data, but on dry/live, you get limited number of data. The difference of the data can be problematic if you use the data wrongly. Let’s see how the data looked like in backtest

As you can see in the image above, in backtest, you get the full data based of timerange that you provided. For each of the green boxes (except the last one), there are future data available to them. This is where lookahead issue can happen, because you can tell the bot to use the future data (intentionally or not).

Let’s say we go back to the past, and we are currently at the time at the start of the backtest. This is how your data gonna look like in dry/live run

As you can see, there is no future data available for us in dry/live, while in backtest, you gonna have plenty of future data available. Read this to know common mistakes that can cause lookahead issue.

What about the recursive issue then? Let’s say we are now in the middle of the backtest timerange like this (top is backtest, bottom is dry/live run)

As you can see, in backtest, for the same timestamp, you get plenty of historical data to be used, while you just get limited amount of data to be used. It might matter or not depending on how you are using them. If you read this post, the step indicator gonna have different value depending on how much historical data it get.

Freqtrade now have lookahead-analysis and recursive-analysis commands to help you check whether your strategy has both issues or not.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *