diff --git a/docs/commands/hyperopt.md b/docs/commands/hyperopt.md index 9348e15da..4d9a75b22 100644 --- a/docs/commands/hyperopt.md +++ b/docs/commands/hyperopt.md @@ -56,10 +56,10 @@ options: --spaces SPACES [SPACES ...] Specify which parameters to hyperopt. Space-separated list. Available builtin options (custom spaces will - not be listed here): default, all, buy, sell, roi, - stoploss, trailing, protection, trades. Default: - `default` - which includes all spaces except for - 'trailing', 'protection', and 'trades'. + not be listed here): default, all, buy, sell, enter, + exit, roi, stoploss, trailing, protection, trades. + Default: `default` - which includes all spaces except + for 'trailing', 'protection', and 'trades'. --print-all Print all results, not only the best ones. --print-json Print output in JSON format. -j JOBS, --job-workers JOBS diff --git a/freqtrade/constants.py b/freqtrade/constants.py index a386dba28..5a57f773f 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -44,6 +44,8 @@ HYPEROPT_LOSS_BUILTIN = [ HYPEROPT_BUILTIN_SPACES = [ "buy", "sell", + "enter", + "exit", "roi", "stoploss", "trailing", diff --git a/freqtrade/optimize/hyperopt/hyperopt_auto.py b/freqtrade/optimize/hyperopt/hyperopt_auto.py index 603d0b139..fd2a75c55 100644 --- a/freqtrade/optimize/hyperopt/hyperopt_auto.py +++ b/freqtrade/optimize/hyperopt/hyperopt_auto.py @@ -67,7 +67,9 @@ class HyperOptAuto(IHyperOpt): if attr.optimize: yield attr.get_space(attr_name) - def get_indicator_space(self, category: Literal["buy", "sell", "protection"] | str) -> list: + def get_indicator_space( + self, category: Literal["buy", "sell", "enter", "exit", "protection"] | str + ) -> list: """ Get indicator space for a given space. :param category: parameter space to get. diff --git a/freqtrade/strategy/hyper.py b/freqtrade/strategy/hyper.py index 123600c55..445a1a300 100644 --- a/freqtrade/strategy/hyper.py +++ b/freqtrade/strategy/hyper.py @@ -166,7 +166,7 @@ def detect_all_parameters( :param obj: Strategy object or class :return: Dictionary of detected parameters by space """ - auto_categories = ["buy", "sell", "protection"] + auto_categories = ["buy", "sell", "enter", "exit", "protection"] result: AllSpaceParams = defaultdict(dict) for attr_name in dir(obj): if attr_name.startswith("__"): # Ignore internals diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index 5f3c11821..e536e335a 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -974,6 +974,16 @@ def test_auto_hyperopt_interface(default_conf): match=r"'hello:world:22' is not a valid space\. Parameter: exit22_rsi\.", ): detect_all_parameters(strategy.__class__) + del strategy.__class__.exit22_rsi + + # Valid exit parameter + strategy.__class__.exit_rsi = IntParameter([0, 10], default=5) + strategy.__class__.enter_rsi = IntParameter([0, 10], default=5) + spaces = detect_all_parameters(strategy.__class__) + assert "exit" in spaces + assert "enter" in spaces + del strategy.__class__.exit_rsi + del strategy.__class__.enter_rsi def test_auto_hyperopt_interface_loadparams(default_conf, mocker, caplog):