diff --git a/freqtrade/enums/__init__.py b/freqtrade/enums/__init__.py index e50ebc4a4..d2f5474fc 100644 --- a/freqtrade/enums/__init__.py +++ b/freqtrade/enums/__init__.py @@ -3,6 +3,7 @@ from freqtrade.enums.backteststate import BacktestState from freqtrade.enums.candletype import CandleType from freqtrade.enums.exitchecktuple import ExitCheckTuple from freqtrade.enums.exittype import ExitType +from freqtrade.enums.hyperoptstate import HyperoptState from freqtrade.enums.marginmode import MarginMode from freqtrade.enums.ordertypevalue import OrderTypeValues from freqtrade.enums.rpcmessagetype import RPCMessageType diff --git a/freqtrade/enums/hyperoptstate.py b/freqtrade/enums/hyperoptstate.py new file mode 100644 index 000000000..332b3354d --- /dev/null +++ b/freqtrade/enums/hyperoptstate.py @@ -0,0 +1,12 @@ +from enum import Enum + + +class HyperoptState(Enum): + """ Hyperopt states """ + STARTUP = 1 + DATALOAD = 2 + INDICATORS = 3 + OPTIMIZE = 0 + + def __str__(self): + return f"{self.name.lower()}" diff --git a/freqtrade/optimize/hyperopt_tools.py b/freqtrade/optimize/hyperopt_tools.py index ab6ef013b..7f339eec1 100755 --- a/freqtrade/optimize/hyperopt_tools.py +++ b/freqtrade/optimize/hyperopt_tools.py @@ -13,6 +13,7 @@ from colorama import Fore, Style from pandas import isna, json_normalize from freqtrade.constants import FTHYPT_FILEVERSION, USERPATH_STRATEGIES +from freqtrade.enums import HyperoptState from freqtrade.exceptions import OperationalException from freqtrade.misc import deep_merge_dicts, round_coin_value, round_dict, safe_value_fallback2 from freqtrade.optimize.hyperopt_epoch_filters import hyperopt_filter_epochs @@ -32,6 +33,20 @@ def hyperopt_serializer(x): return str(x) +class HyperoptStateContainer(): + """ Singleton class to track state of hyperopt""" + __state = HyperoptState.OPTIMIZE + + @classmethod + def set_state(cls, value: HyperoptState): + cls.__state = value + + @classmethod + @property + def state(cls) -> HyperoptState: + return cls.__state + + class HyperoptTools(): @staticmethod