freqtrade_origin/freqtrade/optimize/hyperopt_loss/hyperopt_loss_interface.py

39 lines
901 B
Python
Raw Normal View History

2019-07-16 04:27:23 +00:00
"""
IHyperOptLoss interface
2019-11-13 08:38:06 +00:00
This module defines the interface for the loss-function for hyperopt
2019-07-16 04:27:23 +00:00
"""
from abc import ABC, abstractmethod
from datetime import datetime
from typing import Any
2019-07-16 04:27:23 +00:00
from pandas import DataFrame
2022-09-18 11:31:52 +00:00
from freqtrade.constants import Config
2019-07-16 04:27:23 +00:00
class IHyperOptLoss(ABC):
"""
2019-11-13 08:38:06 +00:00
Interface for freqtrade hyperopt Loss functions.
2019-07-16 04:27:23 +00:00
Defines the custom loss function (`hyperopt_loss_function()` which is evaluated every epoch.)
"""
2024-05-12 15:16:02 +00:00
timeframe: str
2019-07-16 04:27:23 +00:00
@staticmethod
@abstractmethod
2024-05-12 15:16:02 +00:00
def hyperopt_loss_function(
*,
results: DataFrame,
trade_count: int,
min_date: datetime,
max_date: datetime,
config: Config,
processed: dict[str, DataFrame],
backtest_stats: dict[str, Any],
2024-05-12 15:16:02 +00:00
**kwargs,
) -> float:
2019-07-16 04:27:23 +00:00
"""
Objective function, returns smaller number for better results
"""