From ad9c5d96dc33ec93e35d769d159f385b222fab25 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Tue, 4 Jan 2022 23:09:35 -0600 Subject: [PATCH] EMERGENCY_SELL -> EMERGENCY_EXIT --- freqtrade/enums/exittype.py | 2 +- freqtrade/freqtradebot.py | 6 +++--- tests/test_freqtradebot.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/freqtrade/enums/exittype.py b/freqtrade/enums/exittype.py index 823f40d1e..3b03e5514 100644 --- a/freqtrade/enums/exittype.py +++ b/freqtrade/enums/exittype.py @@ -11,7 +11,7 @@ class ExitType(Enum): TRAILING_STOP_LOSS = "trailing_stop_loss" EXIT_SIGNAL = "exit_signal" FORCE_EXIT = "force_exit" - EMERGENCY_SELL = "emergency_sell" + EMERGENCY_EXIT = "emergency_sell" CUSTOM_SELL = "custom_sell" NONE = "" diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 5aa75674f..3a519d8b9 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -915,7 +915,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_reason=ExitCheckTuple( - exit_type=ExitType.EMERGENCY_SELL)) + exit_type=ExitType.EMERGENCY_EXIT)) except ExchangeError: trade.stoploss_order_id = None @@ -1102,7 +1102,7 @@ class FreqtradeBot(LoggingMixin): try: self.execute_trade_exit( trade, order.get('price'), - exit_reason=ExitCheckTuple(exit_type=ExitType.EMERGENCY_SELL)) + exit_reason=ExitCheckTuple(exit_type=ExitType.EMERGENCY_EXIT)) except DependencyException as exception: logger.warning( f'Unable to emergency sell trade {trade.pair}: {exception}') @@ -1314,7 +1314,7 @@ class FreqtradeBot(LoggingMixin): logger.exception(f"Could not cancel stoploss order {trade.stoploss_order_id}") order_type = ordertype or self.strategy.order_types[exit_type] - if exit_reason.exit_type == ExitType.EMERGENCY_SELL: + if exit_reason.exit_type == ExitType.EMERGENCY_EXIT: # Emergency sells (default to market!) order_type = self.strategy.order_types.get("emergencysell", "market") diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index 00bfcaa34..50123d735 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1164,7 +1164,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) @@ -1176,7 +1176,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]['exit_reason'] == ExitType.EMERGENCY_SELL.value + assert rpc_mock.call_args_list[1][0][0]['exit_reason'] == ExitType.EMERGENCY_EXIT.value assert rpc_mock.call_args_list[1][0][0]['order_type'] == 'market'