Fix wrong intendation for custom-hyperopt check
This commit is contained in:
parent
7be25313a5
commit
07a1c48e8c
@ -1,9 +1,7 @@
|
|||||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||||
|
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from math import exp
|
|
||||||
from typing import Any, Callable, Dict, List
|
from typing import Any, Callable, Dict, List
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import talib.abstract as ta
|
import talib.abstract as ta
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
@ -33,21 +31,6 @@ class DefaultHyperOpts(IHyperOpt):
|
|||||||
You can override it with your own hyperopt
|
You can override it with your own hyperopt
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def hyperopt_loss_custom(results: DataFrame, trade_count: int,
|
|
||||||
min_date: datetime, max_date: datetime, *args, **kwargs) -> float:
|
|
||||||
"""
|
|
||||||
Objective function, returns smaller number for more optimal results
|
|
||||||
"""
|
|
||||||
total_profit = results.profit_percent.sum()
|
|
||||||
trade_duration = results.trade_duration.mean()
|
|
||||||
|
|
||||||
trade_loss = 1 - 0.25 * exp(-(trade_count - TARGET_TRADES) ** 2 / 10 ** 5.8)
|
|
||||||
profit_loss = max(0, 1 - total_profit / EXPECTED_MAX_PROFIT)
|
|
||||||
duration_loss = 0.4 * min(trade_duration / MAX_ACCEPTED_TRADE_DURATION, 1)
|
|
||||||
result = trade_loss + profit_loss + duration_loss
|
|
||||||
return result
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
dataframe['adx'] = ta.ADX(dataframe)
|
dataframe['adx'] = ta.ADX(dataframe)
|
||||||
|
Loading…
Reference in New Issue
Block a user