From 7f8e0ba25fe544dbb187e40337044c6b55afadfc Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Wed, 6 Jun 2018 13:56:08 +0300 Subject: [PATCH] use buy/sell signal from previous candle, not current to avoid seeing to the future --- freqtrade/optimize/backtesting.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 3dd643561..57282aae9 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -162,6 +162,10 @@ class Backtesting(object): pair_data['buy'], pair_data['sell'] = 0, 0 # cleanup from previous run ticker_data = self.populate_sell_trend(self.populate_buy_trend(pair_data))[headers] + + # to avoid using data from future, we buy/sell with signal from previous candle, not current + ticker_data.buy = ticker_data.buy.shift(1) + ticker_data.sell = ticker_data.sell.shift(1) ticker = [x for x in ticker_data.itertuples()] lock_pair_until = None