feat: add backtesting support for ignore_buying_expired_candle_after

this is only relevant for detail candles - otherwise entries will never happen within a candle.
This commit is contained in:
Matthias
2025-01-17 06:36:32 +01:00
parent d02b4d4c3f
commit 419d5d9946
2 changed files with 10 additions and 0 deletions

View File

@@ -1527,6 +1527,15 @@ class Backtesting:
row = detail_data[idx]
trade_dir = pair_tradedir_cache.get(pair)
if self.strategy.ignore_expired_candle(
current_time - self.timeframe_td, # last closed candle is 1 timeframe away.
current_time_det,
self.timeframe_secs,
trade_dir is not None,
):
# Ignore late entries eventually
trade_dir = None
self.dataprovider._set_dataframe_max_date(current_time_det)
pair_has_open_trades = len(LocalTrade.bt_trades_open_pp[pair]) > 0

View File

@@ -866,6 +866,7 @@ def test_backtest_one_detail(default_conf_usdt, mocker, testdatadir, use_detail)
backtesting = Backtesting(default_conf_usdt)
backtesting._set_strategy(backtesting.strategylist[0])
backtesting.strategy.populate_entry_trend = advise_entry
backtesting.strategy.ignore_buying_expired_candle_after = 59
backtesting.strategy.custom_entry_price = custom_entry_price
pair = "XRP/ETH"
# Pick a timerange adapted to the pair we use to test