diff --git a/docs/telegram-usage.md b/docs/telegram-usage.md index a690e18b9..add889681 100644 --- a/docs/telegram-usage.md +++ b/docs/telegram-usage.md @@ -187,7 +187,7 @@ official commands. You can ask at any moment for help with `/help`. | `/stats` | Shows Wins / losses by Exit reason as well as Avg. holding durations for buys and sells | `/exits` | Shows Wins / losses by Exit reason as well as Avg. holding durations for buys and sells | `/entries` | Shows Wins / losses by Exit reason as well as Avg. holding durations for buys and sells -| `/whitelist` | Show the current whitelist +| `/whitelist [sorted] [baseonly]` | Show the current whitelist. Optionally display in alphabetical order and/or with just the base currency of each pairing. | `/blacklist [pair]` | Show the current blacklist, or adds a pair to the blacklist. | `/edge` | Show validated pairs by Edge if it is enabled. | `/help` | Show help message diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 9e0cd7d86..88222608e 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -1368,6 +1368,12 @@ class Telegram(RPCHandler): try: whitelist = self._rpc._rpc_whitelist() + if context.args: + if "sorted" in context.args: + whitelist['whitelist'] = sorted(whitelist['whitelist']) + if "baseonly" in context.args: + whitelist['whitelist'] = [pair.split("/")[0] for pair in whitelist['whitelist']] + message = f"Using whitelist `{whitelist['method']}` with {whitelist['length']} pairs\n" message += f"`{', '.join(whitelist['whitelist'])}`" @@ -1487,7 +1493,8 @@ class Telegram(RPCHandler): "*/fx |all:* `Alias to /forceexit`\n" f"{force_enter_text if self._config.get('force_entry_enable', False) else ''}" "*/delete :* `Instantly delete the given trade in the database`\n" - "*/whitelist:* `Show current whitelist` \n" + "*/whitelist [sorted] [baseonly]:* `Show current whitelist. Optionally in " + "order and/or only displaying the base currency of each pairing.`\n" "*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs " "to the blacklist.` \n" "*/blacklist_delete [pairs]| /bl_delete [pairs]:* " @@ -1524,7 +1531,7 @@ class Telegram(RPCHandler): "*/weekly :* `Shows statistics per week, over the last n weeks`\n" "*/monthly :* `Shows statistics per month, over the last n months`\n" "*/stats:* `Shows Wins / losses by Sell reason as well as " - "Avg. holding durationsfor buys and sells.`\n" + "Avg. holding durations for buys and sells.`\n" "*/help:* `This help message`\n" "*/version:* `Show version`" ) diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 2c9528b5e..a30115bd9 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -1458,6 +1458,27 @@ def test_whitelist_static(default_conf, update, mocker) -> None: assert ("Using whitelist `['StaticPairList']` with 4 pairs\n" "`ETH/BTC, LTC/BTC, XRP/BTC, NEO/BTC`" in msg_mock.call_args_list[0][0][0]) + context = MagicMock() + context.args = ['sorted'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['StaticPairList']` with 4 pairs\n" + "`ETH/BTC, LTC/BTC, NEO/BTC, XRP/BTC`" in msg_mock.call_args_list[0][0][0]) + + context = MagicMock() + context.args = ['baseonly'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['StaticPairList']` with 4 pairs\n" + "`ETH, LTC, XRP, NEO`" in msg_mock.call_args_list[0][0][0]) + + context = MagicMock() + context.args = ['baseonly', 'sorted'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['StaticPairList']` with 4 pairs\n" + "`ETH, LTC, NEO, XRP`" in msg_mock.call_args_list[0][0][0]) + def test_whitelist_dynamic(default_conf, update, mocker) -> None: mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True)) @@ -1471,6 +1492,27 @@ def test_whitelist_dynamic(default_conf, update, mocker) -> None: assert ("Using whitelist `['VolumePairList']` with 4 pairs\n" "`ETH/BTC, LTC/BTC, XRP/BTC, NEO/BTC`" in msg_mock.call_args_list[0][0][0]) + context = MagicMock() + context.args = ['sorted'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['VolumePairList']` with 4 pairs\n" + "`ETH/BTC, LTC/BTC, NEO/BTC, XRP/BTC`" in msg_mock.call_args_list[0][0][0]) + + context = MagicMock() + context.args = ['baseonly'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['VolumePairList']` with 4 pairs\n" + "`ETH, LTC, XRP, NEO`" in msg_mock.call_args_list[0][0][0]) + + context = MagicMock() + context.args = ['baseonly', 'sorted'] + msg_mock.reset_mock() + telegram._whitelist(update=update, context=context) + assert ("Using whitelist `['VolumePairList']` with 4 pairs\n" + "`ETH, LTC, NEO, XRP`" in msg_mock.call_args_list[0][0][0]) + def test_blacklist_static(default_conf, update, mocker) -> None: