From 611e35ed81dd305b36fc6a4a1a8cf1371585a3da Mon Sep 17 00:00:00 2001 From: Stefano Ariestasia Date: Wed, 7 Dec 2022 15:47:58 +0900 Subject: [PATCH] flake8 fix --- freqtrade/data/metrics.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/freqtrade/data/metrics.py b/freqtrade/data/metrics.py index 4d442ac6a..02a57517b 100644 --- a/freqtrade/data/metrics.py +++ b/freqtrade/data/metrics.py @@ -219,6 +219,7 @@ def calculate_expectancy(trades: pd.DataFrame) -> float: return expectancy + def calculate_sortino(trades: pd.DataFrame, min_date: datetime, max_date: datetime) -> float: """ @@ -226,7 +227,7 @@ def calculate_sortino(trades: pd.DataFrame, :param trades: DataFrame containing trades (requires columns profit_ratio) :return: sortino """ - if (len(trades) == 0) or (min_date == None) or (max_date == None) or (min_date == max_date): + if (len(trades) == 0) or (min_date is None) or (max_date is None) or (min_date == max_date): return 0 total_profit = trades["profit_ratio"] @@ -252,14 +253,15 @@ def calculate_sortino(trades: pd.DataFrame, # print(expected_returns_mean, down_stdev, sortino_ratio) return sortino_ratio + def calculate_sharpe(trades: pd.DataFrame, - min_date: datetime, max_date: datetime) -> float: + min_date: datetime, max_date: datetime) -> float: """ Calculate sharpe :param trades: DataFrame containing trades (requires columns close_date and profit_ratio) :return: sharpe """ - if (len(trades) == 0) or (min_date == None) or (max_date == None) or (min_date == max_date): + if (len(trades) == 0) or (min_date is None) or (max_date is None) or (min_date == max_date): return 0 total_profit = trades["profit_ratio"] @@ -282,14 +284,15 @@ def calculate_sharpe(trades: pd.DataFrame, # print(expected_returns_mean, up_stdev, sharp_ratio) return sharp_ratio + def calculate_calmar(trades: pd.DataFrame, - min_date: datetime, max_date: datetime) -> float: + min_date: datetime, max_date: datetime) -> float: """ Calculate calmar :param trades: DataFrame containing trades (requires columns close_date and profit_ratio) :return: calmar """ - if (len(trades) == 0) or (min_date == None) or (max_date == None) or (min_date == max_date): + if (len(trades) == 0) or (min_date is None) or (max_date is None) or (min_date == max_date): return 0 total_profit = trades["profit_ratio"]