Added support for max_open_trades hyperopting

This commit is contained in:
Antonio Della Fortuna
2023-01-04 10:34:44 +01:00
parent cd4faa9c59
commit 5fd85368a9
20 changed files with 155 additions and 36 deletions

View File

@@ -80,6 +80,8 @@ class HyperStrategyMixin:
self.stoploss = params.get('stoploss', {}).get(
'stoploss', getattr(self, 'stoploss', -0.1))
self.max_open_trades = params.get('max_open_trades', {}).get(
'max_open_trades', getattr(self, 'max_open_trades', -1))
trailing = params.get('trailing', {})
self.trailing_stop = trailing.get(
'trailing_stop', getattr(self, 'trailing_stop', False))

View File

@@ -54,6 +54,9 @@ class IStrategy(ABC, HyperStrategyMixin):
# associated stoploss
stoploss: float
# max open trades for the strategy
max_open_trades: int | float
# trailing stoploss
trailing_stop: bool = False
trailing_stop_positive: Optional[float] = None