mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: add "*" to define custom default for non-defined exit reasons
This commit is contained in:
@@ -558,10 +558,12 @@ class Telegram(RPCHandler):
|
|||||||
sell_noti = (
|
sell_noti = (
|
||||||
self._config["telegram"].get("notification_settings", {}).get(str(msg_type), {})
|
self._config["telegram"].get("notification_settings", {}).get(str(msg_type), {})
|
||||||
)
|
)
|
||||||
|
|
||||||
# For backward compatibility sell still can be string
|
# For backward compatibility sell still can be string
|
||||||
if isinstance(sell_noti, str):
|
if isinstance(sell_noti, str):
|
||||||
noti = sell_noti
|
noti = sell_noti
|
||||||
else:
|
else:
|
||||||
|
default_noti = sell_noti.get("*", default_noti)
|
||||||
noti = sell_noti.get(str(exit_reason), default_noti)
|
noti = sell_noti.get(str(exit_reason), default_noti)
|
||||||
else:
|
else:
|
||||||
noti = (
|
noti = (
|
||||||
|
|||||||
@@ -2912,6 +2912,7 @@ def test_noficiation_settings(default_conf_usdt, mocker):
|
|||||||
"exit_fill": {
|
"exit_fill": {
|
||||||
"roi": "silent",
|
"roi": "silent",
|
||||||
"partial_exit": "off",
|
"partial_exit": "off",
|
||||||
|
"*": "silent", # Default to silent
|
||||||
},
|
},
|
||||||
"exit_cancel": "on",
|
"exit_cancel": "on",
|
||||||
"protection_trigger": "off",
|
"protection_trigger": "off",
|
||||||
@@ -2925,15 +2926,18 @@ def test_noficiation_settings(default_conf_usdt, mocker):
|
|||||||
assert telegram._message_loudness(RPCMessageType.ENTRY, "") == "silent"
|
assert telegram._message_loudness(RPCMessageType.ENTRY, "") == "silent"
|
||||||
assert telegram._message_loudness(RPCMessageType.ENTRY_FILL, "") == "on"
|
assert telegram._message_loudness(RPCMessageType.ENTRY_FILL, "") == "on"
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT, "") == "on"
|
assert telegram._message_loudness(RPCMessageType.EXIT, "") == "on"
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "") == "on"
|
# Default to silent due to "*" definition
|
||||||
|
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "") == "silent"
|
||||||
assert telegram._message_loudness(RPCMessageType.PROTECTION_TRIGGER, "") == "off"
|
assert telegram._message_loudness(RPCMessageType.PROTECTION_TRIGGER, "") == "off"
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT, "roi") == "silent"
|
assert telegram._message_loudness(RPCMessageType.EXIT, "roi") == "silent"
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT, "partial_exit") == "off"
|
assert telegram._message_loudness(RPCMessageType.EXIT, "partial_exit") == "off"
|
||||||
|
# Not given key defaults to on
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT, "cust_exit112") == "on"
|
assert telegram._message_loudness(RPCMessageType.EXIT, "cust_exit112") == "on"
|
||||||
|
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "roi") == "silent"
|
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "roi") == "silent"
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "partial_exit") == "off"
|
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "partial_exit") == "off"
|
||||||
# Default to on
|
# Default to silent due to "*" definition
|
||||||
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "cust_exit112") == "on"
|
assert telegram._message_loudness(RPCMessageType.EXIT_FILL, "cust_exit112") == "silent"
|
||||||
|
|
||||||
# Simplified setup for exit
|
# Simplified setup for exit
|
||||||
telegram._config["telegram"].update(
|
telegram._config["telegram"].update(
|
||||||
|
|||||||
Reference in New Issue
Block a user