mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
chore: improved response on delete order
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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."
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user