Extract strategy-specific stuff from search logic

will allow extracting all to IResolver
This commit is contained in:
Matthias 2019-07-21 14:52:59 +02:00
parent 790838d897
commit 89db5c6bab

View File

@ -155,19 +155,23 @@ class StrategyResolver(IResolver):
kwargs={'config': config}) kwargs={'config': config})
if strategy: if strategy:
logger.info(f"Using resolved strategy {strategy_name} from '{module_path}'...") logger.info(f"Using resolved strategy {strategy_name} from '{module_path}'...")
strategy._populate_fun_len = len( break
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}")
except FileNotFoundError: except FileNotFoundError:
logger.warning('Path "%s" does not exist.', _path.relative_to(Path.cwd())) 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( raise OperationalException(
f"Impossible to load Strategy '{strategy_name}'. This class does not exist " f"Impossible to load Strategy '{strategy_name}'. This class does not exist "
"or contains Python code errors." "or contains Python code errors."