From e90c60c940618af6425bc92da2284f0fd03443ff Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 7 Jul 2025 19:20:48 +0200 Subject: [PATCH] chore: improved response on delete order --- freqtrade/rpc/rpc.py | 7 +++++-- freqtrade/rpc/telegram.py | 2 +- tests/rpc/test_rpc_apiserver.py | 4 ++-- tests/rpc/test_rpc_telegram.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 6bc779d05..00a280d34 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -1115,13 +1115,16 @@ class RPC: c_count += 1 except ExchangeError: pass - + trade_pair = trade.pair trade.delete() self._freqtrade.wallets.update() return { "result": "success", "trade_id": trade_id, - "result_msg": f"Deleted trade {trade_id}. Closed {c_count} open orders.", + "result_msg": ( + f"Deleted trade #{trade_id} for pair {trade_pair}. " + f"Closed {c_count} open orders." + ), "cancel_order_count": c_count, } diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 7230a8681..d864fa7a4 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -1484,7 +1484,7 @@ class Telegram(RPCHandler): trade_id = int(context.args[0]) msg = self._rpc._rpc_delete(trade_id) await self._send_msg( - f"`{msg['result_msg']}`\n" + f"{msg['result_msg']}\n" "Please make sure to take care of this asset on the exchange manually." ) diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index fb85e1b80..573130a4a 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -1048,7 +1048,7 @@ def test_api_delete_trade(botclient, mocker, fee, markets, is_short): rc = client_delete(client, f"{BASE_URI}/trades/1") assert_response(rc) - assert rc.json()["result_msg"] == "Deleted trade 1. Closed 1 open orders." + assert rc.json()["result_msg"] == "Deleted trade #1 for pair ETH/BTC. Closed 1 open orders." assert len(trades) - 1 == len(Trade.session.scalars(select(Trade)).all()) assert cancel_mock.call_count == 1 @@ -1061,7 +1061,7 @@ def test_api_delete_trade(botclient, mocker, fee, markets, is_short): assert len(trades) - 1 == len(Trade.session.scalars(select(Trade)).all()) rc = client_delete(client, f"{BASE_URI}/trades/5") assert_response(rc) - assert rc.json()["result_msg"] == "Deleted trade 5. Closed 1 open orders." + assert rc.json()["result_msg"] == "Deleted trade #5 for pair XRP/BTC. Closed 1 open orders." assert len(trades) - 2 == len(Trade.session.scalars(select(Trade)).all()) assert stoploss_mock.call_count == 1 diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 30420b1d6..460352fff 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -2001,7 +2001,7 @@ async def test_telegram_delete_trade(mocker, update, default_conf, fee, is_short context.args = [1] await telegram._delete_trade(update=update, context=context) assert msg_mock.call_count == 1 - assert "Deleted trade 1." in msg_mock.call_args_list[0][0][0] + assert "Deleted trade #1" in msg_mock.call_args_list[0][0][0] assert "Please make sure to take care of this asset" in msg_mock.call_args_list[0][0][0]