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
|
2021-07-04 08:15:19 +00:00
|
|
|
from typing import Any, Dict
|
2019-07-16 04:27:23 +00:00
|
|
|
|
|
|
|
from pandas import DataFrame
|
|
|
|
|
|
|
|
|
|
|
|
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.)
|
|
|
|
"""
|
2020-06-02 07:41:42 +00:00
|
|
|
timeframe: str
|
2019-07-16 04:27:23 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
@abstractmethod
|
|
|
|
def hyperopt_loss_function(results: DataFrame, trade_count: int,
|
2021-02-17 06:04:29 +00:00
|
|
|
min_date: datetime, max_date: datetime,
|
|
|
|
config: Dict, processed: Dict[str, DataFrame],
|
2021-07-04 08:15:19 +00:00
|
|
|
backtest_stats: Dict[str, Any],
|
2021-02-17 06:04:29 +00:00
|
|
|
*args, **kwargs) -> float:
|
2019-07-16 04:27:23 +00:00
|
|
|
"""
|
|
|
|
Objective function, returns smaller number for better results
|
|
|
|
"""
|