diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 69f38e524..248b4a421 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -131,11 +131,11 @@ class RPC: current_rate = NAN current_profit = trade.calc_profit_ratio(current_rate) fmt_close_profit = (f'{round(trade.close_profit * 100, 2):.2f}%' - if trade.close_profit else None) + if trade.close_profit is not None else None) trade_dict = trade.to_json() trade_dict.update(dict( base_currency=self._freqtrade.config['stake_currency'], - close_profit=trade.close_profit or None, + close_profit=trade.close_profit if trade.close_profit is not None else None, close_profit_pct=fmt_close_profit, current_rate=current_rate, current_profit=current_profit, diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 77c72bb2a..488fa9f37 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -215,13 +215,15 @@ class Telegram(RPC): "*Open Rate:* `{open_rate:.8f}`", "*Close Rate:* `{close_rate}`" if r['close_rate'] else "", "*Current Rate:* `{current_rate:.8f}`", - "*Close Profit:* `{close_profit_pct}`" if r['close_profit_pct'] else "", + ("*Close Profit:* `{close_profit_pct}`" + if r['close_profit_pct'] is not None else ""), "*Current Profit:* `{current_profit_pct:.2f}%`", # Adding initial stoploss only if it is different from stoploss "*Initial Stoploss:* `{initial_stop_loss:.8f}` " + - ("`({initial_stop_loss_pct:.2f}%)`" if r['initial_stop_loss_pct'] else "") - if r['stop_loss'] != r['initial_stop_loss'] else "", + ("`({initial_stop_loss_pct:.2f}%)`") if ( + r['stop_loss'] != r['initial_stop_loss'] + and r['initial_stop_loss_pct'] is not None) else "", # Adding stoploss and stoploss percentage only if it is not None "*Stoploss:* `{stop_loss:.8f}` " +