diff --git a/freqtrade/optimize/default_hyperopt.py b/freqtrade/optimize/default_hyperopt.py index 1c93fcc5d..aa3056fc0 100644 --- a/freqtrade/optimize/default_hyperopt.py +++ b/freqtrade/optimize/default_hyperopt.py @@ -1,9 +1,7 @@ # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement from functools import reduce -from math import exp from typing import Any, Callable, Dict, List -from datetime import datetime import talib.abstract as ta from pandas import DataFrame @@ -33,21 +31,6 @@ class DefaultHyperOpts(IHyperOpt): You can override it with your own hyperopt """ - @staticmethod - def hyperopt_loss_custom(results: DataFrame, trade_count: int, - min_date: datetime, max_date: datetime, *args, **kwargs) -> float: - """ - Objective function, returns smaller number for more optimal results - """ - total_profit = results.profit_percent.sum() - trade_duration = results.trade_duration.mean() - - trade_loss = 1 - 0.25 * exp(-(trade_count - TARGET_TRADES) ** 2 / 10 ** 5.8) - profit_loss = max(0, 1 - total_profit / EXPECTED_MAX_PROFIT) - duration_loss = 0.4 * min(trade_duration / MAX_ACCEPTED_TRADE_DURATION, 1) - result = trade_loss + profit_loss + duration_loss - return result - @staticmethod def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe['adx'] = ta.ADX(dataframe) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index bf5b70e14..e041554dc 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -80,11 +80,11 @@ class Hyperopt(Backtesting): hasattr(self.custom_hyperopt, 'hyperopt_loss_custom')): self.calculate_loss = self.custom_hyperopt.hyperopt_loss_custom # type: ignore - # Implement fallback to avoid odd crashes when custom-hyperopt fails to load. - if not hasattr(self.custom_hyperopt, 'hyperopt_loss_custom'): - logger.warning("Could not load hyperopt configuration. " - "Falling back to legacy configuration.") - raise OperationalException("Could not load hyperopt loss function.") + # Implement fallback to avoid odd crashes when custom-hyperopt fails to load. + if not hasattr(self.custom_hyperopt, 'hyperopt_loss_custom'): + logger.warning("Could not load hyperopt configuration. " + "Falling back to legacy configuration.") + raise OperationalException("Could not load hyperopt loss function.") # Populate functions here (hasattr is slow so should not be run during "regular" operations) if hasattr(self.custom_hyperopt, 'populate_buy_trend'):