From 5474d5ee64b65a178a195e97ca16b3e797e34f33 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 20 Jun 2021 15:18:41 +0200 Subject: [PATCH] Move webserver start command to seperate file --- freqtrade/commands/__init__.py | 3 ++- freqtrade/commands/trade_commands.py | 13 ------------- freqtrade/commands/webserver_commands.py | 15 +++++++++++++++ freqtrade/rpc/api_server/api_backtest.py | 1 - tests/commands/test_commands.py | 3 +-- 5 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 freqtrade/commands/webserver_commands.py diff --git a/freqtrade/commands/__init__.py b/freqtrade/commands/__init__.py index a13d0ba49..04e46ee23 100644 --- a/freqtrade/commands/__init__.py +++ b/freqtrade/commands/__init__.py @@ -19,4 +19,5 @@ from freqtrade.commands.list_commands import (start_list_exchanges, start_list_h from freqtrade.commands.optimize_commands import start_backtesting, start_edge, start_hyperopt from freqtrade.commands.pairlist_commands import start_test_pairlist from freqtrade.commands.plot_commands import start_plot_dataframe, start_plot_profit -from freqtrade.commands.trade_commands import start_trading, start_webserver +from freqtrade.commands.trade_commands import start_trading +from freqtrade.commands.webserver_commands import start_webserver diff --git a/freqtrade/commands/trade_commands.py b/freqtrade/commands/trade_commands.py index 3c3f3db9f..535844844 100644 --- a/freqtrade/commands/trade_commands.py +++ b/freqtrade/commands/trade_commands.py @@ -27,16 +27,3 @@ def start_trading(args: Dict[str, Any]) -> int: logger.info("worker found ... calling exit") worker.exit() return 0 - - -def start_webserver(args: Dict[str, Any]) -> None: - """ - Main entry point for webserver mode - """ - from freqtrade.configuration import Configuration - from freqtrade.enums import RunMode - from freqtrade.rpc.api_server import ApiServer - - # Initialize configuration - config = Configuration(args, RunMode.WEBSERVER).get_config() - ApiServer(config, standalone=True) diff --git a/freqtrade/commands/webserver_commands.py b/freqtrade/commands/webserver_commands.py new file mode 100644 index 000000000..9a5975227 --- /dev/null +++ b/freqtrade/commands/webserver_commands.py @@ -0,0 +1,15 @@ +from typing import Any, Dict + +from freqtrade.enums import RunMode + + +def start_webserver(args: Dict[str, Any]) -> None: + """ + Main entry point for webserver mode + """ + from freqtrade.configuration import Configuration + from freqtrade.rpc.api_server import ApiServer + + # Initialize configuration + config = Configuration(args, RunMode.WEBSERVER).get_config() + ApiServer(config, standalone=True) diff --git a/freqtrade/rpc/api_server/api_backtest.py b/freqtrade/rpc/api_server/api_backtest.py index bd202ea64..bdd9bc522 100644 --- a/freqtrade/rpc/api_server/api_backtest.py +++ b/freqtrade/rpc/api_server/api_backtest.py @@ -1,4 +1,3 @@ - import asyncio import logging from copy import deepcopy diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index bef421c89..dfbbbb2a6 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -13,10 +13,9 @@ from freqtrade.commands import (start_convert_data, start_create_userdir, start_ start_list_data, start_list_exchanges, start_list_hyperopts, start_list_markets, start_list_strategies, start_list_timeframes, start_new_hyperopt, start_new_strategy, start_show_trades, - start_test_pairlist, start_trading) + start_test_pairlist, start_trading, start_webserver) from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui, get_ui_download_url, read_ui_version) -from freqtrade.commands.trade_commands import start_webserver from freqtrade.configuration import setup_utils_configuration from freqtrade.enums import RunMode from freqtrade.exceptions import OperationalException