Add response-model for show_config

This commit is contained in:
Matthias 2021-01-02 15:48:33 +01:00
parent ca0bb7bbb8
commit cff50f9f66
3 changed files with 26 additions and 4 deletions

View File

@ -112,6 +112,29 @@ class Daily(BaseModel):
stake_currency: str
class ShowConfig(BaseModel):
dry_run: str
stake_currency: str
stake_amount: float
max_open_trades: int
minimal_roi: Dict[str, Any]
stoploss: float
trailing_stop: bool
trailing_stop_positive: Optional[float]
trailing_stop_positive_offset: Optional[float]
trailing_only_offset_is_reached: Optional[bool]
timeframe: str
timeframe_ms: int
timeframe_min: int
exchange: str
strategy: str
forcebuy_enabled: bool
ask_strategy: Dict[str, Any]
bid_strategy: Dict[str, Any]
state: str
runmode: str
class TradeSchema(BaseModel):
trade_id: int
pair: str

View File

@ -15,7 +15,7 @@ from freqtrade.rpc.api_server.api_schemas import (AvailablePairs, Balances, Blac
ForceBuyPayload, ForceBuyResponse,
ForceSellPayload, Locks, Logs, OpenTradeSchema,
PairHistory, PerformanceEntry, Ping, PlotConfig,
Profit, ResultMsg, Stats, StatusMsg,
Profit, ResultMsg, ShowConfig, Stats, StatusMsg,
StrategyListResponse, StrategyResponse,
TradeResponse, Version, WhitelistResponse)
from freqtrade.rpc.api_server.deps import get_config, get_rpc, get_rpc_optional
@ -98,8 +98,7 @@ def edge(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_edge()
# TODO: Missing response model
@router.get('/show_config', tags=['info'])
@router.get('/show_config', response_model=ShowConfig, tags=['info'])
def show_config(rpc: Optional[RPC] = Depends(get_rpc_optional), config=Depends(get_config)):
state = ''
if rpc:

View File

@ -111,7 +111,7 @@ class RPC:
self._fiat_converter = CryptoToFiatConverter()
@staticmethod
def _rpc_show_config(config, botstate: State) -> Dict[str, Any]:
def _rpc_show_config(config, botstate: Union[State, str]) -> Dict[str, Any]:
"""
Return a dict of config options.
Explicitly does NOT return the full config to avoid leakage of sensitive