From e8439ae0bca268dc01dfc5e01f2e47d5d699e5fa Mon Sep 17 00:00:00 2001 From: Yazeed Al Oyoun Date: Sun, 2 Feb 2020 06:20:09 +0100 Subject: [PATCH] better readability, kept np.sqrt(365) which results in annualized sharpe ratio --- freqtrade/optimize/hyperopt_loss_sharpe_daily.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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