|
|
|
|
@ -920,7 +920,7 @@ class Backtesting:
|
|
|
|
|
trade.close(exit_row[OPEN_IDX], show_msg=False)
|
|
|
|
|
LocalTrade.close_bt_trade(trade)
|
|
|
|
|
|
|
|
|
|
def trade_slot_available(self, max_open_trades: int | float, open_trade_count: int) -> bool:
|
|
|
|
|
def trade_slot_available(self, max_open_trades: int, open_trade_count: int) -> bool:
|
|
|
|
|
# Always allow trades when max_open_trades is enabled.
|
|
|
|
|
if max_open_trades <= 0 or open_trade_count < max_open_trades:
|
|
|
|
|
return True
|
|
|
|
|
@ -1051,7 +1051,7 @@ class Backtesting:
|
|
|
|
|
|
|
|
|
|
def backtest_loop(
|
|
|
|
|
self, row: Tuple, pair: str, current_time: datetime, end_date: datetime,
|
|
|
|
|
max_open_trades: int | float,
|
|
|
|
|
max_open_trades: int,
|
|
|
|
|
open_trade_count_start: int, is_first: bool = True) -> int:
|
|
|
|
|
"""
|
|
|
|
|
NOTE: This method is used by Hyperopt at each iteration. Please keep it optimized.
|
|
|
|
|
@ -1123,7 +1123,7 @@ class Backtesting:
|
|
|
|
|
|
|
|
|
|
def backtest(self, processed: Dict,
|
|
|
|
|
start_date: datetime, end_date: datetime,
|
|
|
|
|
max_open_trades: int | float = 0) -> Dict[str, Any]:
|
|
|
|
|
max_open_trades: int = 0) -> Dict[str, Any]:
|
|
|
|
|
"""
|
|
|
|
|
Implement backtesting functionality
|
|
|
|
|
|
|
|
|
|
@ -1228,7 +1228,8 @@ class Backtesting:
|
|
|
|
|
# Use max_open_trades in backtesting, except --disable-max-market-positions is set
|
|
|
|
|
if self.config.get('use_max_market_positions', True):
|
|
|
|
|
# Must come from strategy config, as the strategy may modify this setting.
|
|
|
|
|
max_open_trades = self.strategy.config['max_open_trades']
|
|
|
|
|
max_open_trades = self.strategy.config['max_open_trades'] \
|
|
|
|
|
if self.strategy.config['max_open_trades'] != float('inf') else -1
|
|
|
|
|
else:
|
|
|
|
|
logger.info(
|
|
|
|
|
'Ignoring max_open_trades (--disable-max-market-positions was used) ...')
|
|
|
|
|
|