fix formatting
This commit is contained in:
parent
c0d01dbc26
commit
6ba46b38bd
@ -5,11 +5,12 @@ This module defines the alternative HyperOptLoss class which can be used for
|
|||||||
Hyperoptimization.
|
Hyperoptimization.
|
||||||
"""
|
"""
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from freqtrade.data.btanalysis import calculate_max_drawdown
|
|
||||||
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
|
||||||
|
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
|
|
||||||
|
from freqtrade.data.btanalysis import calculate_max_drawdown
|
||||||
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||||
|
|
||||||
|
|
||||||
class MaxDrawDownHyperOptLoss(IHyperOptLoss):
|
class MaxDrawDownHyperOptLoss(IHyperOptLoss):
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ class MaxDrawDownHyperOptLoss(IHyperOptLoss):
|
|||||||
Uses profit ratio weighted max_drawdown when drawdown is available.
|
Uses profit ratio weighted max_drawdown when drawdown is available.
|
||||||
Otherwise directly optimizes profit ratio.
|
Otherwise directly optimizes profit ratio.
|
||||||
"""
|
"""
|
||||||
total_profit = results['profit_ratio'].sum()
|
total_profit = results['profit_ratio'].sum()
|
||||||
try:
|
try:
|
||||||
max_drawdown = calculate_max_drawdown(results)
|
max_drawdown = calculate_max_drawdown(results)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -39,4 +40,4 @@ class MaxDrawDownHyperOptLoss(IHyperOptLoss):
|
|||||||
return -total_profit
|
return -total_profit
|
||||||
max_drawdown_rev = 1 / max_drawdown[0]
|
max_drawdown_rev = 1 / max_drawdown[0]
|
||||||
ret = max_drawdown_rev * total_profit
|
ret = max_drawdown_rev * total_profit
|
||||||
return -ret
|
return -ret
|
||||||
|
Loading…
Reference in New Issue
Block a user