Allow and document time-based custom stoploss

closes #3206
This commit is contained in:
Matthias
2020-12-19 11:46:49 +01:00
parent f235ab8cf4
commit f7b54c2415
2 changed files with 28 additions and 5 deletions

View File

@@ -255,8 +255,8 @@ class IStrategy(ABC):
"""
return True
def stoploss_value(self, pair: str, trade: Trade, current_rate: float, current_profit: float,
**kwargs) -> float:
def stoploss_value(self, pair: str, trade: Trade, current_time: datetime, current_rate: float,
current_profit: float, **kwargs) -> float:
"""
Define custom stoploss logic
The custom stoploss can never be below self.stoploss, which serves as a hard maximum loss.
@@ -554,6 +554,7 @@ class IStrategy(ABC):
if self.custom_stoploss:
stop_loss_value = strategy_safe_wrapper(self.stoploss_value, default_retval=None
)(pair=trade.pair, trade=trade,
current_time=current_time,
current_rate=current_rate,
current_profit=current_profit)
# Sanity check - error cases will return None