Use defaultdict for backtesting
This commit is contained in:
parent
8e85b63b3d
commit
88f26971fa
@ -352,7 +352,7 @@ class Backtesting:
|
|||||||
data: Dict = self._get_ohlcv_as_lists(processed)
|
data: Dict = self._get_ohlcv_as_lists(processed)
|
||||||
|
|
||||||
# Indexes per pair, so some pairs are allowed to have a missing start.
|
# 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)
|
tmp = start_date + timedelta(minutes=self.timeframe_min)
|
||||||
|
|
||||||
open_trades: Dict[str, List[LocalTrade]] = defaultdict(list)
|
open_trades: Dict[str, List[LocalTrade]] = defaultdict(list)
|
||||||
@ -363,9 +363,6 @@ class Backtesting:
|
|||||||
open_trade_count_start = open_trade_count
|
open_trade_count_start = open_trade_count
|
||||||
|
|
||||||
for i, pair in enumerate(data):
|
for i, pair in enumerate(data):
|
||||||
if pair not in indexes:
|
|
||||||
indexes[pair] = 0
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
row = data[pair][indexes[pair]]
|
row = data[pair][indexes[pair]]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
Loading…
Reference in New Issue
Block a user