fix: formating

This commit is contained in:
David Arena
2025-02-14 12:44:42 +01:00
parent a1a5cab04e
commit ceff757bc6
3 changed files with 6 additions and 2 deletions

View File

@@ -638,6 +638,7 @@ class Health(BaseModel):
bot_startup: datetime | None = None
bot_startup_ts: int | None = None
class ListCustomData(BaseModel):
trade_id: int
custom_data: list[dict[str, Any]]

View File

@@ -510,6 +510,7 @@ def sysinfo():
def health(rpc: RPC = Depends(get_rpc)):
return rpc.health()
@router.get("/trades/open/custom-data", response_model=list[ListCustomData], tags=["info"])
def list_open_trades_custom_data(rpc: RPC = Depends(get_rpc)):
"""
@@ -517,6 +518,7 @@ def list_open_trades_custom_data(rpc: RPC = Depends(get_rpc)):
"""
return rpc._rpc_list_custom_data()
@router.get("/trades/{trade_id}/custom-data", response_model=list[ListCustomData], tags=["info"])
def list_custom_data(trade_id: int, rpc: RPC = Depends(get_rpc)):
"""

View File

@@ -1117,12 +1117,13 @@ class RPC:
}
def _rpc_list_custom_data(
self, trade_id: int | None = None, key: str | None = None) -> list[dict[str, Any]]:
self, trade_id: int | None = None, key: str | None = None
) -> list[dict[str, Any]]:
"""
Fetch custom data for a specific trade, or all open trades if `trade_id` is not provided.
"""
if trade_id is None:
#get all open trades
# get all open trades
trades = Trade.get_open_trades()
else:
trades = Trade.get_trades(trade_filter=[Trade.id == trade_id]).all()