Prevent backtest starting when not in webserver mode

#6455
This commit is contained in:
Matthias
2022-02-25 07:40:49 +01:00
parent 42df65d4ec
commit 3b1b66bee8
3 changed files with 17 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ from typing import Any, Dict, Iterator, Optional
from fastapi import Depends
from freqtrade.enums import RunMode
from freqtrade.persistence import Trade
from freqtrade.rpc.rpc import RPC, RPCException
@@ -38,3 +39,9 @@ def get_exchange(config=Depends(get_config)):
ApiServer._exchange = ExchangeResolver.load_exchange(
config['exchange']['name'], config)
return ApiServer._exchange
def is_webserver_mode(config=Depends(get_config)):
if config['runmode'] != RunMode.WEBSERVER:
raise RPCException('Bot is not in the correct state')
return None