diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index b8d80ceb1..51736968b 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -12,7 +12,6 @@ from telegram.error import NetworkError, TelegramError from telegram.ext import CallbackContext, CommandHandler, Updater from freqtrade.__init__ import __version__ -from freqtrade.misc import plural from freqtrade.rpc import RPC, RPCException, RPCMessageType from freqtrade.rpc.fiat_convert import CryptoToFiatConverter @@ -147,8 +146,7 @@ class Telegram(RPC): msg['profit_percent'] = round(msg['profit_percent'] * 100, 2) msg['duration'] = msg['close_date'].replace( microsecond=0) - msg['open_date'].replace(microsecond=0) - duration_tmp = msg['duration'].total_seconds() // 60 - msg['duration_mins'] = f"{duration_tmp:.0f} {plural(duration_tmp, 'min')}" + msg['duration_min'] = msg['duration'].total_seconds() / 60 message = ("*{exchange}:* Selling {pair}\n" "*Rate:* `{limit:.8f}`\n" @@ -156,7 +154,7 @@ class Telegram(RPC): "*Open Rate:* `{open_rate:.8f}`\n" "*Current Rate:* `{current_rate:.8f}`\n" "*Sell Reason:* `{sell_reason}`\n" - "*Duration:* `{duration} ({duration_mins})`\n" + "*Duration:* `{duration} ({duration_min:.1f} min)`\n" "*Profit:* `{profit_percent:.2f}%`").format(**msg) # Check if all sell properties are available. diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 7c1dd7983..7c4a8f0d6 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -1241,7 +1241,7 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None: '*Open Rate:* `0.00007500`\n' '*Current Rate:* `0.00003201`\n' '*Sell Reason:* `stop_loss`\n' - '*Duration:* `1:00:00 (60 mins)`\n' + '*Duration:* `1:00:00 (60.0 min)`\n' '*Profit:* `-57.41%`` (loss: -0.05746268 ETH`` / -24.812 USD)`') msg_mock.reset_mock() @@ -1269,7 +1269,7 @@ def test_send_msg_sell_notification(default_conf, mocker) -> None: '*Open Rate:* `0.00007500`\n' '*Current Rate:* `0.00003201`\n' '*Sell Reason:* `stop_loss`\n' - '*Duration:* `1 day, 2:30:00 (1590 mins)`\n' + '*Duration:* `1 day, 2:30:00 (1590.0 min)`\n' '*Profit:* `-57.41%`') # Reset singleton function to avoid random breaks telegram._fiat_converter.convert_amount = old_convamount @@ -1400,7 +1400,7 @@ def test_send_msg_sell_notification_no_fiat(default_conf, mocker) -> None: '*Open Rate:* `0.00007500`\n' \ '*Current Rate:* `0.00003201`\n' \ '*Sell Reason:* `stop_loss`\n' \ - '*Duration:* `2:35:03 (155 mins)`\n' \ + '*Duration:* `2:35:03 (155.1 min)`\n' \ '*Profit:* `-57.41%`'