diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index ec341ff0a..0595e0d35 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -962,7 +962,9 @@ class FreqtradeBot: 'current_rate': current_rate, 'profit_amount': profit_trade, 'profit_percent': profit_percent, - 'sell_reason': trade.sell_reason + 'sell_reason': trade.sell_reason, + 'open_date': trade.open_date, + 'close_date': trade.close_date or datetime.utcnow() } # For regular case, when the configuration exists diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 2ae22f472..859700019 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -9,7 +9,7 @@ from typing import Any, Callable, Dict from tabulate import tabulate from telegram import ParseMode, ReplyKeyboardMarkup, Update from telegram.error import NetworkError, TelegramError -from telegram.ext import CommandHandler, Updater, CallbackContext +from telegram.ext import CallbackContext, CommandHandler, Updater from freqtrade.__init__ import __version__ from freqtrade.rpc import RPC, RPCException, RPCMessageType @@ -144,6 +144,8 @@ class Telegram(RPC): elif msg['type'] == RPCMessageType.SELL_NOTIFICATION: msg['amount'] = round(msg['amount'], 8) msg['profit_percent'] = round(msg['profit_percent'] * 100, 2) + msg['duration'] = msg['close_date'].replace( + microsecond=0) - msg['open_date'].replace(microsecond=0) message = ("*{exchange}:* Selling {pair}\n" "*Rate:* `{limit:.8f}`\n" @@ -151,6 +153,7 @@ class Telegram(RPC): "*Open Rate:* `{open_rate:.8f}`\n" "*Current Rate:* `{current_rate:.8f}`\n" "*Sell Reason:* `{sell_reason}`\n" + "*Duration:* `{duration}`\n" "*Profit:* `{profit_percent:.2f}%`").format(**msg) # Check if all sell properties are available.