From 88f26971fa6fdfc7ac05868b509d4d301fb4be8a Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 24 Apr 2021 19:15:09 +0200 Subject: [PATCH] Use defaultdict for backtesting --- freqtrade/optimize/backtesting.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index fc5c0fdd7..fb9826a23 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -352,7 +352,7 @@ class Backtesting: data: Dict = self._get_ohlcv_as_lists(processed) # Indexes per pair, so some pairs are allowed to have a missing start. - indexes: Dict = {} + indexes: Dict = defaultdict(int) tmp = start_date + timedelta(minutes=self.timeframe_min) open_trades: Dict[str, List[LocalTrade]] = defaultdict(list) @@ -363,9 +363,6 @@ class Backtesting: open_trade_count_start = open_trade_count for i, pair in enumerate(data): - if pair not in indexes: - indexes[pair] = 0 - try: row = data[pair][indexes[pair]] except IndexError: