2019-07-23 15:51:24 +00:00
|
|
|
"""
|
|
|
|
OnlyProfitHyperOptLoss
|
|
|
|
|
|
|
|
This module defines the alternative HyperOptLoss class which can be used for
|
|
|
|
Hyperoptimization.
|
|
|
|
"""
|
2024-05-12 15:13:50 +00:00
|
|
|
|
2019-07-23 15:51:24 +00:00
|
|
|
from pandas import DataFrame
|
|
|
|
|
|
|
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
|
|
|
|
|
|
|
|
|
|
|
class OnlyProfitHyperOptLoss(IHyperOptLoss):
|
|
|
|
"""
|
|
|
|
Defines the loss function for hyperopt.
|
|
|
|
|
2021-05-28 06:38:46 +00:00
|
|
|
This implementation takes only absolute profit into account, not looking at any other indicator.
|
2019-07-23 15:51:24 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
@staticmethod
|
2024-05-12 15:13:50 +00:00
|
|
|
def hyperopt_loss_function(results: DataFrame, trade_count: int, *args, **kwargs) -> float:
|
2019-07-23 15:51:24 +00:00
|
|
|
"""
|
|
|
|
Objective function, returns smaller number for better results.
|
|
|
|
"""
|
2024-05-12 15:13:50 +00:00
|
|
|
total_profit = results["profit_abs"].sum()
|
2021-05-28 06:38:46 +00:00
|
|
|
return -1 * total_profit
|