mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: add builtin spaces enter and exit
This commit is contained in:
@@ -56,10 +56,10 @@ options:
|
|||||||
--spaces SPACES [SPACES ...]
|
--spaces SPACES [SPACES ...]
|
||||||
Specify which parameters to hyperopt. Space-separated
|
Specify which parameters to hyperopt. Space-separated
|
||||||
list. Available builtin options (custom spaces will
|
list. Available builtin options (custom spaces will
|
||||||
not be listed here): default, all, buy, sell, roi,
|
not be listed here): default, all, buy, sell, enter,
|
||||||
stoploss, trailing, protection, trades. Default:
|
exit, roi, stoploss, trailing, protection, trades.
|
||||||
`default` - which includes all spaces except for
|
Default: `default` - which includes all spaces except
|
||||||
'trailing', 'protection', and 'trades'.
|
for 'trailing', 'protection', and 'trades'.
|
||||||
--print-all Print all results, not only the best ones.
|
--print-all Print all results, not only the best ones.
|
||||||
--print-json Print output in JSON format.
|
--print-json Print output in JSON format.
|
||||||
-j JOBS, --job-workers JOBS
|
-j JOBS, --job-workers JOBS
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ HYPEROPT_LOSS_BUILTIN = [
|
|||||||
HYPEROPT_BUILTIN_SPACES = [
|
HYPEROPT_BUILTIN_SPACES = [
|
||||||
"buy",
|
"buy",
|
||||||
"sell",
|
"sell",
|
||||||
|
"enter",
|
||||||
|
"exit",
|
||||||
"roi",
|
"roi",
|
||||||
"stoploss",
|
"stoploss",
|
||||||
"trailing",
|
"trailing",
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ class HyperOptAuto(IHyperOpt):
|
|||||||
if attr.optimize:
|
if attr.optimize:
|
||||||
yield attr.get_space(attr_name)
|
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.
|
Get indicator space for a given space.
|
||||||
:param category: parameter space to get.
|
:param category: parameter space to get.
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ def detect_all_parameters(
|
|||||||
:param obj: Strategy object or class
|
:param obj: Strategy object or class
|
||||||
:return: Dictionary of detected parameters by space
|
:return: Dictionary of detected parameters by space
|
||||||
"""
|
"""
|
||||||
auto_categories = ["buy", "sell", "protection"]
|
auto_categories = ["buy", "sell", "enter", "exit", "protection"]
|
||||||
result: AllSpaceParams = defaultdict(dict)
|
result: AllSpaceParams = defaultdict(dict)
|
||||||
for attr_name in dir(obj):
|
for attr_name in dir(obj):
|
||||||
if attr_name.startswith("__"): # Ignore internals
|
if attr_name.startswith("__"): # Ignore internals
|
||||||
|
|||||||
@@ -974,6 +974,16 @@ def test_auto_hyperopt_interface(default_conf):
|
|||||||
match=r"'hello:world:22' is not a valid space\. Parameter: exit22_rsi\.",
|
match=r"'hello:world:22' is not a valid space\. Parameter: exit22_rsi\.",
|
||||||
):
|
):
|
||||||
detect_all_parameters(strategy.__class__)
|
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):
|
def test_auto_hyperopt_interface_loadparams(default_conf, mocker, caplog):
|
||||||
|
|||||||
Reference in New Issue
Block a user