[SQUASH] Make skopt imports optional.

This commit is contained in:
Rokas Kupstys
2021-03-25 10:00:52 +02:00
parent 11689100e7
commit fd45dfd894
2 changed files with 16 additions and 11 deletions

View File

@@ -3,9 +3,12 @@ HyperOptAuto class.
This module implements a convenience auto-hyperopt class, which can be used together with strategies
that implement IHyperStrategy interface.
"""
from contextlib import suppress
from typing import Any, Callable, Dict, List
from pandas import DataFrame
from skopt.space import Categorical, Dimension, Integer, Real # noqa
with suppress(ImportError):
from skopt.space import Dimension
from freqtrade.optimize.hyperopt_interface import IHyperOpt
@@ -57,23 +60,23 @@ class HyperOptAuto(IHyperOpt):
else:
return self._get_func(fallback_method_name)()
def indicator_space(self) -> List[Dimension]:
def indicator_space(self) -> List['Dimension']:
return self._get_indicator_space('buy', 'indicator_space')
def sell_indicator_space(self) -> List[Dimension]:
def sell_indicator_space(self) -> List['Dimension']:
return self._get_indicator_space('sell', 'sell_indicator_space')
def generate_roi_table(self, params: Dict) -> Dict[int, float]:
return self._get_func('generate_roi_table')(params)
def roi_space(self) -> List[Dimension]:
def roi_space(self) -> List['Dimension']:
return self._get_func('roi_space')()
def stoploss_space(self) -> List[Dimension]:
def stoploss_space(self) -> List['Dimension']:
return self._get_func('stoploss_space')()
def generate_trailing_params(self, params: Dict) -> Dict:
return self._get_func('generate_trailing_params')(params)
def trailing_space(self) -> List[Dimension]:
def trailing_space(self) -> List['Dimension']:
return self._get_func('trailing_space')()