From 813c008af22d78a854c11f6dd04cda50e579b325 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Sun, 16 Jun 2019 21:37:43 +0300 Subject: [PATCH 1/2] setup_configuration() cleanup --- freqtrade/optimize/__init__.py | 10 +++------- freqtrade/utils.py | 5 +++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index 475aaa82f..8b548eefe 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -5,8 +5,9 @@ from typing import Any, Dict from filelock import FileLock, Timeout from freqtrade import DependencyException, constants -from freqtrade.configuration import Configuration from freqtrade.state import RunMode +from freqtrade.utils import setup_utils_configuration + logger = logging.getLogger(__name__) @@ -17,12 +18,7 @@ def setup_configuration(args: Namespace, method: RunMode) -> Dict[str, Any]: :param args: Cli args from Arguments() :return: Configuration """ - configuration = Configuration(args, method) - config = configuration.load_config() - - # Ensure we do not use Exchange credentials - config['exchange']['key'] = '' - config['exchange']['secret'] = '' + config = setup_utils_configuration(args, method) if method == RunMode.BACKTEST: if config['stake_amount'] == constants.UNLIMITED_STAKE_AMOUNT: diff --git a/freqtrade/utils.py b/freqtrade/utils.py index 324b54a4e..d550ef43c 100644 --- a/freqtrade/utils.py +++ b/freqtrade/utils.py @@ -10,15 +10,16 @@ from freqtrade.state import RunMode logger = logging.getLogger(__name__) -def setup_configuration(args: Namespace, method: RunMode) -> Dict[str, Any]: +def setup_utils_configuration(args: Namespace, method: RunMode) -> Dict[str, Any]: """ - Prepare the configuration for the Hyperopt module + Prepare the configuration for utils subcommands :param args: Cli args from Arguments() :return: Configuration """ configuration = Configuration(args, method) config = configuration.load_config() + config['exchange']['dry_run'] = True # Ensure we do not use Exchange credentials config['exchange']['key'] = '' config['exchange']['secret'] = '' From 195bf5a4ccdbfffb3c997e64332af7177f1ef9da Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Sun, 16 Jun 2019 21:37:59 +0300 Subject: [PATCH 2/2] tests adjusted --- freqtrade/tests/test_utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/freqtrade/tests/test_utils.py b/freqtrade/tests/test_utils.py index 7550efb23..a12b709d7 100644 --- a/freqtrade/tests/test_utils.py +++ b/freqtrade/tests/test_utils.py @@ -1,17 +1,18 @@ -from freqtrade.utils import setup_configuration, start_list_exchanges +from freqtrade.utils import setup_utils_configuration, start_list_exchanges from freqtrade.tests.conftest import get_args from freqtrade.state import RunMode import re -def test_setup_configuration(): +def test_setup_utils_configuration(): args = [ '--config', 'config.json.example', ] - config = setup_configuration(get_args(args), RunMode.OTHER) + config = setup_utils_configuration(get_args(args), RunMode.OTHER) assert "exchange" in config + assert config['exchange']['dry_run'] is True assert config['exchange']['key'] == '' assert config['exchange']['secret'] == ''