diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 70d656199..65d6f9fc3 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -1153,13 +1153,12 @@ class IStrategy(ABC, HyperStrategyMixin): return exits - def stop_loss_reached(self, current_rate: float, trade: Trade, - current_time: datetime, current_profit: float, - force_stoploss: float, low: Optional[float] = None, - high: Optional[float] = None) -> ExitCheckTuple: + def ft_stoploss_adjust(self, current_rate: float, trade: Trade, + current_time: datetime, current_profit: float, + force_stoploss: float, low: Optional[float] = None, + high: Optional[float] = None) -> None: """ - Based on current profit of the trade and configured (trailing) stoploss, - decides to exit or not + Adjust stop-loss dynamically if configured to do so. :param current_profit: current profit as ratio :param low: Low value of this candle, only set in backtesting :param high: High value of this candle, only set in backtesting @@ -1205,6 +1204,20 @@ class IStrategy(ABC, HyperStrategyMixin): trade.adjust_stop_loss(bound or current_rate, stop_loss_value) + def stop_loss_reached(self, current_rate: float, trade: Trade, + current_time: datetime, current_profit: float, + force_stoploss: float, low: Optional[float] = None, + high: Optional[float] = None) -> ExitCheckTuple: + """ + Based on current profit of the trade and configured (trailing) stoploss, + decides to exit or not + :param current_profit: current profit as ratio + :param low: Low value of this candle, only set in backtesting + :param high: High value of this candle, only set in backtesting + """ + self.ft_stoploss_adjust(current_rate, trade, current_time, current_profit, + force_stoploss, low, high) + sl_higher_long = (trade.stop_loss >= (low or current_rate) and not trade.is_short) sl_lower_short = (trade.stop_loss <= (high or current_rate) and trade.is_short) liq_higher_long = (trade.liquidation_price