Improve naming of apiserver variables
This commit is contained in:
parent
ad26b0dad0
commit
52ae95b2a5
@ -390,6 +390,6 @@ class Arguments:
|
||||
|
||||
# Add webserver subcommand
|
||||
webserver_cmd = subparsers.add_parser('webserver', help='Webserver module.',
|
||||
parents=[_common_parser, _strategy_parser])
|
||||
parents=[_common_parser])
|
||||
webserver_cmd.set_defaults(func=start_webserver)
|
||||
self._build_args(optionlist=ARGS_WEBSERVER, parser=webserver_cmd)
|
||||
|
@ -40,35 +40,39 @@ async def api_start_backtest(bt_settings: BacktestRequest, background_tasks: Bac
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
try:
|
||||
# Reload strategy
|
||||
lastconfig = ApiServer._lastbacktestconfig
|
||||
lastconfig = ApiServer._bt_last_config
|
||||
strat = StrategyResolver.load_strategy(btconfig)
|
||||
|
||||
if (not ApiServer._bt
|
||||
if (
|
||||
not ApiServer._bt
|
||||
or lastconfig.get('timeframe') != strat.timeframe
|
||||
or lastconfig.get('dry_run_wallet') != btconfig.get('dry_run_wallet', 0)):
|
||||
or lastconfig.get('dry_run_wallet') != btconfig.get('dry_run_wallet', 0)
|
||||
):
|
||||
from freqtrade.optimize.backtesting import Backtesting
|
||||
ApiServer._bt = Backtesting(btconfig)
|
||||
|
||||
# Only reload data if timeframe or timerange changed.
|
||||
if (not ApiServer._backtestdata or not ApiServer._bt_timerange
|
||||
if (
|
||||
not ApiServer._bt_data
|
||||
or not ApiServer._bt_timerange
|
||||
or lastconfig.get('timerange') != btconfig['timerange']
|
||||
or lastconfig.get('stake_amount') != btconfig.get('stake_amount')
|
||||
or lastconfig.get('enable_protections') != btconfig.get('enable_protections')
|
||||
or lastconfig.get('protections') != btconfig.get('protections', [])
|
||||
or lastconfig.get('timeframe') != strat.timeframe):
|
||||
or lastconfig.get('timeframe') != strat.timeframe
|
||||
):
|
||||
lastconfig['timerange'] = btconfig['timerange']
|
||||
lastconfig['protections'] = btconfig.get('protections', [])
|
||||
lastconfig['enable_protections'] = btconfig.get('enable_protections')
|
||||
lastconfig['dry_run_wallet'] = btconfig.get('dry_run_wallet')
|
||||
lastconfig['timeframe'] = strat.timeframe
|
||||
ApiServer._backtestdata, ApiServer._bt_timerange = ApiServer._bt.load_bt_data()
|
||||
ApiServer._bt_data, ApiServer._bt_timerange = ApiServer._bt.load_bt_data()
|
||||
|
||||
ApiServer._bt.abort = False
|
||||
min_date, max_date = ApiServer._bt.backtest_one_strategy(
|
||||
strat, ApiServer._backtestdata,
|
||||
ApiServer._bt_timerange)
|
||||
strat, ApiServer._bt_data, ApiServer._bt_timerange)
|
||||
ApiServer._bt.results = generate_backtest_stats(
|
||||
ApiServer._backtestdata, ApiServer._bt.all_results,
|
||||
ApiServer._bt_data, ApiServer._bt.all_results,
|
||||
min_date=min_date, max_date=max_date)
|
||||
logger.info("Backtest finished.")
|
||||
|
||||
@ -140,8 +144,8 @@ def api_delete_backtest():
|
||||
if ApiServer._bt:
|
||||
del ApiServer._bt
|
||||
ApiServer._bt = None
|
||||
del ApiServer._backtestdata
|
||||
ApiServer._backtestdata = None
|
||||
del ApiServer._bt_data
|
||||
ApiServer._bt_data = None
|
||||
logger.info("Backtesting reset")
|
||||
return {
|
||||
"status": "reset",
|
||||
|
@ -35,9 +35,9 @@ class ApiServer(RPCHandler):
|
||||
_rpc: RPC
|
||||
# Backtesting type: Backtesting
|
||||
_bt = None
|
||||
_backtestdata = None
|
||||
_bt_data = None
|
||||
_bt_timerange = None
|
||||
_lastbacktestconfig: Dict[str, Any] = {}
|
||||
_bt_last_config: Dict[str, Any] = {}
|
||||
_has_rpc: bool = False
|
||||
_bgtask_running: bool = False
|
||||
_config: Dict[str, Any] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user