From a0df7b9d7cfa6e5e8d5c841724e5b1a0fcc661e6 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 6 Jan 2019 14:12:55 +0100 Subject: [PATCH] Use sell/buy trends from hyperopt file if available --- freqtrade/optimize/hyperopt.py | 4 ++++ freqtrade/resolvers/hyperopt_resolver.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index ba9c186da..b8b8aaf56 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -170,9 +170,13 @@ class Hyperopt(Backtesting): if self.has_space('buy'): self.advise_buy = self.custom_hyperopt.buy_strategy_generator(params) + elif hasattr(self.custom_hyperopt, 'populate_buy_trend'): + self.advise_buy = self.custom_hyperopt.populate_buy_trend if self.has_space('sell'): self.advise_sell = self.custom_hyperopt.sell_strategy_generator(params) + elif hasattr(self.custom_hyperopt, 'populate_sell_trend'): + self.advise_sell = self.custom_hyperopt.populate_sell_trend if self.has_space('stoploss'): self.strategy.stoploss = params['stoploss'] diff --git a/freqtrade/resolvers/hyperopt_resolver.py b/freqtrade/resolvers/hyperopt_resolver.py index eb91c0e89..6bf7fa17d 100644 --- a/freqtrade/resolvers/hyperopt_resolver.py +++ b/freqtrade/resolvers/hyperopt_resolver.py @@ -32,6 +32,13 @@ class HyperOptResolver(IResolver): hyperopt_name = config.get('hyperopt') or DEFAULT_HYPEROPT self.hyperopt = self._load_hyperopt(hyperopt_name, extra_dir=config.get('hyperopt_path')) + if not hasattr(self.hyperopt, 'populate_buy_trend'): + logger.warning("Custom Hyperopt does not provide populate_buy_trend. " + "Using populate_buy_trend from DefaultStrategy.") + if not hasattr(self.hyperopt, 'populate_sell_trend'): + logger.warning("Custom Hyperopt does not provide populate_sell_trend. " + "Using populate_sell_trend from DefaultStrategy.") + def _load_hyperopt( self, hyperopt_name: str, extra_dir: Optional[str] = None) -> IHyperOpt: """