From a177e58dc4d7b64d082136ae27233fb778318646 Mon Sep 17 00:00:00 2001 From: ethan Date: Sat, 13 Nov 2021 08:49:02 -0500 Subject: [PATCH] Remove "currency" generating from splitting pair str --- freqtrade/rpc/telegram.py | 14 ++++++-------- tests/rpc/test_rpc_telegram.py | 14 +++++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 11574c1f7..7bb5b71f9 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -219,7 +219,6 @@ class Telegram(RPCHandler): else: msg['stake_amount_fiat'] = 0 - msg['currency'] = msg['pair'].split('/')[0] content = [] content.append( f"\N{LARGE BLUE CIRCLE} *{msg['exchange']}:* Buying {msg['pair']}" @@ -227,7 +226,7 @@ class Telegram(RPCHandler): ) if msg.get('buy_tag', None): content.append(f"*Buy Tag:* `{msg['buy_tag']}`\n") - content.append(f"*Amount:* `{msg['amount']:.8f}` {msg['currency']}\n") + content.append(f"*Amount:* `{msg['amount']:.8f}`\n") content.append(f"*Open Rate:* `{msg['limit']:.8f}`\n") content.append(f"*Current Rate:* `{msg['current_rate']:.8f}`\n") content.append( @@ -249,7 +248,6 @@ class Telegram(RPCHandler): else: msg['stake_amount_fiat'] = 0 - msg['currency'] = msg['pair'].split('/')[0] content = [] content.append( f"\N{CHECK MARK} *{msg['exchange']}:* Bought {msg['pair']}" @@ -257,7 +255,7 @@ class Telegram(RPCHandler): ) if msg.get('buy_tag', None): content.append(f"*Buy Tag:* `{msg['buy_tag']}`\n") - content.append(f"*Amount:* `{msg['amount']:.8f}` {msg['currency']}\n") + content.append(f"*Amount:* `{msg['amount']:.8f}`\n") content.append(f"*Open Rate:* `{msg['open_rate']:.8f}`\n") content.append( f"*Total:* `({round_coin_value(msg['stake_amount'], msg['stake_currency'])}" @@ -291,13 +289,13 @@ class Telegram(RPCHandler): ' / {profit_fiat:.3f} {fiat_currency})').format(**msg) else: msg['profit_extra'] = '' - msg['currency'] = msg['pair'].split('/')[0] + 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}` {currency}\n" + "*Amount:* `{amount:.8f}`\n" "*Open Rate:* `{open_rate:.8f}`\n" "*Current Rate:* `{current_rate:.8f}`\n" "*Close Rate:* `{limit:.8f}`").format(**msg) @@ -326,13 +324,13 @@ class Telegram(RPCHandler): ' / {profit_fiat:.3f} {fiat_currency})').format(**msg) else: msg['profit_extra'] = '' - msg['currency'] = msg['pair'].split('/')[0] + 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}` {currency}\n" + "*Amount:* `{amount:.8f}`\n" "*Close Rate:* `{close_rate:.8f}`").format(**msg) return message diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 0b4ff968b..95a2f4549 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -1613,7 +1613,7 @@ def test_send_msg_buy_notification(default_conf, mocker, caplog) -> None: assert msg_mock.call_args[0][0] \ == '\N{LARGE BLUE CIRCLE} *Binance:* Buying ETH/BTC (#1)\n' \ '*Buy Tag:* `buy_signal_01`\n' \ - '*Amount:* `1333.33333333` ETH\n' \ + '*Amount:* `1333.33333333`\n' \ '*Open Rate:* `0.00001099`\n' \ '*Current Rate:* `0.00001099`\n' \ '*Total:* `(0.00100000 BTC, 12.345 USD)`' @@ -1702,7 +1702,7 @@ def test_send_msg_buy_fill_notification(default_conf, mocker) -> None: assert msg_mock.call_args[0][0] \ == '\N{CHECK MARK} *Binance:* Bought ETH/BTC (#1)\n' \ '*Buy Tag:* `buy_signal_01`\n' \ - '*Amount:* `1333.33333333` ETH\n' \ + '*Amount:* `1333.33333333`\n' \ '*Open Rate:* `0.00001099`\n' \ '*Total:* `(0.00100000 BTC, 12.345 USD)`' @@ -1739,7 +1739,7 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None: '*Buy Tag:* `buy_signal1`\n' '*Sell Reason:* `stop_loss`\n' '*Duration:* `1:00:00 (60.0 min)`\n' - '*Amount:* `1333.33333333` KEY\n' + '*Amount:* `1333.33333333`\n' '*Open Rate:* `0.00007500`\n' '*Current Rate:* `0.00003201`\n' '*Close Rate:* `0.00003201`' @@ -1771,7 +1771,7 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None: '*Buy Tag:* `buy_signal1`\n' '*Sell Reason:* `stop_loss`\n' '*Duration:* `1 day, 2:30:00 (1590.0 min)`\n' - '*Amount:* `1333.33333333` KEY\n' + '*Amount:* `1333.33333333`\n' '*Open Rate:* `0.00007500`\n' '*Current Rate:* `0.00003201`\n' '*Close Rate:* `0.00003201`' @@ -1842,7 +1842,7 @@ def test_send_msg_sell_fill_notification(default_conf, mocker) -> None: '*Buy Tag:* `buy_signal1`\n' '*Sell Reason:* `stop_loss`\n' '*Duration:* `1 day, 2:30:00 (1590.0 min)`\n' - '*Amount:* `1333.33333333` KEY\n' + '*Amount:* `1333.33333333`\n' '*Close Rate:* `0.00003201`' ) @@ -1905,7 +1905,7 @@ def test_send_msg_buy_notification_no_fiat(default_conf, mocker) -> None: }) assert msg_mock.call_args[0][0] == ('\N{LARGE BLUE CIRCLE} *Binance:* Buying ETH/BTC (#1)\n' '*Buy Tag:* `buy_signal_01`\n' - '*Amount:* `1333.33333333` ETH\n' + '*Amount:* `1333.33333333`\n' '*Open Rate:* `0.00001099`\n' '*Current Rate:* `0.00001099`\n' '*Total:* `(0.00100000 BTC)`') @@ -1940,7 +1940,7 @@ def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None: '*Buy Tag:* `buy_signal1`\n' '*Sell Reason:* `stop_loss`\n' '*Duration:* `2:35:03 (155.1 min)`\n' - '*Amount:* `1333.33333333` KEY\n' + '*Amount:* `1333.33333333`\n' '*Open Rate:* `0.00007500`\n' '*Current Rate:* `0.00003201`\n' '*Close Rate:* `0.00003201`'