CustomPerformanceLoss
This commit is contained in:
30
CustomPerformanceLoss.py
Normal file
30
CustomPerformanceLoss.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user