|
|
|
|
@ -8,8 +8,10 @@ Possible to change `DRAWDOWN_MULT` to penalize drawdown objective for
|
|
|
|
|
individual needs.
|
|
|
|
|
"""
|
|
|
|
|
from pandas import DataFrame
|
|
|
|
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
|
|
|
|
|
|
|
|
|
from freqtrade.data.btanalysis import calculate_max_drawdown
|
|
|
|
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# higher numbers penalize drawdowns more severely
|
|
|
|
|
DRAWDOWN_MULT = 0.075
|
|
|
|
|
@ -20,9 +22,8 @@ class ProfitDrawDownHyperOptLoss(IHyperOptLoss):
|
|
|
|
|
def hyperopt_loss_function(results: DataFrame, trade_count: int, *args, **kwargs) -> float:
|
|
|
|
|
total_profit = results["profit_abs"].sum()
|
|
|
|
|
|
|
|
|
|
# from freqtrade.optimize.optimize_reports.generate_strategy_stats()
|
|
|
|
|
try:
|
|
|
|
|
profit_abs, _, _, _, _ = calculate_max_drawdown(results, value_col="profit_ratio")
|
|
|
|
|
profit_abs, _, _, _, _ = calculate_max_drawdown(results, value_col="profit_abs")
|
|
|
|
|
except ValueError:
|
|
|
|
|
profit_abs = 0
|
|
|
|
|
|
|
|
|
|
|