From 0bc9384451c22c70f3ad805b3701dec1d217838b Mon Sep 17 00:00:00 2001 From: ethan Date: Sat, 13 Nov 2021 14:52:59 -0500 Subject: [PATCH] more notification code consolidation --- freqtrade/rpc/telegram.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 63174024e..36bbf1a64 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -285,27 +285,22 @@ class Telegram(RPCHandler): else: msg['profit_extra'] = '' - # Sell Order Fill - if msg['type'] == RPCMessageType.SELL_FILL: - message = ("{emoji} *{exchange}:* Sold {pair} (#{trade_id})\n" - "*Profit:* `{profit_ratio:.2%}{profit_extra}`\n" - "*Buy Tag:* `{buy_tag}`\n" - "*Sell Reason:* `{sell_reason}`\n" - "*Duration:* `{duration} ({duration_min:.1f} min)`\n" - "*Amount:* `{amount:.8f}`\n" - "*Close Rate:* `{close_rate:.8f}`").format(**msg) + message = ("{emoji} *{exchange}:* Sold {pair} (#{trade_id})\n" + "*Profit:* `{profit_ratio:.2%}{profit_extra}`\n" + "*Buy Tag:* `{buy_tag}`\n" + "*Sell Reason:* `{sell_reason}`\n" + "*Duration:* `{duration} ({duration_min:.1f} min)`\n" + "*Amount:* `{amount:.8f}`\n").format(**msg) + + if msg['type'] == RPCMessageType.SELL: + message = message.replace('Sold', 'Selling').replace('Profit', 'Unrealized Profit') + message += ("*Open Rate:* `{open_rate:.8f}`\n" + "*Current Rate:* `{current_rate:.8f}`\n" + "*Close Rate:* `{limit:.8f}`").format(**msg) + + elif msg['type'] == RPCMessageType.SELL_FILL: + message += ("*Close Rate:* `{close_rate:.8f}`").format(**msg) - # Sell Order Ask - else: - message = ("{emoji} *{exchange}:* Selling {pair} (#{trade_id})\n" - "*Unrealized Profit:* `{profit_ratio:.2%}{profit_extra}`\n" - "*Buy Tag:* `{buy_tag}`\n" - "*Sell Reason:* `{sell_reason}`\n" - "*Duration:* `{duration} ({duration_min:.1f} min)`\n" - "*Amount:* `{amount:.8f}`\n" - "*Open Rate:* `{open_rate:.8f}`\n" - "*Current Rate:* `{current_rate:.8f}`\n" - "*Close Rate:* `{limit:.8f}`").format(**msg) return message def compose_message(self, msg: Dict[str, Any], msg_type: RPCMessageType) -> str: