diff --git a/freqtrade/optimize/hyperopt_loss_sharpe_daily.py b/freqtrade/optimize/hyperopt_loss_sharpe_daily.py index 55d1b4c1f..ff92901ad 100644 --- a/freqtrade/optimize/hyperopt_loss_sharpe_daily.py +++ b/freqtrade/optimize/hyperopt_loss_sharpe_daily.py @@ -43,12 +43,11 @@ class SharpeHyperOptLossDaily(IHyperOptLoss): * 100.0 ) - if (np.std(sum_daily["profit_percent"]) != 0.): - sharp_ratio = ( - sum_daily["profit_percent"].mean() - / np.std(sum_daily["profit_percent"]) - * np.sqrt(365) - ) + total_profit = sum_daily["profit_percent"] + expected_returns_mean = total_profit.mean() + + if (np.std(total_profit) != 0.): + sharp_ratio = expected_returns_mean / np.std(total_profit) * np.sqrt(365) else: # Define high (negative) sharpe ratio to be clear that this is NOT optimal. sharp_ratio = -20.0