diff --git a/freqtrade/optimize/hyperopt_auto.py b/freqtrade/optimize/hyperopt_auto.py index fdc4da14c..41f086ad2 100644 --- a/freqtrade/optimize/hyperopt_auto.py +++ b/freqtrade/optimize/hyperopt_auto.py @@ -7,10 +7,10 @@ from typing import Any, Callable, Dict, List from pandas import DataFrame from skopt.space import Categorical, Dimension, Integer, Real # noqa +from freqtrade.exceptions import OperationalException from freqtrade.optimize.hyperopt_interface import IHyperOpt -# noinspection PyUnresolvedReferences class HyperOptAuto(IHyperOpt): """ This class delegates functionality to Strategy(IHyperStrategy) and Strategy.HyperOpt classes. diff --git a/freqtrade/strategy/hyper.py b/freqtrade/strategy/hyper.py index 8de986950..154dcead6 100644 --- a/freqtrade/strategy/hyper.py +++ b/freqtrade/strategy/hyper.py @@ -2,7 +2,7 @@ IHyperStrategy interface, hyperoptable Parameter class. This module defines a base class for auto-hyperoptable strategies. """ -from typing import Iterator, Tuple, Any, Optional, Sequence +from typing import Iterator, Tuple, Any, Optional, Sequence, Union from skopt.space import Integer, Real, Categorical @@ -22,7 +22,8 @@ class BaseParameter(object): **kwargs): """ Initialize hyperopt-optimizable parameter. - :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if parameter field + :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if + parameter field name is prefixed with 'buy_' or 'sell_'. :param kwargs: Extra parameters to skopt.space.(Integer|Real|Categorical). """ @@ -37,6 +38,9 @@ class BaseParameter(object): def __repr__(self): return f'{self.__class__.__name__}({self.value})' + def get_space(self, name: str) -> Union[Integer, Real, Categorical]: + raise NotImplementedError() + class IntParameter(BaseParameter): default: int @@ -49,7 +53,8 @@ class IntParameter(BaseParameter): Initialize hyperopt-optimizable parameter. :param space: Optimization space, [min, max]. :param default: A default value. - :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if parameter field + :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if + parameter field name is prefixed with 'buy_' or 'sell_'. :param kwargs: Extra parameters to skopt.space.Integer. """ @@ -76,7 +81,8 @@ class FloatParameter(BaseParameter): Initialize hyperopt-optimizable parameter. :param space: Optimization space, [min, max]. :param default: A default value. - :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if parameter field + :param category: A parameter category. Can be 'buy' or 'sell'. This parameter is optional if + parameter field name is prefixed with 'buy_' or 'sell_'. :param kwargs: Extra parameters to skopt.space.Real. """