From 4e8999ade3e8e9d39a5e78d175b736ed6d6b7dc1 Mon Sep 17 00:00:00 2001 From: Erwin Hoeckx Date: Mon, 22 Mar 2021 20:40:11 +0100 Subject: [PATCH 1/4] Changed the code for status table a bit so that it splits up the trades per 50 trades, to make sure it can be sent regardless of number of trades Signed-off-by: Erwin Hoeckx --- freqtrade/rpc/telegram.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 7ec67e5d0..2d753db70 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -330,8 +330,12 @@ class Telegram(RPCHandler): statlist, head = self._rpc._rpc_status_table( self._config['stake_currency'], self._config.get('fiat_display_currency', '')) - message = tabulate(statlist, headers=head, tablefmt='simple') - self._send_msg(f"
{message}
", parse_mode=ParseMode.HTML) + max_trades_per_msg = 50 + for i in range(0, max(int(len(statlist) / max_trades_per_msg), 1)): + message = tabulate(statlist[i * max_trades_per_msg:(i + 1) * max_trades_per_msg], + headers=head, + tablefmt='simple') + self._send_msg(f"
{message}
", parse_mode=ParseMode.HTML) except RPCException as e: self._send_msg(str(e)) From c928cd38dc2e5a67fcf70d7a76d350f5b7549560 Mon Sep 17 00:00:00 2001 From: Erwin Hoeckx Date: Tue, 23 Mar 2021 16:45:42 +0100 Subject: [PATCH 2/4] Small bugfix to make sure it shows all the trades Signed-off-by: Erwin Hoeckx --- freqtrade/rpc/telegram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 2d753db70..b83cbf1a2 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -331,7 +331,7 @@ class Telegram(RPCHandler): self._config['stake_currency'], self._config.get('fiat_display_currency', '')) max_trades_per_msg = 50 - for i in range(0, max(int(len(statlist) / max_trades_per_msg), 1)): + for i in range(0, max(int(len(statlist) / max_trades_per_msg) + 1, 1)): message = tabulate(statlist[i * max_trades_per_msg:(i + 1) * max_trades_per_msg], headers=head, tablefmt='simple') From 65a9763fa587aa42823956cd4e207f08905e7906 Mon Sep 17 00:00:00 2001 From: Erwin Hoeckx Date: Tue, 23 Mar 2021 16:54:38 +0100 Subject: [PATCH 3/4] Fixed an issue when there were exactly 50 trades, it was sending an extra empty table Signed-off-by: Erwin Hoeckx --- freqtrade/rpc/telegram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index b83cbf1a2..61a0188cb 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -331,7 +331,7 @@ class Telegram(RPCHandler): self._config['stake_currency'], self._config.get('fiat_display_currency', '')) max_trades_per_msg = 50 - for i in range(0, max(int(len(statlist) / max_trades_per_msg) + 1, 1)): + for i in range(0, max(int(len(statlist) / max_trades_per_msg + 0.99), 1)): message = tabulate(statlist[i * max_trades_per_msg:(i + 1) * max_trades_per_msg], headers=head, tablefmt='simple') From 2fd510e6e4e8a2108f2a64c6ccad72f83fb047d7 Mon Sep 17 00:00:00 2001 From: Erwin Hoeckx Date: Tue, 23 Mar 2021 21:52:46 +0100 Subject: [PATCH 4/4] Added comment with an example calculation Signed-off-by: Erwin Hoeckx --- freqtrade/rpc/telegram.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 61a0188cb..2063a4f58 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -331,6 +331,11 @@ class Telegram(RPCHandler): self._config['stake_currency'], self._config.get('fiat_display_currency', '')) max_trades_per_msg = 50 + """ + Calculate the number of messages of 50 trades per message + 0.99 is used to make sure that there are no extra (empty) messages + As an example with 50 trades, there will be int(50/50 + 0.99) = 1 message + """ for i in range(0, max(int(len(statlist) / max_trades_per_msg + 0.99), 1)): message = tabulate(statlist[i * max_trades_per_msg:(i + 1) * max_trades_per_msg], headers=head,