I sorted imports with isort

This commit is contained in:
Robert Roman 2021-09-22 09:18:17 -05:00 committed by GitHub
parent 3834bb86ff
commit b946f8e7f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,10 +7,9 @@ Hyperoptimization.
from datetime import datetime from datetime import datetime
import numpy as np import numpy as np
from pandas import DataFrame
from freqtrade.optimize.hyperopt import IHyperOptLoss
from freqtrade.data.btanalysis import calculate_max_drawdown from freqtrade.data.btanalysis import calculate_max_drawdown
from freqtrade.optimize.hyperopt import IHyperOptLoss
from pandas import DataFrame
class CalmarHyperOptLoss(IHyperOptLoss): class CalmarHyperOptLoss(IHyperOptLoss):
@ -38,15 +37,14 @@ class CalmarHyperOptLoss(IHyperOptLoss):
# calculate max drawdown # calculate max drawdown
try: 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 max_drawdown = (high_val - low_val) / high_val
except ValueError: except ValueError:
max_drawdown = 0 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) calmar_ratio = expected_returns_mean / max_drawdown * np.sqrt(365)
else: else:
calmar_ratio = -20. calmar_ratio = -20.
# print(calmar_ratio)
return -calmar_ratio return -calmar_ratio