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,14 +1131,14 @@ class RPC:
if not trades: if not trades:
return [] return []
# Collect custom data
custom_data = [] custom_data = []
for trade in trades:
# Collect custom data
if key: if key:
data = trades.get_custom_data(key=key) data = trade.get_custom_data(key=key)
if data: if data:
custom_data = [data] custom_data = [data]
else:
for trade in trades:
custom_data.extend(trade.get_all_custom_data()) custom_data.extend(trade.get_all_custom_data())
# Format the results # Format the results