diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index d4dc6ef73..539bbcb38 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1597,14 +1597,14 @@ class FreqtradeBot(LoggingMixin): # second condition is for mypy only; order will always be passed during sub trade if sub_trade and order is not None: amount = order.safe_filled if fill else order.amount - profit_rate = order.safe_price + order_rate: float = order.safe_price - profit = trade.calc_profit(rate=profit_rate, amount=amount, open_rate=trade.open_rate) - profit_ratio = trade.calc_profit_ratio(profit_rate, amount, trade.open_rate) + profit = trade.calc_profit(rate=order_rate, amount=amount, open_rate=trade.open_rate) + profit_ratio = trade.calc_profit_ratio(order_rate, amount, trade.open_rate) else: - profit_rate = trade.close_rate if trade.close_rate else trade.close_rate_requested - profit = trade.calc_profit(rate=profit_rate) + (0.0 if fill else trade.realized_profit) - profit_ratio = trade.calc_profit_ratio(profit_rate) + order_rate = trade.close_rate if trade.close_rate else trade.close_rate_requested + profit = trade.calc_profit(rate=order_rate) + (0.0 if fill else trade.realized_profit) + profit_ratio = trade.calc_profit_ratio(order_rate) amount = trade.amount gain = "profit" if profit_ratio > 0 else "loss" @@ -1617,11 +1617,12 @@ class FreqtradeBot(LoggingMixin): 'leverage': trade.leverage, 'direction': 'Short' if trade.is_short else 'Long', 'gain': gain, - 'limit': profit_rate, + 'limit': order_rate, # Deprecated + 'order_rate': order_rate, 'order_type': order_type, 'amount': amount, 'open_rate': trade.open_rate, - 'close_rate': profit_rate, + 'close_rate': order_rate, 'current_rate': current_rate, 'profit_amount': profit, 'profit_ratio': profit_ratio, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index c40bdb963..247373817 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -286,7 +286,7 @@ class Telegram(RPCHandler): if msg['type'] in [RPCMessageType.ENTRY_FILL]: message += f"*Open Rate:* `{msg['open_rate']:.8f}`\n" elif msg['type'] in [RPCMessageType.ENTRY]: - message += f"*Open Rate:* `{msg['limit']:.8f}`\n"\ + 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'])}" @@ -353,8 +353,9 @@ class Telegram(RPCHandler): f"*Open Rate:* `{msg['open_rate']:.8f}`\n" ) if msg['type'] == RPCMessageType.EXIT: - message += (f"*Current Rate:* `{msg['current_rate']:.8f}`\n" - f"*Exit Rate:* `{msg['limit']:.8f}`") + message += f"*Current Rate:* `{msg['current_rate']:.8f}`\n" + if msg['order_rate']: + message += f"*Exit Rate:* `{msg['order_rate']:.8f}`" elif msg['type'] == RPCMessageType.EXIT_FILL: message += f"*Exit Rate:* `{msg['close_rate']:.8f}`"