diff --git a/CustomPerformanceLoss.py b/CustomPerformanceLoss.py new file mode 100644 index 0000000..a595075 --- /dev/null +++ b/CustomPerformanceLoss.py @@ -0,0 +1,30 @@ +from freqtrade.optimize.hyperopt import IHyperOptLoss +from math import sqrt + + +class CustomPerformanceLoss(IHyperOptLoss): + + @staticmethod + def hyperopt_loss_function(results, trade_count, *args, **kwargs): + + total_profit = results['profit_total_abs'] + max_dd = results['max_drawdown'] + profit_factor = results['profit_factor'] + sqn = results['sqn'] + + # Sécurité minimale + if trade_count < 30: + return 1000 + + # Éviter division par zéro + if max_dd == 0: + max_dd = 0.0001 + + # Score principal + performance_score = ( + (profit_factor * sqn * total_profit) + / (max_dd ** 1.5) + ) + + # On retourne l'inverse car hyperopt minimise + return -performance_score \ No newline at end of file