Simplify api schema by not using union types
This commit is contained in:
parent
dfd5d3b8b2
commit
3787b747ae
@ -32,6 +32,10 @@ async def api_start_backtest(bt_settings: BacktestRequest, background_tasks: Bac
|
|||||||
for setting in settings.keys():
|
for setting in settings.keys():
|
||||||
if settings[setting] is not None:
|
if settings[setting] is not None:
|
||||||
btconfig[setting] = settings[setting]
|
btconfig[setting] = settings[setting]
|
||||||
|
try:
|
||||||
|
btconfig['stake_amount'] = float(btconfig['stake_amount'])
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Force dry-run for backtesting
|
# Force dry-run for backtesting
|
||||||
btconfig['dry_run'] = True
|
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
|
from freqtrade.optimize.backtesting import Backtesting
|
||||||
ApiServer._bt = Backtesting(btconfig)
|
ApiServer._bt = Backtesting(btconfig)
|
||||||
if ApiServer._bt.timeframe_detail:
|
ApiServer._bt.load_bt_data_detail()
|
||||||
ApiServer._bt.load_bt_data_detail()
|
|
||||||
else:
|
else:
|
||||||
ApiServer._bt.config = btconfig
|
ApiServer._bt.config = btconfig
|
||||||
ApiServer._bt.init_backtest()
|
ApiServer._bt.init_backtest()
|
||||||
|
@ -149,7 +149,7 @@ class ShowConfig(BaseModel):
|
|||||||
api_version: float
|
api_version: float
|
||||||
dry_run: bool
|
dry_run: bool
|
||||||
stake_currency: str
|
stake_currency: str
|
||||||
stake_amount: Union[float, str]
|
stake_amount: str
|
||||||
available_capital: Optional[float]
|
available_capital: Optional[float]
|
||||||
stake_currency_decimals: int
|
stake_currency_decimals: int
|
||||||
max_open_trades: int
|
max_open_trades: int
|
||||||
@ -366,7 +366,7 @@ class BacktestRequest(BaseModel):
|
|||||||
timeframe_detail: Optional[str]
|
timeframe_detail: Optional[str]
|
||||||
timerange: Optional[str]
|
timerange: Optional[str]
|
||||||
max_open_trades: Optional[int]
|
max_open_trades: Optional[int]
|
||||||
stake_amount: Optional[Union[float, str]]
|
stake_amount: Optional[str]
|
||||||
enable_protections: bool
|
enable_protections: bool
|
||||||
dry_run_wallet: Optional[float]
|
dry_run_wallet: Optional[float]
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class RPC:
|
|||||||
'dry_run': config['dry_run'],
|
'dry_run': config['dry_run'],
|
||||||
'stake_currency': config['stake_currency'],
|
'stake_currency': config['stake_currency'],
|
||||||
'stake_currency_decimals': decimals_per_coin(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'),
|
'available_capital': config.get('available_capital'),
|
||||||
'max_open_trades': (config['max_open_trades']
|
'max_open_trades': (config['max_open_trades']
|
||||||
if config['max_open_trades'] != float('inf') else -1),
|
if config['max_open_trades'] != float('inf') else -1),
|
||||||
|
Loading…
Reference in New Issue
Block a user