Improve response models
This commit is contained in:
parent
9350f505bc
commit
9f873305eb
@ -2,10 +2,9 @@ import secrets
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
from fastapi.security.http import HTTPBasic, HTTPBasicCredentials
|
from fastapi.security.http import HTTPBasic, HTTPBasicCredentials
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
from freqtrade.rpc.api_server2.api_models import AccessAndRefreshToken, AccessToken
|
from freqtrade.rpc.api_server2.api_models import AccessAndRefreshToken, AccessToken
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
|
from datetime import date, datetime
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
from datetime import date
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from freqtrade.constants import DATETIME_PRINT_FORMAT
|
||||||
|
|
||||||
|
|
||||||
class Ping(BaseModel):
|
class Ping(BaseModel):
|
||||||
status: str
|
status: str
|
||||||
@ -181,3 +184,26 @@ class AvailablePairs(BaseModel):
|
|||||||
length: int
|
length: int
|
||||||
pairs: List[str]
|
pairs: List[str]
|
||||||
pair_interval: List[List[str]]
|
pair_interval: List[List[str]]
|
||||||
|
|
||||||
|
|
||||||
|
class PairHistory(BaseModel):
|
||||||
|
strategy: str
|
||||||
|
pair: str
|
||||||
|
timeframe: str
|
||||||
|
timeframe_ms: int
|
||||||
|
columns: List[str]
|
||||||
|
data: List[Any]
|
||||||
|
length: int
|
||||||
|
buy_signals: int
|
||||||
|
sell_signals: int
|
||||||
|
last_analyzed: datetime
|
||||||
|
last_analyzed_ts: int
|
||||||
|
data_start_ts: int
|
||||||
|
data_start: str
|
||||||
|
data_stop: str
|
||||||
|
data_stop_ts: int
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
json_encoders = {
|
||||||
|
datetime: lambda v: v.strftime(DATETIME_PRINT_FORMAT),
|
||||||
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from freqtrade.constants import USERPATH_STRATEGIES
|
|
||||||
from typing import Dict, List, Optional, Union
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from fastapi.exceptions import HTTPException
|
from fastapi.exceptions import HTTPException
|
||||||
|
|
||||||
from freqtrade import __version__
|
from freqtrade import __version__
|
||||||
|
from freqtrade.constants import USERPATH_STRATEGIES
|
||||||
from freqtrade.data.history import get_datahandler
|
from freqtrade.data.history import get_datahandler
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.rpc import RPC
|
from freqtrade.rpc import RPC
|
||||||
@ -14,7 +14,8 @@ from freqtrade.rpc.rpc import RPCException
|
|||||||
|
|
||||||
from .api_models import (AvailablePairs, Balances, BlacklistPayload, BlacklistResponse, Count,
|
from .api_models import (AvailablePairs, Balances, BlacklistPayload, BlacklistResponse, Count,
|
||||||
Daily, DeleteTrade, ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
Daily, DeleteTrade, ForceBuyPayload, ForceSellPayload, Locks, Logs,
|
||||||
PerformanceEntry, Ping, PlotConfig, Profit, ResultMsg, Stats, StatusMsg, StrategyListResponse, StrategyResponse, Version,
|
PairHistory, PerformanceEntry, Ping, PlotConfig, Profit, ResultMsg, Stats,
|
||||||
|
StatusMsg, StrategyListResponse, StrategyResponse, Version,
|
||||||
WhitelistResponse)
|
WhitelistResponse)
|
||||||
from .deps import get_config, get_rpc
|
from .deps import get_config, get_rpc
|
||||||
|
|
||||||
@ -164,14 +165,12 @@ def reload_config(rpc: RPC = Depends(get_rpc)):
|
|||||||
return rpc._rpc_reload_config()
|
return rpc._rpc_reload_config()
|
||||||
|
|
||||||
|
|
||||||
# TODO: Missing response model
|
@router.get('/pair_candles', response_model=PairHistory, tags=['candle data'])
|
||||||
@router.get('/pair_candles', tags=['candle data'])
|
|
||||||
def pair_candles(pair: str, timeframe: str, limit: Optional[int], rpc=Depends(get_rpc)):
|
def pair_candles(pair: str, timeframe: str, limit: Optional[int], rpc=Depends(get_rpc)):
|
||||||
return rpc._rpc_analysed_dataframe(pair, timeframe, limit)
|
return rpc._rpc_analysed_dataframe(pair, timeframe, limit)
|
||||||
|
|
||||||
|
|
||||||
# TODO: Missing response model
|
@router.get('/pair_history', response_model=PairHistory, tags=['candle data'])
|
||||||
@router.get('/pair_history', tags=['candle data'])
|
|
||||||
def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
|
def pair_history(pair: str, timeframe: str, timerange: str, strategy: str,
|
||||||
config=Depends(get_config)):
|
config=Depends(get_config)):
|
||||||
config = deepcopy(config)
|
config = deepcopy(config)
|
||||||
|
Loading…
Reference in New Issue
Block a user