From b1cbc75e93740e3f62ec5ed6c1a5b0e2d0c4ff80 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 31 Jul 2021 08:45:04 +0200 Subject: [PATCH] Properly cache pair dataframe in backtesting (without startup-range). --- freqtrade/optimize/backtesting.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index b9ce69edd..2974e49e2 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -240,6 +240,9 @@ class Backtesting: df_analyzed.drop(df_analyzed.head(1).index, inplace=True) + # Update dataprovider cache + self.dataprovider._set_cached_df(pair, self.timeframe, df_analyzed) + # Convert from Pandas to list for performance reasons # (Looping Pandas is slow.) data[pair] = df_analyzed.values.tolist() @@ -434,10 +437,6 @@ class Backtesting: trades: List[LocalTrade] = [] self.prepare_backtest(enable_protections) - # Update dataprovider cache - for pair, dataframe in processed.items(): - self.dataprovider._set_cached_df(pair, self.timeframe, dataframe) - # Use dict of lists with data for performance # (looping lists is a lot faster than pandas DataFrames) data: Dict = self._get_ohlcv_as_lists(processed)