From 8acffbc1d8db5ef10e269debec6700baa09bf2e9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 3 Apr 2022 11:18:36 +0200 Subject: [PATCH] sell_type -> exit_type --- freqtrade/strategy/interface.py | 12 ++++++------ tests/test_freqtradebot.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 06fa121b3..7b05ce503 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -905,7 +905,7 @@ class IStrategy(ABC, HyperStrategyMixin): custom_reason = None if sell_signal in (ExitType.CUSTOM_SELL, ExitType.SELL_SIGNAL): logger.debug(f"{trade.pair} - Sell signal received. " - f"sell_type=ExitType.{sell_signal.name}" + + f"exit_type=ExitType.{sell_signal.name}" + (f", custom_reason={custom_reason}" if custom_reason else "")) return ExitCheckTuple(exit_type=sell_signal, exit_reason=custom_reason) @@ -914,12 +914,12 @@ class IStrategy(ABC, HyperStrategyMixin): # ROI (if not stoploss) # Stoploss if roi_reached and stoplossflag.exit_type != ExitType.STOP_LOSS: - logger.debug(f"{trade.pair} - Required profit reached. sell_type=ExitType.ROI") + logger.debug(f"{trade.pair} - Required profit reached. exit_type=ExitType.ROI") return ExitCheckTuple(exit_type=ExitType.ROI) if stoplossflag.exit_flag: - logger.debug(f"{trade.pair} - Stoploss hit. sell_type={stoplossflag.exit_type}") + logger.debug(f"{trade.pair} - Stoploss hit. exit_type={stoplossflag.exit_type}") return stoplossflag # This one is noisy, commented out... @@ -988,11 +988,11 @@ class IStrategy(ABC, HyperStrategyMixin): if ((sl_higher_long or sl_lower_short) and (not self.order_types.get('stoploss_on_exchange') or self.config['dry_run'])): - sell_type = ExitType.STOP_LOSS + exit_type = ExitType.STOP_LOSS # If initial stoploss is not the same as current one then it is trailing. if trade.initial_stop_loss != trade.stop_loss: - sell_type = ExitType.TRAILING_STOP_LOSS + exit_type = ExitType.TRAILING_STOP_LOSS logger.debug( f"{trade.pair} - HIT STOP: current price at " f"{((high if trade.is_short else low) or current_rate):.6f}, " @@ -1007,7 +1007,7 @@ class IStrategy(ABC, HyperStrategyMixin): logger.debug(f"{trade.pair} - Trailing stop saved " f"{new_stoploss:.6f}") - return ExitCheckTuple(exit_type=sell_type) + return ExitCheckTuple(exit_type=exit_type) return ExitCheckTuple(exit_type=ExitType.NONE) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 10eea1e50..698881349 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -2268,7 +2268,7 @@ def test_handle_trade_roi(default_conf_usdt, ticker_usdt, limit_order_open, fee, caplog.clear() patch_get_signal(freqtrade) assert freqtrade.handle_trade(trade) - assert log_has("ETH/USDT - Required profit reached. sell_type=ExitType.ROI", + assert log_has("ETH/USDT - Required profit reached. exit_type=ExitType.ROI", caplog) @@ -2310,7 +2310,7 @@ def test_handle_trade_use_sell_signal( else: patch_get_signal(freqtrade, enter_long=False, exit_long=True) assert freqtrade.handle_trade(trade) - assert log_has("ETH/USDT - Sell signal received. sell_type=ExitType.SELL_SIGNAL", + assert log_has("ETH/USDT - Sell signal received. exit_type=ExitType.SELL_SIGNAL", caplog) @@ -3628,7 +3628,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u assert mock_insuf.call_count == 1 -@pytest.mark.parametrize('profit_only,bid,ask,handle_first,handle_second,sell_type,is_short', [ +@pytest.mark.parametrize('profit_only,bid,ask,handle_first,handle_second,exit_type,is_short', [ # Enable profit (True, 2.18, 2.2, False, True, ExitType.SELL_SIGNAL.value, False), (True, 2.18, 2.2, False, True, ExitType.SELL_SIGNAL.value, True), @@ -3645,7 +3645,7 @@ def test_execute_trade_exit_insufficient_funds_error(default_conf_usdt, ticker_u ]) def test_sell_profit_only( default_conf_usdt, limit_order, limit_order_open, is_short, - fee, mocker, profit_only, bid, ask, handle_first, handle_second, sell_type) -> None: + fee, mocker, profit_only, bid, ask, handle_first, handle_second, exit_type) -> None: patch_RPCManager(mocker) patch_exchange(mocker) eside = enter_side(is_short) @@ -3669,7 +3669,7 @@ def test_sell_profit_only( }) freqtrade = FreqtradeBot(default_conf_usdt) patch_get_signal(freqtrade, enter_short=is_short, enter_long=not is_short) - if sell_type == ExitType.SELL_SIGNAL.value: + if exit_type == ExitType.SELL_SIGNAL.value: freqtrade.strategy.min_roi_reached = MagicMock(return_value=False) else: freqtrade.strategy.stop_loss_reached = MagicMock(return_value=ExitCheckTuple(