have edge send multiple messages if necessary

closes #4519
This commit is contained in:
Matthias 2021-05-08 19:43:31 +02:00
parent 0ca0ed4117
commit 2157923aee
3 changed files with 21 additions and 4 deletions

View File

@ -240,7 +240,7 @@ class Edge:
return self._final_pairs return self._final_pairs
def accepted_pairs(self) -> list: def accepted_pairs(self) -> List[Dict[str, Any]]:
""" """
return a list of accepted pairs along with their winrate, expectancy and stoploss return a list of accepted pairs along with their winrate, expectancy and stoploss
""" """

View File

@ -861,9 +861,17 @@ class Telegram(RPCHandler):
""" """
try: try:
edge_pairs = self._rpc._rpc_edge() edge_pairs = self._rpc._rpc_edge()
edge_pairs_tab = tabulate(edge_pairs, headers='keys', tablefmt='simple') if not edge_pairs:
message = f'<b>Edge only validated following pairs:</b>\n<pre>{edge_pairs_tab}</pre>' message = '<b>Edge only validated following pairs:</b>'
self._send_msg(message, parse_mode=ParseMode.HTML) self._send_msg(message, parse_mode=ParseMode.HTML)
for chunk in chunks(edge_pairs, 25):
edge_pairs_tab = tabulate(chunk, headers='keys', tablefmt='simple')
message = (f'<b>Edge only validated following pairs:</b>\n'
f'<pre>{edge_pairs_tab}</pre>')
self._send_msg(message, parse_mode=ParseMode.HTML)
except RPCException as e: except RPCException as e:
self._send_msg(str(e)) self._send_msg(str(e))

View File

@ -1102,6 +1102,15 @@ def test_edge_enabled(edge_conf, update, mocker) -> None:
assert '<b>Edge only validated following pairs:</b>\n<pre>' in msg_mock.call_args_list[0][0][0] assert '<b>Edge only validated following pairs:</b>\n<pre>' in msg_mock.call_args_list[0][0][0]
assert 'Pair Winrate Expectancy Stoploss' in msg_mock.call_args_list[0][0][0] assert 'Pair Winrate Expectancy Stoploss' in msg_mock.call_args_list[0][0][0]
msg_mock.reset_mock()
mocker.patch('freqtrade.edge.Edge._cached_pairs', mocker.PropertyMock(
return_value={}))
telegram._edge(update=update, context=MagicMock())
assert msg_mock.call_count == 1
assert '<b>Edge only validated following pairs:</b>' in msg_mock.call_args_list[0][0][0]
assert 'Winrate' not in msg_mock.call_args_list[0][0][0]
def test_telegram_trades(mocker, update, default_conf, fee): def test_telegram_trades(mocker, update, default_conf, fee):