From b946f8e7f19fb5674b77385d44c6cf266e0e37e0 Mon Sep 17 00:00:00 2001 From: Robert Roman Date: Wed, 22 Sep 2021 09:18:17 -0500 Subject: [PATCH] I sorted imports with isort --- freqtrade/optimize/hyperopt_loss_calmar.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/freqtrade/optimize/hyperopt_loss_calmar.py b/freqtrade/optimize/hyperopt_loss_calmar.py index 8ee1a5c27..866c0aa5f 100644 --- a/freqtrade/optimize/hyperopt_loss_calmar.py +++ b/freqtrade/optimize/hyperopt_loss_calmar.py @@ -7,10 +7,9 @@ Hyperoptimization. from datetime import datetime import numpy as np -from pandas import DataFrame - -from freqtrade.optimize.hyperopt import IHyperOptLoss from freqtrade.data.btanalysis import calculate_max_drawdown +from freqtrade.optimize.hyperopt import IHyperOptLoss +from pandas import DataFrame class CalmarHyperOptLoss(IHyperOptLoss): @@ -38,15 +37,14 @@ class CalmarHyperOptLoss(IHyperOptLoss): # calculate max drawdown try: - _, _, _, high_val, low_val = calculate_max_drawdown(results) + _,_,_,high_val,low_val = calculate_max_drawdown(results) max_drawdown = (high_val - low_val) / high_val except ValueError: max_drawdown = 0 - if max_drawdown > 0: + if max_drawdown != 0 and trade_count > 1000: calmar_ratio = expected_returns_mean / max_drawdown * np.sqrt(365) else: calmar_ratio = -20. - # print(calmar_ratio) return -calmar_ratio