Fix hyperopt-loss interface to enforce kwargs

This commit is contained in:
Matthias 2022-04-25 11:33:18 +02:00
parent 5ff2261b74
commit 4444259078
2 changed files with 5 additions and 6 deletions

View File

@ -19,11 +19,11 @@ class IHyperOptLoss(ABC):
@staticmethod
@abstractmethod
def hyperopt_loss_function(results: DataFrame, trade_count: int,
def hyperopt_loss_function(*, results: DataFrame, trade_count: int,
min_date: datetime, max_date: datetime,
config: Dict, processed: Dict[str, DataFrame],
backtest_stats: Dict[str, Any],
*args, **kwargs) -> float:
**kwargs) -> float:
"""
Objective function, returns smaller number for better results
"""

View File

@ -3,7 +3,6 @@ from pathlib import Path
from typing import Any, Dict, List, Optional
import pandas as pd
from numpy import number
from freqtrade.configuration import TimeRange
from freqtrade.data.btanalysis import (analyze_trade_parallelism, calculate_max_drawdown,
@ -159,7 +158,7 @@ def add_profit(fig, row, data: pd.DataFrame, column: str, name: str) -> make_sub
def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame,
timeframe: str, starting_balance: number) -> make_subplots:
timeframe: str, starting_balance: float) -> make_subplots:
"""
Add scatter points indicating max drawdown
"""
@ -192,7 +191,7 @@ def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame,
return fig
def add_underwater(fig, row, trades: pd.DataFrame, starting_balance: number) -> make_subplots:
def add_underwater(fig, row, trades: pd.DataFrame, starting_balance: float) -> make_subplots:
"""
Add underwater plots
"""
@ -526,7 +525,7 @@ def generate_candlestick_graph(pair: str, data: pd.DataFrame, trades: pd.DataFra
def generate_profit_graph(pairs: str, data: Dict[str, pd.DataFrame],
trades: pd.DataFrame, timeframe: str, stake_currency: str,
starting_balance: number) -> go.Figure:
starting_balance: float) -> go.Figure:
# Combine close-values for all pairs, rename columns to "pair"
try:
df_comb = combine_dataframes_with_mean(data, "close")