From cd146bfa8fe6ca32bce1a20462113fbc36e41509 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 4 Apr 2022 17:03:27 +0200 Subject: [PATCH] emergency_sell -> emergency_exit --- config_examples/config_full.example.json | 2 +- docs/strategy-callbacks.md | 2 +- docs/telegram-usage.md | 2 +- freqtrade/enums/exittype.py | 2 +- freqtrade/freqtradebot.py | 6 +++--- freqtrade/rpc/telegram.py | 2 +- freqtrade/strategy/interface.py | 2 +- .../templates/subtemplates/strategy_methods_advanced.j2 | 2 +- tests/test_freqtradebot.py | 6 +++--- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config_examples/config_full.example.json b/config_examples/config_full.example.json index f7c569e93..164e38f67 100644 --- a/config_examples/config_full.example.json +++ b/config_examples/config_full.example.json @@ -143,7 +143,7 @@ "buy_fill": "on", "sell": { "roi": "off", - "emergency_sell": "off", + "emergency_exit": "off", "force_exit": "off", "sell_signal": "off", "trailing_stop_loss": "off", diff --git a/docs/strategy-callbacks.md b/docs/strategy-callbacks.md index 13b29e8e1..8897bddbb 100644 --- a/docs/strategy-callbacks.md +++ b/docs/strategy-callbacks.md @@ -564,7 +564,7 @@ class AwesomeStrategy(IStrategy): :param time_in_force: Time in force. Defaults to GTC (Good-til-cancelled). :param exit_reason: Exit reason. Can be any of ['roi', 'stop_loss', 'stoploss_on_exchange', 'trailing_stop_loss', - 'sell_signal', 'force_exit', 'emergency_sell'] + 'sell_signal', 'force_exit', 'emergency_exit'] :param current_time: datetime object, containing the current datetime :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. :return bool: When True is returned, then the exit-order is placed on the exchange. diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index d680bab45..b84c21c65 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -84,7 +84,7 @@ Example configuration showing the different settings: "buy": "silent", "sell": { "roi": "silent", - "emergency_sell": "on", + "emergency_exit": "on", "force_exit": "on", "sell_signal": "silent", "trailing_stop_loss": "on", diff --git a/freqtrade/enums/exittype.py b/freqtrade/enums/exittype.py index e7648a32e..fb5c7110b 100644 --- a/freqtrade/enums/exittype.py +++ b/freqtrade/enums/exittype.py @@ -11,7 +11,7 @@ class ExitType(Enum): TRAILING_STOP_LOSS = "trailing_stop_loss" SELL_SIGNAL = "sell_signal" FORCE_EXIT = "force_exit" - EMERGENCY_SELL = "emergency_sell" + EMERGENCY_EXIT = "emergency_exit" CUSTOM_SELL = "custom_sell" NONE = "" diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index f440d8b99..c50ed4972 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -981,7 +981,7 @@ class FreqtradeBot(LoggingMixin): logger.error(f'Unable to place a stoploss order on exchange. {e}') logger.warning('Exiting the trade forcefully') self.execute_trade_exit(trade, trade.stop_loss, exit_check=ExitCheckTuple( - exit_type=ExitType.EMERGENCY_SELL)) + exit_type=ExitType.EMERGENCY_EXIT)) except ExchangeError: trade.stoploss_order_id = None @@ -1162,7 +1162,7 @@ class FreqtradeBot(LoggingMixin): try: self.execute_trade_exit( trade, order.get('price'), - exit_check=ExitCheckTuple(exit_type=ExitType.EMERGENCY_SELL)) + exit_check=ExitCheckTuple(exit_type=ExitType.EMERGENCY_EXIT)) except DependencyException as exception: logger.warning( f'Unable to emergency sell trade {trade.pair}: {exception}') @@ -1380,7 +1380,7 @@ class FreqtradeBot(LoggingMixin): trade = self.cancel_stoploss_on_exchange(trade) order_type = ordertype or self.strategy.order_types[exit_type] - if exit_check.exit_type == ExitType.EMERGENCY_SELL: + if exit_check.exit_type == ExitType.EMERGENCY_EXIT: # Emergency sells (default to market!) order_type = self.strategy.order_types.get("emergencyexit", "market") diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index be7e79c1f..5215c0ab2 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -770,7 +770,7 @@ class Telegram(RPCHandler): 'stoploss_on_exchange': 'Stoploss', 'sell_signal': 'Sell Signal', 'force_exit': 'Force Exit', - 'emergency_sell': 'Emergency Sell', + 'emergency_exit': 'Emergency Exit', } exit_reasons_tabulate = [ [ diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 1484cc61e..a488b1a28 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -308,7 +308,7 @@ class IStrategy(ABC, HyperStrategyMixin): :param time_in_force: Time in force. Defaults to GTC (Good-til-cancelled). :param exit_reason: Exit reason. Can be any of ['roi', 'stop_loss', 'stoploss_on_exchange', 'trailing_stop_loss', - 'sell_signal', 'force_exit', 'emergency_sell'] + 'sell_signal', 'force_exit', 'emergency_exit'] :param current_time: datetime object, containing the current datetime :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. :return bool: When True, then the exit-order is placed on the exchange. diff --git a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 index 5039e60a4..bf995ddfe 100644 --- a/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 +++ b/freqtrade/templates/subtemplates/strategy_methods_advanced.j2 @@ -162,7 +162,7 @@ def confirm_trade_exit(self, pair: str, trade: 'Trade', order_type: str, amount: :param time_in_force: Time in force. Defaults to GTC (Good-til-cancelled). :param exit_reason: Exit reason. Can be any of ['roi', 'stop_loss', 'stoploss_on_exchange', 'trailing_stop_loss', - 'sell_signal', 'force_exit', 'emergency_sell'] + 'sell_signal', 'force_exit', 'emergency_exit'] :param current_time: datetime object, containing the current datetime :param **kwargs: Ensure to keep this here so updates to this won't break your strategy. :return bool: When True is returned, then the exit-order is placed on the exchange. diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 698881349..e098cd144 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1210,7 +1210,7 @@ def test_handle_stoploss_on_exchange(mocker, default_conf_usdt, fee, caplog, is_ assert freqtrade.handle_stoploss_on_exchange(trade) is False assert trade.stoploss_order_id is None assert trade.is_open is False - assert trade.exit_reason == str(ExitType.EMERGENCY_SELL) + assert trade.exit_reason == str(ExitType.EMERGENCY_EXIT) @pytest.mark.parametrize("is_short", [False, True]) @@ -1293,7 +1293,7 @@ def test_create_stoploss_order_invalid_order( caplog.clear() freqtrade.create_stoploss_order(trade, 200) assert trade.stoploss_order_id is None - assert trade.exit_reason == ExitType.EMERGENCY_SELL.value + assert trade.exit_reason == ExitType.EMERGENCY_EXIT.value assert log_has("Unable to place a stoploss order on exchange. ", caplog) assert log_has("Exiting the trade forcefully", caplog) @@ -1305,7 +1305,7 @@ def test_create_stoploss_order_invalid_order( # Rpc is sending first buy, then sell assert rpc_mock.call_count == 2 - assert rpc_mock.call_args_list[1][0][0]['sell_reason'] == ExitType.EMERGENCY_SELL.value + assert rpc_mock.call_args_list[1][0][0]['sell_reason'] == ExitType.EMERGENCY_EXIT.value assert rpc_mock.call_args_list[1][0][0]['order_type'] == 'market'