Add response_models for new endpoints

This commit is contained in:
Matthias
2023-11-11 14:43:24 +01:00
parent de68850d28
commit 2ef716e94c
2 changed files with 34 additions and 10 deletions
+24
View File
@@ -95,6 +95,30 @@ class Count(BaseModel):
total_stake: float total_stake: float
class Entry(BaseModel):
enter_tag: str
profit_ratio: float
profit_pct: float
profit_abs: float
count: int
class Exit(BaseModel):
exit_reason: str
profit_ratio: float
profit_pct: float
profit_abs: float
count: int
class MixTag(BaseModel):
mix_tag: str
profit: float
profit_pct: float
profit_abs: float
count: int
class PerformanceEntry(BaseModel): class PerformanceEntry(BaseModel):
pair: str pair: str
profit: float profit: float
+10 -10
View File
@@ -12,15 +12,15 @@ from freqtrade.exceptions import OperationalException
from freqtrade.rpc import RPC from freqtrade.rpc import RPC
from freqtrade.rpc.api_server.api_schemas import (AvailablePairs, Balances, BlacklistPayload, from freqtrade.rpc.api_server.api_schemas import (AvailablePairs, Balances, BlacklistPayload,
BlacklistResponse, Count, DailyWeeklyMonthly, BlacklistResponse, Count, DailyWeeklyMonthly,
DeleteLockRequest, DeleteTrade, DeleteLockRequest, DeleteTrade, Entry,
ExchangeListResponse, ForceEnterPayload, ExchangeListResponse, Exit, ForceEnterPayload,
ForceEnterResponse, ForceExitPayload, ForceEnterResponse, ForceExitPayload,
FreqAIModelListResponse, Health, Locks, Logs, FreqAIModelListResponse, Health, Locks, Logs,
OpenTradeSchema, PairHistory, PerformanceEntry, MixTag, OpenTradeSchema, PairHistory,
Ping, PlotConfig, Profit, ResultMsg, ShowConfig, PerformanceEntry, Ping, PlotConfig, Profit,
Stats, StatusMsg, StrategyListResponse, ResultMsg, ShowConfig, Stats, StatusMsg,
StrategyResponse, SysInfo, Version, StrategyListResponse, StrategyResponse, SysInfo,
WhitelistResponse) Version, WhitelistResponse)
from freqtrade.rpc.api_server.deps import get_config, get_exchange, get_rpc, get_rpc_optional from freqtrade.rpc.api_server.deps import get_config, get_exchange, get_rpc, get_rpc_optional
from freqtrade.rpc.rpc import RPCException from freqtrade.rpc.rpc import RPCException
@@ -84,17 +84,17 @@ def count(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_count() return rpc._rpc_count()
@router.get('/entries', tags=['info']) @router.get('/entries', response_model=List[Entry], tags=['info'])
def entries(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): def entries(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)):
return rpc._rpc_enter_tag_performance(pair) return rpc._rpc_enter_tag_performance(pair)
@router.get('/exits', tags=['info']) @router.get('/exits', response_model=List[Exit], tags=['info'])
def exits(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): def exits(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)):
return rpc._rpc_exit_reason_performance(pair) return rpc._rpc_exit_reason_performance(pair)
@router.get('/mix_tags', tags=['info']) @router.get('/mix_tags', response_model=List[MixTag], tags=['info'])
def mix_tags(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)): def mix_tags(pair: Optional[str] = None, rpc: RPC = Depends(get_rpc)):
return rpc._rpc_mix_tag_performance(pair) return rpc._rpc_mix_tag_performance(pair)