From 2115a3ed125c2dc1310f8b382b5933cd6e32c0df Mon Sep 17 00:00:00 2001 From: Theagainmen <24569139+Theagainmen@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:49:10 +0100 Subject: [PATCH 1/2] Update warning message open trades This shouldn't confuse user when just reloading their bot. --- freqtrade/freqtradebot.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index d23ba270d..8ce3930ef 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -193,21 +193,22 @@ class FreqtradeBot(LoggingMixin): def check_for_open_trades(self): """ - Notify the user when the bot is stopped + Notify the user when the bot is stopped (not reloaded) and there are still open trades active. """ open_trades = Trade.get_trades([Trade.is_open.is_(True)]).all() if len(open_trades) != 0: - msg = { - 'type': RPCMessageType.WARNING, - 'status': f"{len(open_trades)} open trades active.\n\n" - f"Handle these trades manually on {self.exchange.name}, " - f"or '/start' the bot again and use '/stopbuy' " - f"to handle open trades gracefully. \n" - f"{'Trades are simulated.' if self.config['dry_run'] else ''}", - } - self.rpc.send_msg(msg) + if self.state != State.RELOAD_CONFIG: + msg = { + 'type': RPCMessageType.WARNING, + 'status': f"{len(open_trades)} open trades active.\n\n" + f"Handle these trades manually on {self.exchange.name}, " + f"or '/start' the bot again and use '/stopbuy' " + f"to handle open trades gracefully. \n" + f"{'Note: Trades are simulated (dry run).' if self.config['dry_run'] else ''}", + } + self.rpc.send_msg(msg) def _refresh_active_whitelist(self, trades: List[Trade] = []) -> List[str]: """ From 4595c1e73c08bf0a99d5ddf8d1084f091b17e688 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 7 Nov 2021 10:55:11 +0100 Subject: [PATCH 2/2] Slightly reformat to simplify new change --- freqtrade/freqtradebot.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 8ce3930ef..d29e6200d 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -198,17 +198,17 @@ class FreqtradeBot(LoggingMixin): """ open_trades = Trade.get_trades([Trade.is_open.is_(True)]).all() - if len(open_trades) != 0: - if self.state != State.RELOAD_CONFIG: - msg = { - 'type': RPCMessageType.WARNING, - 'status': f"{len(open_trades)} open trades active.\n\n" - f"Handle these trades manually on {self.exchange.name}, " - f"or '/start' the bot again and use '/stopbuy' " - f"to handle open trades gracefully. \n" - f"{'Note: Trades are simulated (dry run).' if self.config['dry_run'] else ''}", - } - self.rpc.send_msg(msg) + if len(open_trades) != 0 and self.state != State.RELOAD_CONFIG: + msg = { + 'type': RPCMessageType.WARNING, + 'status': + f"{len(open_trades)} open trades active.\n\n" + f"Handle these trades manually on {self.exchange.name}, " + f"or '/start' the bot again and use '/stopbuy' " + f"to handle open trades gracefully. \n" + f"{'Note: Trades are simulated (dry run).' if self.config['dry_run'] else ''}", + } + self.rpc.send_msg(msg) def _refresh_active_whitelist(self, trades: List[Trade] = []) -> List[str]: """