diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 9d6696803..7e431ece9 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -431,14 +431,15 @@ class RPC: if not trade.is_open: profit_ratio = trade.close_profit - profit_closed_coin.append(trade.close_profit_abs) + profit_abs = trade.close_profit_abs + profit_closed_coin.append(profit_abs) profit_closed_ratio.append(profit_ratio) if trade.close_profit >= 0: winning_trades += 1 - winning_profit += trade.close_profit_abs + winning_profit += profit_abs else: losing_trades += 1 - losing_profit += trade.close_profit_abs + losing_profit += profit_abs else: # Get current rate try: @@ -447,10 +448,10 @@ class RPC: except (PricingError, ExchangeError): current_rate = NAN profit_ratio = trade.calc_profit_ratio(rate=current_rate) + profit_abs = trade.calc_profit( + rate=trade.close_rate or current_rate) + trade.realized_profit - profit_all_coin.append( - trade.calc_profit(rate=trade.close_rate or current_rate) - ) + profit_all_coin.append(profit_abs) profit_all_ratio.append(profit_ratio) best_pair = Trade.get_best_pair(start_date) diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index c6507d0ae..b7161e680 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -717,11 +717,11 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets): ( True, {'best_pair': 'ETC/BTC', 'best_rate': -0.5, 'best_pair_profit_ratio': -0.005, - 'profit_all_coin': 43.61269123, - 'profit_all_fiat': 538398.67323435, 'profit_all_percent_mean': 66.41, + 'profit_all_coin': 45.561959, + 'profit_all_fiat': 562462.39126200, 'profit_all_percent_mean': 66.41, 'profit_all_ratio_mean': 0.664109545, 'profit_all_percent_sum': 398.47, - 'profit_all_ratio_sum': 3.98465727, 'profit_all_percent': 4.36, - 'profit_all_ratio': 0.043612222872799825, 'profit_closed_coin': -0.00673913, + 'profit_all_ratio_sum': 3.98465727, 'profit_all_percent': 4.56, + 'profit_all_ratio': 0.04556147, 'profit_closed_coin': -0.00673913, 'profit_closed_fiat': -83.19455985, 'profit_closed_ratio_mean': -0.0075, 'profit_closed_percent_mean': -0.75, 'profit_closed_ratio_sum': -0.015, 'profit_closed_percent_sum': -1.5, 'profit_closed_ratio': -6.739057628404269e-06, @@ -732,11 +732,11 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets): ( False, {'best_pair': 'XRP/BTC', 'best_rate': 1.0, 'best_pair_profit_ratio': 0.01, - 'profit_all_coin': -44.0631579, - 'profit_all_fiat': -543959.6842755, 'profit_all_percent_mean': -66.41, + 'profit_all_coin': -45.79641127, + 'profit_all_fiat': -565356.69712815, 'profit_all_percent_mean': -66.41, 'profit_all_ratio_mean': -0.6641100666666667, 'profit_all_percent_sum': -398.47, - 'profit_all_ratio_sum': -3.9846604, 'profit_all_percent': -4.41, - 'profit_all_ratio': -0.044063014216106644, 'profit_closed_coin': 0.00073913, + 'profit_all_ratio_sum': -3.9846604, 'profit_all_percent': -4.58, + 'profit_all_ratio': -0.045796261934205953, 'profit_closed_coin': 0.00073913, 'profit_closed_fiat': 9.124559849999999, 'profit_closed_ratio_mean': 0.0075, 'profit_closed_percent_mean': 0.75, 'profit_closed_ratio_sum': 0.015, 'profit_closed_percent_sum': 1.5, 'profit_closed_ratio': 7.391275897987988e-07, @@ -747,11 +747,11 @@ def test_api_edge_disabled(botclient, mocker, ticker, fee, markets): ( None, {'best_pair': 'XRP/BTC', 'best_rate': 1.0, 'best_pair_profit_ratio': 0.01, - 'profit_all_coin': -14.43790415, - 'profit_all_fiat': -178235.92673175, 'profit_all_percent_mean': 0.08, + 'profit_all_coin': -14.94732578, + 'profit_all_fiat': -184524.7367541, 'profit_all_percent_mean': 0.08, 'profit_all_ratio_mean': 0.000835751666666662, 'profit_all_percent_sum': 0.5, - 'profit_all_ratio_sum': 0.005014509999999972, 'profit_all_percent': -1.44, - 'profit_all_ratio': -0.014437768014451796, 'profit_closed_coin': -0.00542913, + 'profit_all_ratio_sum': 0.005014509999999972, 'profit_all_percent': -1.49, + 'profit_all_ratio': -0.014947184841095841, 'profit_closed_coin': -0.00542913, 'profit_closed_fiat': -67.02260985, 'profit_closed_ratio_mean': 0.0025, 'profit_closed_percent_mean': 0.25, 'profit_closed_ratio_sum': 0.005, 'profit_closed_percent_sum': 0.5, 'profit_closed_ratio': -5.429078808526421e-06,