diff --git a/freqtrade/optimize/hyperopt_loss/hyperopt_loss_profit_drawdown.py b/freqtrade/optimize/hyperopt_loss/hyperopt_loss_profit_drawdown.py index ac3f82700..e5ec6075e 100644 --- a/freqtrade/optimize/hyperopt_loss/hyperopt_loss_profit_drawdown.py +++ b/freqtrade/optimize/hyperopt_loss/hyperopt_loss_profit_drawdown.py @@ -10,23 +10,26 @@ individual needs. from pandas import DataFrame +from freqtrade.constants import Config from freqtrade.data.metrics import calculate_max_drawdown from freqtrade.optimize.hyperopt import IHyperOptLoss -# higher numbers penalize drawdowns more severely +# smaller numbers penalize drawdowns more severely DRAWDOWN_MULT = 0.075 class ProfitDrawDownHyperOptLoss(IHyperOptLoss): @staticmethod - def hyperopt_loss_function(results: DataFrame, trade_count: int, *args, **kwargs) -> float: + def hyperopt_loss_function(results: DataFrame, config: Config, *args, **kwargs) -> float: total_profit = results["profit_abs"].sum() try: - drawdown = calculate_max_drawdown(results, value_col="profit_abs") + drawdown = calculate_max_drawdown( + results, starting_balance=config["dry_run_wallet"], value_col="profit_abs" + ) relative_account_drawdown = drawdown.relative_account_drawdown except ValueError: relative_account_drawdown = 0 - return -1 * (total_profit * (1 - relative_account_drawdown * DRAWDOWN_MULT)) + return -1 * (total_profit - (relative_account_drawdown * total_profit) / DRAWDOWN_MULT)