diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index c9b0d0a4b..daecad465 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -311,11 +311,7 @@ class Telegram(RPCHandler): return '' def _format_entry_msg(self, msg: Dict[str, Any]) -> str: - if self._rpc._fiat_converter: - msg['stake_amount_fiat'] = self._rpc._fiat_converter.convert_amount( - msg['stake_amount'], msg['stake_currency'], msg['fiat_currency']) - else: - msg['stake_amount_fiat'] = 0 + is_fill = msg['type'] in [RPCMessageType.ENTRY_FILL] emoji = '\N{CHECK MARK}' if is_fill else '\N{LARGE BLUE CIRCLE}' @@ -338,12 +334,11 @@ class Telegram(RPCHandler): message += f"*Open Rate:* `{msg['open_rate']:.8f}`\n"\ f"*Current Rate:* `{msg['current_rate']:.8f}`\n" - message += f"*Total:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}" + profit_fiat_extra = self.__format_profit_fiat(msg, 'stake_amount') + total = round_coin_value(msg['stake_amount'], msg['stake_currency']) - if msg.get('fiat_currency'): - message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}" + message += f"*Total:* `{total}{profit_fiat_extra}`" - message += ")`" return message def _format_exit_msg(self, msg: Dict[str, Any]) -> str: diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 88ce6393e..bef7b62e7 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -2024,7 +2024,7 @@ def test_send_msg_enter_notification(default_conf, mocker, caplog, message_type, f'{leverage_text}' '*Open Rate:* `0.00001099`\n' '*Current Rate:* `0.00001099`\n' - '*Total:* `(0.01465333 BTC, 180.895 USD)`' + '*Total:* `0.01465333 BTC / 180.895 USD`' ) freqtradebot.config['telegram']['notification_settings'] = {'buy': 'off'} @@ -2125,7 +2125,7 @@ def test_send_msg_entry_fill_notification(default_conf, mocker, message_type, en '*Amount:* `1333.33333333`\n' f"{leverage_text}" '*Open Rate:* `0.00001099`\n' - '*Total:* `(0.01465333 BTC, 180.895 USD)`' + '*Total:* `0.01465333 BTC / 180.895 USD`' ) msg_mock.reset_mock() @@ -2152,7 +2152,7 @@ def test_send_msg_entry_fill_notification(default_conf, mocker, message_type, en '*Amount:* `1333.33333333`\n' f"{leverage_text}" '*Open Rate:* `0.00001099`\n' - '*Total:* `(0.01465333 BTC, 180.895 USD)`' + '*Total:* `0.01465333 BTC / 180.895 USD`' ) @@ -2441,7 +2441,7 @@ def test_send_msg_buy_notification_no_fiat( f'{leverage_text}' '*Open Rate:* `0.00001099`\n' '*Current Rate:* `0.00001099`\n' - '*Total:* `(0.01465333 BTC)`' + '*Total:* `0.01465333 BTC`' )