From cdd324d0a9c2a9b66eafa87e0dfb2f23f83095c2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 13 Feb 2023 20:08:54 +0100 Subject: [PATCH] Rename stoploss_reached to ft_stoploss_reached --- freqtrade/strategy/interface.py | 16 ++++++++-------- tests/strategy/test_interface.py | 20 ++++++++++---------- tests/test_freqtradebot.py | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 65d6f9fc3..1f687c196 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -1083,10 +1083,10 @@ class IStrategy(ABC, HyperStrategyMixin): trade.adjust_min_max_rates(high or current_rate, low or current_rate) - stoplossflag = self.stop_loss_reached(current_rate=current_rate, trade=trade, - current_time=current_time, - current_profit=current_profit, - force_stoploss=force_stoploss, low=low, high=high) + stoplossflag = self.ft_stoploss_reached(current_rate=current_rate, trade=trade, + current_time=current_time, + current_profit=current_profit, + force_stoploss=force_stoploss, low=low, high=high) # Set current rate to high for backtesting exits current_rate = (low if trade.is_short else high) or rate @@ -1204,10 +1204,10 @@ 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: + def ft_stoploss_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 diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index 294021c83..fe562907a 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -452,8 +452,8 @@ def test_min_roi_reached3(default_conf, fee) -> None: (0.05, 0.9, ExitType.NONE, None, False, True, 0.09, 0.9, ExitType.NONE, lambda **kwargs: None), ]) -def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, liq, trailing, custom, - profit2, adjusted2, expected2, custom_stop) -> None: +def test_ft_stoploss_reached(default_conf, fee, profit, adjusted, expected, liq, trailing, custom, + profit2, adjusted2, expected2, custom_stop) -> None: strategy = StrategyResolver.load_strategy(default_conf) trade = Trade( @@ -477,9 +477,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, liq, t now = arrow.utcnow().datetime current_rate = trade.open_rate * (1 + profit) - sl_flag = strategy.stop_loss_reached(current_rate=current_rate, trade=trade, - current_time=now, current_profit=profit, - force_stoploss=0, high=None) + sl_flag = strategy.ft_stoploss_reached(current_rate=current_rate, trade=trade, + current_time=now, current_profit=profit, + force_stoploss=0, high=None) assert isinstance(sl_flag, ExitCheckTuple) assert sl_flag.exit_type == expected if expected == ExitType.NONE: @@ -489,9 +489,9 @@ def test_stop_loss_reached(default_conf, fee, profit, adjusted, expected, liq, t assert round(trade.stop_loss, 2) == adjusted current_rate2 = trade.open_rate * (1 + profit2) - sl_flag = strategy.stop_loss_reached(current_rate=current_rate2, trade=trade, - current_time=now, current_profit=profit2, - force_stoploss=0, high=None) + sl_flag = strategy.ft_stoploss_reached(current_rate=current_rate2, trade=trade, + current_time=now, current_profit=profit2, + force_stoploss=0, high=None) assert sl_flag.exit_type == expected2 if expected2 == ExitType.NONE: assert sl_flag.exit_flag is False @@ -579,7 +579,7 @@ def test_should_sell(default_conf, fee) -> None: assert res == [ExitCheckTuple(exit_type=ExitType.ROI)] strategy.min_roi_reached = MagicMock(return_value=True) - strategy.stop_loss_reached = MagicMock( + strategy.ft_stoploss_reached = MagicMock( return_value=ExitCheckTuple(exit_type=ExitType.STOP_LOSS)) res = strategy.should_exit(trade, 1, now, @@ -603,7 +603,7 @@ def test_should_sell(default_conf, fee) -> None: ExitCheckTuple(exit_type=ExitType.ROI), ] - strategy.stop_loss_reached = MagicMock( + strategy.ft_stoploss_reached = MagicMock( return_value=ExitCheckTuple(exit_type=ExitType.TRAILING_STOP_LOSS)) # Regular exit signal res = strategy.should_exit(trade, 1, now, diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 5e580e4fa..9e8353a4b 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -3902,7 +3902,7 @@ def test_exit_profit_only( if exit_type == ExitType.EXIT_SIGNAL.value: freqtrade.strategy.min_roi_reached = MagicMock(return_value=False) else: - freqtrade.strategy.stop_loss_reached = MagicMock(return_value=ExitCheckTuple( + freqtrade.strategy.ft_stoploss_reached = MagicMock(return_value=ExitCheckTuple( exit_type=ExitType.NONE)) freqtrade.enter_positions()