From aec496a73b244a7e18e08f885a95d4f4cd108603 Mon Sep 17 00:00:00 2001 From: Axel-CH Date: Fri, 7 Mar 2025 09:40:15 -0400 Subject: [PATCH] fix: update _rpc_list_custom_data with proper typing and custom_data collection loop --- freqtrade/rpc/rpc.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 68856c98a..31589492b 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -1121,6 +1121,7 @@ class RPC: """ Fetch custom data for a specific trade, or all open trades if `trade_id` is not provided. """ + trades: Sequence[Trade] if trade_id is None: # get all open trades trades = Trade.get_open_trades() @@ -1130,15 +1131,15 @@ class RPC: if not trades: return [] - # Collect custom data custom_data = [] - if key: - data = trades.get_custom_data(key=key) - if data: - custom_data = [data] - else: - for trade in trades: - custom_data.extend(trade.get_all_custom_data()) + for trade in trades: + # Collect custom data + if key: + data = trade.get_custom_data(key=key) + if data: + custom_data = [data] + + custom_data.extend(trade.get_all_custom_data()) # Format the results return [