From 83e56a09c2d135b11ba02b101996071f4dc616bc Mon Sep 17 00:00:00 2001 From: David Arena Date: Tue, 17 Dec 2024 19:22:02 +0100 Subject: [PATCH] fix: api url and rm key --- freqtrade/rpc/rpc.py | 19 +++++++------------ ft_client/freqtrade_client/ft_rest_client.py | 9 +++------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 68b749450..905bc78aa 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -1097,26 +1097,21 @@ class RPC: "cancel_order_count": c_count, } - def _rpc_list_custom_data(self, trade_id: int | None = None, key: str | None = None) -> list[dict[str, Any]]: + def _rpc_list_custom_data(self, trade_id: int) -> list[dict[str, Any]]: # Query trades based on trade_id - if trade_id: - trades = Trade.get_trades(trade_filter=[Trade.id == trade_id]).all() - else: - # If no trade_id, get all open trades + if trade_id == -1: + #get all open trades trades = Trade.get_open_trades() + else: + trades = Trade.get_trades(trade_filter=[Trade.id == trade_id]).all() if not trades: return [] - + # Collect custom data custom_data = [] for trade in trades: - if key: - data = trade.get_custom_data(key=key) - if data: - custom_data.append(data) - else: - custom_data.extend(trade.get_all_custom_data()) + custom_data.extend(trade.get_all_custom_data()) # Format the results return [ diff --git a/ft_client/freqtrade_client/ft_rest_client.py b/ft_client/freqtrade_client/ft_rest_client.py index bd6617f73..39844b60b 100755 --- a/ft_client/freqtrade_client/ft_rest_client.py +++ b/ft_client/freqtrade_client/ft_rest_client.py @@ -477,17 +477,14 @@ class FtRestClient: def list_custom_data(self, trade_id=None, key=None): """Lists custom_data of the running bot. - Without a tradeid, returns all custom_data from open trades. - :param tradeid: Optional keyword argument - Id of the trade (can be received via status command) - :param key: Optional keyword argument - Key of the custom data + :param tradeid: Optional keyword argument - Id of the trade :return: json object """ params = {} + trade_id = -1 if trade_id is not None: params["trade_id"] = trade_id - if key is not None: - params["key"] = key - return self._get("list_custom_data", params=params) + return self._get("trades/{tradeid}/custom_data", params=params)