fix: update _rpc_list_custom_data with proper typing and custom_data collection loop

This commit is contained in:
Axel-CH
2025-03-07 09:40:15 -04:00
parent 7bc1398574
commit aec496a73b

View File

@@ -1121,6 +1121,7 @@ class RPC:
""" """
Fetch custom data for a specific trade, or all open trades if `trade_id` is not provided. 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: if trade_id is None:
# get all open trades # get all open trades
trades = Trade.get_open_trades() trades = Trade.get_open_trades()
@@ -1130,15 +1131,15 @@ class RPC:
if not trades: if not trades:
return [] return []
# Collect custom data
custom_data = [] custom_data = []
if key: for trade in trades:
data = trades.get_custom_data(key=key) # Collect custom data
if data: if key:
custom_data = [data] data = trade.get_custom_data(key=key)
else: if data:
for trade in trades: custom_data = [data]
custom_data.extend(trade.get_all_custom_data())
custom_data.extend(trade.get_all_custom_data())
# Format the results # Format the results
return [ return [