From 89db5c6bab15352c334e79bf0cba2ab720cd9687 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 21 Jul 2019 14:52:59 +0200 Subject: [PATCH] Extract strategy-specific stuff from search logic will allow extracting all to IResolver --- freqtrade/resolvers/strategy_resolver.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 4a5604db8..114115d8a 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -155,19 +155,23 @@ class StrategyResolver(IResolver): kwargs={'config': config}) if strategy: logger.info(f"Using resolved strategy {strategy_name} from '{module_path}'...") - strategy._populate_fun_len = len( - getfullargspec(strategy.populate_indicators).args) - strategy._buy_fun_len = len(getfullargspec(strategy.populate_buy_trend).args) - strategy._sell_fun_len = len(getfullargspec(strategy.populate_sell_trend).args) - try: - return import_strategy(strategy, config=config) - except TypeError as e: - logger.warning( - f"Impossible to load strategy '{strategy_name}' from {module_path}. " - f"Error: {e}") + break + except FileNotFoundError: logger.warning('Path "%s" does not exist.', _path.relative_to(Path.cwd())) + if strategy: + strategy._populate_fun_len = len(getfullargspec(strategy.populate_indicators).args) + strategy._buy_fun_len = len(getfullargspec(strategy.populate_buy_trend).args) + strategy._sell_fun_len = len(getfullargspec(strategy.populate_sell_trend).args) + + try: + return import_strategy(strategy, config=config) + except TypeError as e: + logger.warning( + f"Impossible to load strategy '{strategy_name}'. " + f"Error: {e}") + raise OperationalException( f"Impossible to load Strategy '{strategy_name}'. This class does not exist " "or contains Python code errors."