diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index e09cf9bff..c75dc4e2c 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1824,6 +1824,8 @@ class FreqtradeBot(LoggingMixin): 'fiat_currency': self.config.get('fiat_display_currency'), 'sub_trade': sub_trade, 'cumulative_profit': trade.realized_profit, + 'final_profit_ratio': trade.close_profit if not trade.is_open else None, + 'is_final_exit': trade.is_open is False, } # Send the message diff --git a/freqtrade/rpc/rpc_types.py b/freqtrade/rpc/rpc_types.py index c7403dc0f..8deb93067 100644 --- a/freqtrade/rpc/rpc_types.py +++ b/freqtrade/rpc/rpc_types.py @@ -86,6 +86,8 @@ class RPCExitMsg(__RPCEntryExitMsgBase): close_date: datetime # current_rate: Optional[float] order_rate: Optional[float] + final_profit_ratio: Optional[float] + is_final_exit: bool class RPCExitCancelMsg(__RPCEntryExitMsgBase): diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index f0d5af3a4..480a76361 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -373,21 +373,29 @@ class Telegram(RPCHandler): f"{msg['profit_extra']})") is_fill = msg['type'] == RPCMessageType.EXIT_FILL + is_final_exit = msg.get('is_final_exit', False) is_sub_trade = msg.get('sub_trade') is_sub_profit = msg['profit_amount'] != msg.get('cumulative_profit') profit_prefix = ('Sub ' if is_sub_profit else 'Cumulative ') if is_sub_trade else '' cp_extra = '' exit_wording = 'Exited' if is_fill else 'Exiting' - if is_sub_profit and is_sub_trade: + if (is_sub_profit and is_sub_trade) or is_final_exit: if self._rpc._fiat_converter: cp_fiat = self._rpc._fiat_converter.convert_amount( msg['cumulative_profit'], msg['stake_currency'], msg['fiat_currency']) cp_extra = f" / {cp_fiat:.3f} {msg['fiat_currency']}" - exit_wording = f"Partially {exit_wording.lower()}" - cp_extra = ( - f"*Cumulative Profit:* (`{msg['cumulative_profit']:.8f} " - f"{msg['stake_currency']}{cp_extra}`)\n" - ) + if is_final_exit: + profit_prefix = 'Sub ' + cp_extra = ( + f"*Final Profit:* `{msg['final_profit_ratio']:.2%} " + f"({msg['cumulative_profit']:.8f} {msg['stake_currency']}{cp_extra})`\n" + ) + else: + exit_wording = f"Partially {exit_wording.lower()}" + cp_extra = ( + f"*Cumulative Profit:* `({msg['cumulative_profit']:.8f} " + f"{msg['stake_currency']}{cp_extra})`\n" + ) message = ( f"{msg['emoji']} *{self._exchange_from_msg(msg)}:* "