From dd10dec73d6f025b40bee247ab5f5aa9901720d4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 28 Feb 2023 20:31:02 +0100 Subject: [PATCH] Improve variable wording --- freqtrade/rpc/api_server/api_schemas.py | 3 +++ freqtrade/rpc/rpc.py | 12 ++++++------ freqtrade/rpc/telegram.py | 6 +++--- tests/rpc/test_rpc.py | 8 ++++---- tests/rpc/test_rpc_apiserver.py | 2 ++ tests/rpc/test_rpc_telegram.py | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index bb30678ab..562c9aa7d 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -283,6 +283,9 @@ class OpenTradeSchema(TradeSchema): stoploss_entry_dist: Optional[float] stoploss_entry_dist_ratio: Optional[float] current_rate: float + total_profit_abs: float + total_profit_fiat: Optional[float] + open_order: Optional[str] diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 230079cad..82f892101 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -169,7 +169,7 @@ class RPC: for trade in trades: order: Optional[Order] = None current_profit_fiat: Optional[float] = None - combined_profit_fiat: Optional[float] = None + total_profit_fiat: Optional[float] = None if trade.open_order_id: order = trade.select_order_by_order_id(trade.open_order_id) # calculate profit and send message to user @@ -191,7 +191,7 @@ class RPC: current_rate = trade.close_rate current_profit = trade.close_profit current_profit_abs = trade.close_profit_abs - combined_profit_abs = trade.realized_profit + current_profit_abs + total_profit_abs = trade.realized_profit + current_profit_abs # Calculate fiat profit if not isnan(current_profit_abs) and self._fiat_converter: @@ -200,8 +200,8 @@ class RPC: self._freqtrade.config['stake_currency'], self._freqtrade.config['fiat_display_currency'] ) - combined_profit_fiat = self._fiat_converter.convert_amount( - combined_profit_abs, + total_profit_fiat = self._fiat_converter.convert_amount( + total_profit_abs, self._freqtrade.config['stake_currency'], self._freqtrade.config['fiat_display_currency'] ) @@ -222,8 +222,8 @@ class RPC: profit_abs=current_profit_abs, profit_fiat=current_profit_fiat, - combined_profit_abs=combined_profit_abs, - combined_profit_fiat=combined_profit_fiat, + total_profit_abs=total_profit_abs, + total_profit_fiat=total_profit_fiat, stoploss_current_dist=stoploss_current_dist, stoploss_current_dist_ratio=round(stoploss_current_dist_ratio, 8), stoploss_current_dist_pct=round(stoploss_current_dist_ratio * 100, 2), diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 18e412bbb..7bbeea2a2 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -565,8 +565,8 @@ class Telegram(RPCHandler): r['stake_amount_r'] = round_coin_value(r['stake_amount'], r['quote_currency']) r['profit_abs_r'] = round_coin_value(r['profit_abs'], r['quote_currency']) r['realized_profit_r'] = round_coin_value(r['realized_profit'], r['quote_currency']) - r['combined_profit_abs_r'] = round_coin_value( - r['combined_profit_abs'], r['quote_currency']) + r['total_profit_abs_r'] = round_coin_value( + r['total_profit_abs'], r['quote_currency']) lines = [ "*Trade ID:* `{trade_id}`" + (" `(since {open_date_hum})`" if r['is_open'] else ""), @@ -595,7 +595,7 @@ class Telegram(RPCHandler): if r['is_open']: if r.get('realized_profit'): lines.append("*Realized Profit:* `{realized_profit_r}`") - lines.append("*Total Profit:* `{combined_profit_abs_r}` ") + lines.append("*Total Profit:* `{total_profit_abs_r}` ") if (r['stop_loss_abs'] != r['initial_stop_loss_abs'] and r['initial_stop_loss_ratio'] is not None): diff --git a/tests/rpc/test_rpc.py b/tests/rpc/test_rpc.py index 734eb7cf1..3eb391edd 100644 --- a/tests/rpc/test_rpc.py +++ b/tests/rpc/test_rpc.py @@ -76,8 +76,8 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None: 'stoploss_entry_dist_ratio': -0.10376381, 'open_order': None, 'realized_profit': 0.0, - 'combined_profit_abs': -4.09e-06, - 'combined_profit_fiat': ANY, + 'total_profit_abs': -4.09e-06, + 'total_profit_fiat': ANY, 'exchange': 'binance', 'leverage': 1.0, 'interest_rate': 0.0, @@ -121,7 +121,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None: 'profit_ratio': 0.0, 'profit_pct': 0.0, 'profit_abs': 0.0, - 'combined_profit_abs': 0.0, + 'total_profit_abs': 0.0, 'stop_loss_abs': 0.0, 'stop_loss_pct': None, 'stop_loss_ratio': None, @@ -183,7 +183,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None: 'profit_ratio': ANY, 'profit_pct': ANY, 'profit_abs': ANY, - 'combined_profit_abs': ANY, + 'total_profit_abs': ANY, 'current_rate': ANY, }) assert results[0] == response_norate diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index 3697fac05..67156da45 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -1012,6 +1012,8 @@ def test_api_status(botclient, mocker, ticker, fee, markets, is_short, 'profit_pct': ANY, 'profit_abs': ANY, 'profit_fiat': ANY, + 'total_profit_abs': ANY, + 'total_profit_fiat': ANY, 'realized_profit': 0.0, 'current_rate': current_rate, 'open_date': ANY, diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 2a60f0b42..65e676860 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -205,7 +205,7 @@ def test_telegram_status(default_conf, update, mocker) -> None: 'profit_ratio': -0.0059, 'profit_abs': -0.225, 'realized_profit': 0.0, - 'combined_profit_abs': -0.225, + 'total_profit_abs': -0.225, 'initial_stop_loss_abs': 1.098e-05, 'stop_loss_abs': 1.099e-05, 'exit_order_status': None,