mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-17 13:21:15 +00:00
fix: endpoints
This commit is contained in:
@@ -535,7 +535,16 @@ def sysinfo():
|
||||
def health(rpc: RPC = Depends(get_rpc)):
|
||||
return rpc.health()
|
||||
|
||||
@router.get("/trades/{tradeid}/custom-data", response_model=list[ListCustomData], tags=["info"])
|
||||
@router.get("/trades/open/custom-data", response_model=list[ListCustomData], tags=["info"])
|
||||
def list_open_trades_custom_data(rpc: RPC = Depends(get_rpc)):
|
||||
"""
|
||||
Fetch custom data for all open trades.
|
||||
"""
|
||||
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)):
|
||||
custom_data = rpc._rpc_list_custom_data(trade_id)
|
||||
return custom_data
|
||||
"""
|
||||
Fetch custom data for a specific trade.
|
||||
"""
|
||||
return rpc._rpc_list_custom_data(trade_id)
|
||||
|
||||
@@ -7,7 +7,7 @@ from abc import abstractmethod
|
||||
from collections.abc import Generator, Sequence
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from math import isnan
|
||||
from typing import Any
|
||||
from typing import Any, Optional
|
||||
|
||||
import psutil
|
||||
from dateutil.relativedelta import relativedelta
|
||||
@@ -1097,9 +1097,11 @@ class RPC:
|
||||
"cancel_order_count": c_count,
|
||||
}
|
||||
|
||||
def _rpc_list_custom_data(self, trade_id: int) -> list[dict[str, Any]]:
|
||||
# Query trades based on trade_id
|
||||
if trade_id == -1:
|
||||
def _rpc_list_custom_data(self, trade_id: Optional[int] = 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
|
||||
trades = Trade.get_open_trades()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user