From 125dff1dad6289a622fbe79093933f28d9257aad Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 4 Apr 2022 19:19:54 +0200 Subject: [PATCH] Properly deprecate webhook settings (with transition) --- freqtrade/configuration/deprecated_settings.py | 6 ++++++ freqtrade/rpc/webhook.py | 8 +++----- tests/rpc/test_rpc_webhook.py | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/freqtrade/configuration/deprecated_settings.py b/freqtrade/configuration/deprecated_settings.py index b482ca3d5..06d75688d 100644 --- a/freqtrade/configuration/deprecated_settings.py +++ b/freqtrade/configuration/deprecated_settings.py @@ -90,6 +90,12 @@ def process_temporary_deprecated_settings(config: Dict[str, Any]) -> None: 'notification_settings', 'exit_fill') process_deprecated_setting(config['telegram'], 'notification_settings', 'sell_cancel', 'notification_settings', 'exit_cancel') + if config.get('webhook'): + process_deprecated_setting(config, 'webhook', 'webhooksell', 'webhook', 'webhookexit') + process_deprecated_setting(config, 'webhook', 'webhooksellcancel', + 'webhook', 'webhookexitcancel') + process_deprecated_setting(config, 'webhook', 'webhooksellfill', + 'webhook', 'webhookexitfill') # Legacy way - having them in experimental ... process_removed_setting(config, 'experimental', 'use_sell_signal', diff --git a/freqtrade/rpc/webhook.py b/freqtrade/rpc/webhook.py index e9ea9f3ac..dbb87f1fe 100644 --- a/freqtrade/rpc/webhook.py +++ b/freqtrade/rpc/webhook.py @@ -44,7 +44,6 @@ class Webhook(RPCHandler): """ Send a message to telegram channel """ try: whconfig = self._config['webhook'] - # DEPRECATED: Sell terminology if msg['type'] in [RPCMessageType.BUY, RPCMessageType.SHORT]: valuedict = whconfig.get('webhookbuy', None) elif msg['type'] in [RPCMessageType.BUY_CANCEL, RPCMessageType.SHORT_CANCEL]: @@ -52,12 +51,11 @@ class Webhook(RPCHandler): elif msg['type'] in [RPCMessageType.BUY_FILL, RPCMessageType.SHORT_FILL]: valuedict = whconfig.get('webhookbuyfill', None) elif msg['type'] == RPCMessageType.EXIT: - valuedict = whconfig.get('webhookexit', whconfig.get('webhooksell', None)) + valuedict = whconfig.get('webhookexit', None) elif msg['type'] == RPCMessageType.EXIT_FILL: - valuedict = whconfig.get('webhookexitfill', whconfig.get('webhookexitfill', None)) + valuedict = whconfig.get('webhookexitfill', None) elif msg['type'] == RPCMessageType.EXIT_CANCEL: - valuedict = whconfig.get('webhookexitcancel', - whconfig.get('webhooksellcancel', None)) + valuedict = whconfig.get('webhookexitcancel', None) elif msg['type'] in (RPCMessageType.STATUS, RPCMessageType.STARTUP, RPCMessageType.WARNING): diff --git a/tests/rpc/test_rpc_webhook.py b/tests/rpc/test_rpc_webhook.py index cf2d1bf98..6dd24b6c5 100644 --- a/tests/rpc/test_rpc_webhook.py +++ b/tests/rpc/test_rpc_webhook.py @@ -274,11 +274,11 @@ def test_send_msg_webhook(default_conf, mocker): webhook.send_msg(msg=msg) assert msg_mock.call_count == 1 assert (msg_mock.call_args[0][0]["value1"] == - default_conf["webhook"]["webhooksellcancel"]["value1"].format(**msg)) + default_conf["webhook"]["webhookexitcancel"]["value1"].format(**msg)) assert (msg_mock.call_args[0][0]["value2"] == - default_conf["webhook"]["webhooksellcancel"]["value2"].format(**msg)) + default_conf["webhook"]["webhookexitcancel"]["value2"].format(**msg)) assert (msg_mock.call_args[0][0]["value3"] == - default_conf["webhook"]["webhooksellcancel"]["value3"].format(**msg)) + default_conf["webhook"]["webhookexitcancel"]["value3"].format(**msg)) # Test Sell fill msg_mock.reset_mock() msg = {