Simplify api schema by not using union types

This commit is contained in:
Matthias 2022-02-15 20:01:35 +01:00
parent dfd5d3b8b2
commit 3787b747ae
3 changed files with 8 additions and 5 deletions

View File

@ -32,6 +32,10 @@ async def api_start_backtest(bt_settings: BacktestRequest, background_tasks: Bac
for setting in settings.keys():
if settings[setting] is not None:
btconfig[setting] = settings[setting]
try:
btconfig['stake_amount'] = float(btconfig['stake_amount'])
except ValueError:
pass
# Force dry-run for backtesting
btconfig['dry_run'] = True
@ -57,8 +61,7 @@ async def api_start_backtest(bt_settings: BacktestRequest, background_tasks: Bac
):
from freqtrade.optimize.backtesting import Backtesting
ApiServer._bt = Backtesting(btconfig)
if ApiServer._bt.timeframe_detail:
ApiServer._bt.load_bt_data_detail()
ApiServer._bt.load_bt_data_detail()
else:
ApiServer._bt.config = btconfig
ApiServer._bt.init_backtest()

View File

@ -149,7 +149,7 @@ class ShowConfig(BaseModel):
api_version: float
dry_run: bool
stake_currency: str
stake_amount: Union[float, str]
stake_amount: str
available_capital: Optional[float]
stake_currency_decimals: int
max_open_trades: int
@ -366,7 +366,7 @@ class BacktestRequest(BaseModel):
timeframe_detail: Optional[str]
timerange: Optional[str]
max_open_trades: Optional[int]
stake_amount: Optional[Union[float, str]]
stake_amount: Optional[str]
enable_protections: bool
dry_run_wallet: Optional[float]

View File

@ -112,7 +112,7 @@ class RPC:
'dry_run': config['dry_run'],
'stake_currency': config['stake_currency'],
'stake_currency_decimals': decimals_per_coin(config['stake_currency']),
'stake_amount': config['stake_amount'],
'stake_amount': str(config['stake_amount']),
'available_capital': config.get('available_capital'),
'max_open_trades': (config['max_open_trades']
if config['max_open_trades'] != float('inf') else -1),