From 11ace0f867c8f504feabddf5a96ddb84a557c694 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Fri, 7 Jan 2022 12:07:49 +0200 Subject: [PATCH] Instead of clearing `processed` dict, store `df_analyzed` (one with buy/sell signals) dataframe in it. It still saves memory because this dataframe is kept by DataProvider. Fixes #6179. Amends #6133 (a715083fc09cc9c53277e884238a371c138473b9). --- freqtrade/optimize/backtesting.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index fed872015..6cd6d17a6 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -270,8 +270,8 @@ class Backtesting: df_analyzed = self.strategy.advise_sell( self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair}).copy() # Trim startup period from analyzed dataframe - df_analyzed = trim_dataframe(df_analyzed, self.timerange, - startup_candles=self.required_startup) + df_analyzed = processed[pair] = pair_data = trim_dataframe( + df_analyzed, self.timerange, startup_candles=self.required_startup) # To avoid using data from future, we use buy/sell signals shifted # from the previous candle df_analyzed.loc[:, 'buy'] = df_analyzed.loc[:, 'buy'].shift(1) @@ -287,9 +287,6 @@ class Backtesting: # Convert from Pandas to list for performance reasons # (Looping Pandas is slow.) data[pair] = df_analyzed[headers].values.tolist() - - # Do not hold on to old data to reduce memory usage - processed[pair] = pair_data = None return data def _get_close_rate(self, sell_row: Tuple, trade: LocalTrade, sell: SellCheckTuple,