From 8f0dbc6be14c9c4dfac7289a8224f962bf879a71 Mon Sep 17 00:00:00 2001 From: Robert Davey Date: Thu, 25 Jan 2024 16:11:21 +0000 Subject: [PATCH] Improve common mistakes docs Add more details to the common mistakes section of the strategy customisation docs. --- docs/strategy-customization.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/strategy-customization.md b/docs/strategy-customization.md index b203d6d3b..900dafb33 100644 --- a/docs/strategy-customization.md +++ b/docs/strategy-customization.md @@ -1009,8 +1009,8 @@ This is a common pain-point, which can cause huge differences between backtestin The following lists some common patterns which should be avoided to prevent frustration: -- don't use `shift(-1)`. This uses data from the future, which is not available. -- don't use `.iloc[-1]` or any other absolute position in the dataframe, this will be different between dry-run and backtesting. +- don't use `shift(-1)` or other negative values. This uses data from the future in backtesting, which is not available in dry or live modes. +- don't use `.iloc[-1]` or any other absolute position in the dataframe within `populate_` functions, as this will be different between dry-run and backtesting. Absolute `iloc` indexing is safe to use in callbacks however - see [Strategy Callbacks](strategy-callbacks.md). - don't use `dataframe['volume'].mean()`. This uses the full DataFrame for backtesting, including data from the future. Use `dataframe['volume'].rolling().mean()` instead - don't use `.resample('1h')`. This uses the left border of the interval, so moves data from an hour to the start of the hour. Use `.resample('1h', label='right')` instead.