Skip to content

Commit

Permalink
Reorder space methods in hyperopt
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Aug 2, 2021
1 parent adb33e7 commit e70a742
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions freqtrade/optimize/hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,14 @@ def init_spaces(self):

def generate_optimizer(self, raw_params: List[Any], iteration=None) -> Dict:
"""
Used Optimize function. Called once per epoch to optimize whatever is configured.
Used Optimize function.
Called once per epoch to optimize whatever is configured.
Keep this function as optimized as possible!
"""
backtest_start_time = datetime.now(timezone.utc)
params_dict = self._get_params_dict(self.dimensions, raw_params)

# Apply parameters
if HyperoptTools.has_space(self.config, 'roi'):
self.backtesting.strategy.minimal_roi = ( # type: ignore
self.custom_hyperopt.generate_roi_table(params_dict))

if HyperoptTools.has_space(self.config, 'buy'):
self.backtesting.strategy.advise_buy = ( # type: ignore
self.custom_hyperopt.buy_strategy_generator(params_dict))
Expand All @@ -283,6 +280,10 @@ def generate_optimizer(self, raw_params: List[Any], iteration=None) -> Dict:
self.backtesting.strategy.advise_sell = ( # type: ignore
self.custom_hyperopt.sell_strategy_generator(params_dict))

if HyperoptTools.has_space(self.config, 'roi'):
self.backtesting.strategy.minimal_roi = ( # type: ignore
self.custom_hyperopt.generate_roi_table(params_dict))

if HyperoptTools.has_space(self.config, 'stoploss'):
self.backtesting.strategy.stoploss = params_dict['stoploss']

Expand Down

0 comments on commit e70a742

Please sign in to comment.