Improve buy message FIAT formatting

This commit is contained in:
Matthias 2024-01-06 11:22:37 +01:00
parent 690a3599d0
commit 685fef1ee8
2 changed files with 8 additions and 13 deletions

View File

@ -311,11 +311,7 @@ class Telegram(RPCHandler):
return '' return ''
def _format_entry_msg(self, msg: Dict[str, Any]) -> str: 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] is_fill = msg['type'] in [RPCMessageType.ENTRY_FILL]
emoji = '\N{CHECK MARK}' if is_fill else '\N{LARGE BLUE CIRCLE}' 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"\ message += f"*Open Rate:* `{msg['open_rate']:.8f}`\n"\
f"*Current Rate:* `{msg['current_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"*Total:* `{total}{profit_fiat_extra}`"
message += f", {round_coin_value(msg['stake_amount_fiat'], msg['fiat_currency'])}"
message += ")`"
return message return message
def _format_exit_msg(self, msg: Dict[str, Any]) -> str: def _format_exit_msg(self, msg: Dict[str, Any]) -> str:

View File

@ -2024,7 +2024,7 @@ def test_send_msg_enter_notification(default_conf, mocker, caplog, message_type,
f'{leverage_text}' f'{leverage_text}'
'*Open Rate:* `0.00001099`\n' '*Open Rate:* `0.00001099`\n'
'*Current 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'} 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' '*Amount:* `1333.33333333`\n'
f"{leverage_text}" f"{leverage_text}"
'*Open Rate:* `0.00001099`\n' '*Open Rate:* `0.00001099`\n'
'*Total:* `(0.01465333 BTC, 180.895 USD)`' '*Total:* `0.01465333 BTC / 180.895 USD`'
) )
msg_mock.reset_mock() 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' '*Amount:* `1333.33333333`\n'
f"{leverage_text}" f"{leverage_text}"
'*Open Rate:* `0.00001099`\n' '*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}' f'{leverage_text}'
'*Open Rate:* `0.00001099`\n' '*Open Rate:* `0.00001099`\n'
'*Current Rate:* `0.00001099`\n' '*Current Rate:* `0.00001099`\n'
'*Total:* `(0.01465333 BTC)`' '*Total:* `0.01465333 BTC`'
) )