From 27f83b511fa48d5ec59e09b259a10a99455b16da Mon Sep 17 00:00:00 2001 From: gcarq Date: Fri, 8 Jun 2018 02:00:42 +0200 Subject: [PATCH 1/5] raise OperationalException if config is missing --- freqtrade/configuration.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/freqtrade/configuration.py b/freqtrade/configuration.py index 2a9e8fbd8..0b484c57a 100644 --- a/freqtrade/configuration.py +++ b/freqtrade/configuration.py @@ -61,11 +61,9 @@ class Configuration(object): with open(path) as file: conf = json.load(file) except FileNotFoundError: - logger.critical( - 'Config file "%s" not found. Please create your config file', - path - ) - exit(0) + raise OperationalException( + 'Config file "{}" not found!' + ' Please create a config file or check whether it exists.'.format(path)) if 'internals' not in conf: conf['internals'] = {} From a2a1a517daa65d897d8acd9afeb4505491e028c9 Mon Sep 17 00:00:00 2001 From: gcarq Date: Fri, 8 Jun 2018 02:01:18 +0200 Subject: [PATCH 2/5] fix flake8 warning --- freqtrade/exchange/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index 5e768518b..88c06c111 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -277,7 +277,7 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict: 'bid': float(data['bid']), 'ask': float(data['ask']), } - except KeyError as e: + except KeyError: logger.debug("Could not cache ticker data for %s", pair) return data except (ccxt.NetworkError, ccxt.ExchangeError) as e: From 95d6c9c67811c9527b8718e82b84b05fbdc19214 Mon Sep 17 00:00:00 2001 From: gcarq Date: Fri, 8 Jun 2018 02:01:38 +0200 Subject: [PATCH 3/5] adapt tests --- freqtrade/tests/test_configuration.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 2f633c021..caaddbf25 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -85,7 +85,7 @@ def test_load_config_max_open_trades_zero(default_conf, mocker, caplog) -> None: assert log_has('Validating configuration ...', caplog.record_tuples) -def test_load_config_file_exception(mocker, caplog) -> None: +def test_load_config_file_exception(mocker) -> None: """ Test Configuration._load_config_file() method """ @@ -95,12 +95,8 @@ def test_load_config_file_exception(mocker, caplog) -> None: ) configuration = Configuration(Namespace()) - with pytest.raises(SystemExit): + with pytest.raises(OperationalException, match=r'.*Config file "somefile" not found!*'): configuration._load_config_file('somefile') - assert log_has( - 'Config file "somefile" not found. Please create your config file', - caplog.record_tuples - ) def test_load_config(default_conf, mocker) -> None: From bea9a3304e1f1218e151978cd2715c5c101520fc Mon Sep 17 00:00:00 2001 From: gcarq Date: Fri, 8 Jun 2018 02:01:46 +0200 Subject: [PATCH 4/5] use correct return code on error --- scripts/plot_profit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/plot_profit.py b/scripts/plot_profit.py index a5ac00169..803bf71de 100755 --- a/scripts/plot_profit.py +++ b/scripts/plot_profit.py @@ -93,7 +93,7 @@ def plot_profit(args: Namespace) -> None: 'Impossible to load the strategy. Please check the file "user_data/strategies/%s.py"', config.get('strategy') ) - exit(0) + exit(1) # Load the profits results try: @@ -104,7 +104,7 @@ def plot_profit(args: Namespace) -> None: logger.critical( 'File "backtest-result.json" not found. This script require backtesting ' 'results to run.\nPlease run a backtesting with the parameter --export.') - exit(0) + exit(1) # Take pairs from the cli otherwise switch to the pair in the config file if args.pair: From 8effc5f929bf83d20f64e0bffbbd06f98d6ffd86 Mon Sep 17 00:00:00 2001 From: xmatthias Date: Fri, 8 Jun 2018 19:46:07 +0200 Subject: [PATCH 5/5] fix windows-specific init issue with named tuple --- freqtrade/arguments.py | 2 +- freqtrade/optimize/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index 88f183a4a..62dd451bc 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -243,7 +243,7 @@ class Arguments(object): :return: Start and End range period """ if text is None: - return TimeRange() + return TimeRange(None, None, 0, 0) syntax = [(r'^-(\d{8})$', (None, 'date')), (r'^(\d{8})-$', ('date', None)), (r'^(\d{8})-(\d{8})$', ('date', 'date')), diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index 00f05cc46..fc5d53114 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -85,7 +85,7 @@ def load_data(datadir: str, ticker_interval: str, pairs: Optional[List[str]] = None, refresh_pairs: Optional[bool] = False, - timerange: TimeRange = TimeRange()) -> Dict[str, List]: + timerange: TimeRange = TimeRange(None, None, 0, 0)) -> Dict[str, List]: """ Loads ticker history data for the given parameters :return: dict @@ -125,7 +125,7 @@ def make_testdata_path(datadir: str) -> str: def download_pairs(datadir, pairs: List[str], ticker_interval: str, - timerange: TimeRange = TimeRange()) -> bool: + timerange: TimeRange = TimeRange(None, None, 0, 0)) -> bool: """For each pairs passed in parameters, download the ticker intervals""" for pair in pairs: try: