allow simplified hyperopt interface
This commit is contained in:
		| @@ -9,6 +9,15 @@ from typing import Dict, Any, Callable, List | |||||||
| from pandas import DataFrame | from pandas import DataFrame | ||||||
| from skopt.space import Dimension, Integer, Real | from skopt.space import Dimension, Integer, Real | ||||||
|  |  | ||||||
|  | from freqtrade import OperationalException | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def _format_exception_message(method: str, space: str) -> str: | ||||||
|  |     return (f"The '{space}' space is included into the hyperoptimization " | ||||||
|  |             f"but {method}() method is not found in your " | ||||||
|  |             f"custom Hyperopt class. You should either implement this " | ||||||
|  |             f"method or remove the '{space}' space from hyperoptimization.") | ||||||
|  |  | ||||||
|  |  | ||||||
| class IHyperOpt(ABC): | class IHyperOpt(ABC): | ||||||
|     """ |     """ | ||||||
| @@ -32,32 +41,32 @@ class IHyperOpt(ABC): | |||||||
|         """ |         """ | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     @abstractmethod |  | ||||||
|     def buy_strategy_generator(params: Dict[str, Any]) -> Callable: |     def buy_strategy_generator(params: Dict[str, Any]) -> Callable: | ||||||
|         """ |         """ | ||||||
|         Create a buy strategy generator. |         Create a buy strategy generator. | ||||||
|         """ |         """ | ||||||
|  |         raise OperationalException(_format_exception_message('buy_strategy_generator', 'buy')) | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     @abstractmethod |  | ||||||
|     def sell_strategy_generator(params: Dict[str, Any]) -> Callable: |     def sell_strategy_generator(params: Dict[str, Any]) -> Callable: | ||||||
|         """ |         """ | ||||||
|         Create a sell strategy generator. |         Create a sell strategy generator. | ||||||
|         """ |         """ | ||||||
|  |         raise OperationalException(_format_exception_message('sell_strategy_generator', 'sell')) | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     @abstractmethod |  | ||||||
|     def indicator_space() -> List[Dimension]: |     def indicator_space() -> List[Dimension]: | ||||||
|         """ |         """ | ||||||
|         Create an indicator space. |         Create an indicator space. | ||||||
|         """ |         """ | ||||||
|  |         raise OperationalException(_format_exception_message('indicator_space', 'buy')) | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     @abstractmethod |  | ||||||
|     def sell_indicator_space() -> List[Dimension]: |     def sell_indicator_space() -> List[Dimension]: | ||||||
|         """ |         """ | ||||||
|         Create a sell indicator space. |         Create a sell indicator space. | ||||||
|         """ |         """ | ||||||
|  |         raise OperationalException(_format_exception_message('sell_indicator_space', 'sell')) | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
|     def generate_roi_table(params: Dict) -> Dict[int, float]: |     def generate_roi_table(params: Dict) -> Dict[int, float]: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user