diff --git a/freqtrade/optimize/space/decimalspace.py b/freqtrade/optimize/space/decimalspace.py index bcf74feb8..40a8115f9 100644 --- a/freqtrade/optimize/space/decimalspace.py +++ b/freqtrade/optimize/space/decimalspace.py @@ -8,7 +8,7 @@ class SKDecimal(FloatDistribution): high: float, *, step: float | None = None, - decimals: int = 3, + decimals: int | None = None, name=None, ): """ @@ -22,6 +22,8 @@ class SKDecimal(FloatDistribution): """ if decimals is not None and step is not None: raise ValueError("You can only set one of decimals or step") + if decimals is None and step is None: + raise ValueError("You must set one of decimals or step") # Convert decimals to step self.step = step or 1 / 10**decimals self.name = name diff --git a/tests/optimize/test_hyperopt.py b/tests/optimize/test_hyperopt.py index 0e3d24511..c22323bdf 100644 --- a/tests/optimize/test_hyperopt.py +++ b/tests/optimize/test_hyperopt.py @@ -1197,6 +1197,9 @@ def test_SKDecimal(): with pytest.raises(ValueError): SKDecimal(1, 2, step=5, decimals=0.2) + with pytest.raises(ValueError): + SKDecimal(1, 2, step=None, decimals=None) + s = SKDecimal(1, 2, step=0.1, decimals=None) assert s.step == 0.1 assert s._contains(1.1)