parent
a875a7dc40
commit
1ee08d22d2
@ -187,6 +187,9 @@ class Backtesting:
|
|||||||
# since a "perfect" stoploss-exit is assumed anyway
|
# since a "perfect" stoploss-exit is assumed anyway
|
||||||
# And the regular "stoploss" function would not apply to that case
|
# And the regular "stoploss" function would not apply to that case
|
||||||
self.strategy.order_types['stoploss_on_exchange'] = False
|
self.strategy.order_types['stoploss_on_exchange'] = False
|
||||||
|
if self.dataprovider.runmode == RunMode.BACKTEST:
|
||||||
|
# in hyperopt mode - don't re-init params
|
||||||
|
self.strategy.ft_load_hyper_params(False)
|
||||||
self.strategy.ft_bot_start()
|
self.strategy.ft_bot_start()
|
||||||
|
|
||||||
def _load_protections(self, strategy: IStrategy):
|
def _load_protections(self, strategy: IStrategy):
|
||||||
|
@ -31,7 +31,12 @@ class HyperStrategyMixin:
|
|||||||
self.ft_sell_params: List[BaseParameter] = []
|
self.ft_sell_params: List[BaseParameter] = []
|
||||||
self.ft_protection_params: List[BaseParameter] = []
|
self.ft_protection_params: List[BaseParameter] = []
|
||||||
|
|
||||||
self._load_hyper_params(config.get('runmode') == RunMode.HYPEROPT)
|
params = self.load_params_from_file()
|
||||||
|
params = params.get('params', {})
|
||||||
|
self._ft_params_from_file = params
|
||||||
|
|
||||||
|
if config.get('runmode') != RunMode.BACKTEST:
|
||||||
|
self.ft_load_hyper_params(config.get('runmode') == RunMode.HYPEROPT)
|
||||||
|
|
||||||
def enumerate_parameters(self, category: str = None) -> Iterator[Tuple[str, BaseParameter]]:
|
def enumerate_parameters(self, category: str = None) -> Iterator[Tuple[str, BaseParameter]]:
|
||||||
"""
|
"""
|
||||||
@ -80,21 +85,25 @@ class HyperStrategyMixin:
|
|||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
def _load_hyper_params(self, hyperopt: bool = False) -> None:
|
def ft_load_hyper_params(self, hyperopt: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Load Hyperoptable parameters
|
Load Hyperoptable parameters
|
||||||
|
Prevalence:
|
||||||
|
* Parameters from parameter file
|
||||||
|
* Parameters defined in parameters objects (buy_params, sell_params, ...)
|
||||||
|
* Parameter defaults
|
||||||
"""
|
"""
|
||||||
params = self.load_params_from_file()
|
|
||||||
params = params.get('params', {})
|
buy_params = deep_merge_dicts(self._ft_params_from_file.get('buy', {}),
|
||||||
self._ft_params_from_file = params
|
getattr(self, 'buy_params', {}))
|
||||||
buy_params = deep_merge_dicts(params.get('buy', {}), getattr(self, 'buy_params', {}))
|
sell_params = deep_merge_dicts(self._ft_params_from_file.get('sell', {}),
|
||||||
sell_params = deep_merge_dicts(params.get('sell', {}), getattr(self, 'sell_params', {}))
|
getattr(self, 'sell_params', {}))
|
||||||
protection_params = deep_merge_dicts(params.get('protection', {}),
|
protection_params = deep_merge_dicts(self._ft_params_from_file.get('protection', {}),
|
||||||
getattr(self, 'protection_params', {}))
|
getattr(self, 'protection_params', {}))
|
||||||
|
|
||||||
self._load_params(buy_params, 'buy', hyperopt)
|
self._ft_load_params(buy_params, 'buy', hyperopt)
|
||||||
self._load_params(sell_params, 'sell', hyperopt)
|
self._ft_load_params(sell_params, 'sell', hyperopt)
|
||||||
self._load_params(protection_params, 'protection', hyperopt)
|
self._ft_load_params(protection_params, 'protection', hyperopt)
|
||||||
|
|
||||||
def load_params_from_file(self) -> Dict:
|
def load_params_from_file(self) -> Dict:
|
||||||
filename_str = getattr(self, '__file__', '')
|
filename_str = getattr(self, '__file__', '')
|
||||||
@ -117,7 +126,7 @@ class HyperStrategyMixin:
|
|||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _load_params(self, params: Dict, space: str, hyperopt: bool = False) -> None:
|
def _ft_load_params(self, params: Dict, space: str, hyperopt: bool = False) -> None:
|
||||||
"""
|
"""
|
||||||
Set optimizable parameter values.
|
Set optimizable parameter values.
|
||||||
:param params: Dictionary with new parameter values.
|
:param params: Dictionary with new parameter values.
|
||||||
|
Loading…
Reference in New Issue
Block a user