Enhance some response models
This commit is contained in:
@@ -112,6 +112,60 @@ class Daily(BaseModel):
|
||||
stake_currency: str
|
||||
|
||||
|
||||
class TradeSchema(BaseModel):
|
||||
trade_id: str
|
||||
pair: str
|
||||
is_open: bool
|
||||
exchange: str
|
||||
amount: float
|
||||
amount_requested: float
|
||||
stake_amount: float
|
||||
strategy: str
|
||||
timeframe: str
|
||||
fee_open: Optional[float]
|
||||
fee_open_cost: Optional[float]
|
||||
fee_open_currency: Optional[str]
|
||||
fee_close: Optional[float]
|
||||
fee_close_cost: Optional[float]
|
||||
fee_close_currency: Optional[str]
|
||||
open_date_hum: str
|
||||
open_date: str
|
||||
open_timestamp: int
|
||||
open_rate: float
|
||||
open_rate_requested: Optional[float]
|
||||
open_trade_value: float
|
||||
close_date_hum: Optional[str]
|
||||
close_date: Optional[str]
|
||||
close_timestamp: Optional[int]
|
||||
close_rate: Optional[float]
|
||||
close_rate_requested: Optional[float]
|
||||
close_profit: Optional[float]
|
||||
close_profit_pct: Optional[float]
|
||||
close_profit_abs: Optional[float]
|
||||
profit_ratio: Optional[float]
|
||||
profit_pct: Optional[float]
|
||||
profit_abs: Optional[float]
|
||||
sell_reason: Optional[str]
|
||||
sell_order_status: Optional[str]
|
||||
stop_loss_abs: Optional[float]
|
||||
stop_loss_ratio: Optional[float]
|
||||
stop_loss_pct: Optional[float]
|
||||
stoploss_order_id: Optional[str]
|
||||
stoploss_last_update: Optional[str]
|
||||
stoploss_last_update_timestamp: Optional[int]
|
||||
initial_stop_loss_abs: Optional[float]
|
||||
initial_stop_loss_ratio: Optional[float]
|
||||
initial_stop_loss_pct: Optional[float]
|
||||
min_rate: Optional[float]
|
||||
max_rate: Optional[float]
|
||||
open_order_id: Optional[str]
|
||||
|
||||
|
||||
class TradeResponse(BaseModel):
|
||||
trades: List[TradeSchema]
|
||||
trades_count: int
|
||||
|
||||
|
||||
class LockModel(BaseModel):
|
||||
active: bool
|
||||
lock_end_time: str
|
||||
|
@@ -15,7 +15,7 @@ from freqtrade.rpc.api_server.api_models import (AvailablePairs, Balances, Black
|
||||
ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
||||
PairHistory, PerformanceEntry, Ping, PlotConfig,
|
||||
Profit, ResultMsg, Stats, StatusMsg,
|
||||
StrategyListResponse, StrategyResponse, Version,
|
||||
StrategyListResponse, StrategyResponse, TradeResponse, TradeSchema, Version,
|
||||
WhitelistResponse)
|
||||
from freqtrade.rpc.api_server.deps import get_config, get_rpc
|
||||
from freqtrade.rpc.rpc import RPCException
|
||||
@@ -74,7 +74,7 @@ def daily(timescale: int = 7, rpc: RPC = Depends(get_rpc), config=Depends(get_co
|
||||
|
||||
|
||||
# TODO: Missing response model
|
||||
@router.get('/status', tags=['info'])
|
||||
@router.get('/status', response_model=List[TradeSchema], tags=['info'])
|
||||
def status(rpc: RPC = Depends(get_rpc)):
|
||||
try:
|
||||
return rpc._rpc_trade_status()
|
||||
@@ -82,8 +82,7 @@ def status(rpc: RPC = Depends(get_rpc)):
|
||||
return []
|
||||
|
||||
|
||||
# TODO: Missing response model
|
||||
@router.get('/trades', tags=['info', 'trading'])
|
||||
@router.get('/trades', response_model=TradeResponse, tags=['info', 'trading'])
|
||||
def trades(limit: int = 0, rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_trade_history(limit)
|
||||
|
||||
@@ -105,8 +104,7 @@ def show_config(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
|
||||
return RPC._rpc_show_config(config, rpc._freqtrade.state)
|
||||
|
||||
|
||||
# TODO: Missing response model
|
||||
@router.post('/forcebuy', tags=['trading'])
|
||||
@router.post('/forcebuy', response_model=Union[TradeSchema, StatusMsg], tags=['trading'])
|
||||
def forcebuy(payload: ForceBuyPayload, rpc: RPC = Depends(get_rpc)):
|
||||
trade = rpc._rpc_forcebuy(payload.pair, payload.price)
|
||||
|
||||
|
Reference in New Issue
Block a user