fix: don't detail-loop pairs if a trade closed within the current candle.

This commit is contained in:
Matthias
2025-01-15 06:46:33 +01:00
parent 1e1b4239e7
commit cbe38c6f41

View File

@@ -1483,6 +1483,7 @@ class Backtesting:
)
pair_detail_cache: dict[str, list[tuple]] = {}
pair_tradedir_cache: dict[str, LongShort | None] = {}
pairs_with_open_trades = [t.pair for t in LocalTrade.bt_trades_open]
for current_time_det, is_first, has_detail, idx in self.time_generator_det(
current_time, current_time + increment
):
@@ -1523,6 +1524,10 @@ class Backtesting:
self.dataprovider._set_dataframe_max_date(current_time_det)
pair_has_open_trades = len(LocalTrade.bt_trades_open_pp[pair]) > 0
if pair in pairs_with_open_trades and not pair_has_open_trades:
# Pair has had open trades which closed in the current main candle.
# Skip this pair for this timeframe
continue
if (
is_first