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:
@@ -1527,6 +1527,15 @@ class Backtesting:
|
|||||||
row = detail_data[idx]
|
row = detail_data[idx]
|
||||||
trade_dir = pair_tradedir_cache.get(pair)
|
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)
|
self.dataprovider._set_dataframe_max_date(current_time_det)
|
||||||
|
|
||||||
pair_has_open_trades = len(LocalTrade.bt_trades_open_pp[pair]) > 0
|
pair_has_open_trades = len(LocalTrade.bt_trades_open_pp[pair]) > 0
|
||||||
|
|||||||
@@ -866,6 +866,7 @@ def test_backtest_one_detail(default_conf_usdt, mocker, testdatadir, use_detail)
|
|||||||
backtesting = Backtesting(default_conf_usdt)
|
backtesting = Backtesting(default_conf_usdt)
|
||||||
backtesting._set_strategy(backtesting.strategylist[0])
|
backtesting._set_strategy(backtesting.strategylist[0])
|
||||||
backtesting.strategy.populate_entry_trend = advise_entry
|
backtesting.strategy.populate_entry_trend = advise_entry
|
||||||
|
backtesting.strategy.ignore_buying_expired_candle_after = 59
|
||||||
backtesting.strategy.custom_entry_price = custom_entry_price
|
backtesting.strategy.custom_entry_price = custom_entry_price
|
||||||
pair = "XRP/ETH"
|
pair = "XRP/ETH"
|
||||||
# Pick a timerange adapted to the pair we use to test
|
# Pick a timerange adapted to the pair we use to test
|
||||||
|
|||||||
Reference in New Issue
Block a user