freqtrade/freqtrade · error · ValueError
You can only set one of decimals or step
Error message
You can only set one of decimals or step
What it means
SKDecimal (freqtrade/optimize/space/decimalspace.py) is an optuna FloatDistribution wrapper used for hyperopt spaces and strategy parameters. It converts a 'decimals' precision (number of decimal places) into an equivalent 'step' size before delegating to optuna, so the two parameters are mutually exclusive representations of the same grid. Passing both decimals and step is ambiguous (which grid wins?) and is rejected immediately with a ValueError.
Source
Thrown at freqtrade/optimize/space/decimalspace.py:24
self,
low: float,
high: float,
*,
step: float | None = None,
decimals: int | None = None,
name: str | None = None,
):
"""
FloatDistribution with a fixed step size.
Only one of step or decimals can be set.
:param low: lower bound
:param high: upper bound
:param step: step size (e.g. 0.001)
:param decimals: number of decimal places to round to (e.g. 3)
:param name: name of the distribution
"""
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 if decimals else 1)
self.name = name or ""
super().__init__(
low=round(low, decimals) if decimals else low,
high=round(high, decimals) if decimals else high,
step=self.step,
)
View on GitHub (pinned to 1c8edfe4d1)
Solutions
- Remove one of the two arguments: keep `decimals=3` OR `step=0.001`, never both.
- If you need a specific grid, prefer `step` (e.g. step=0.001); if you just want rounded values, use `decimals`.
- Check every DecimalParameter/SKDecimal definition in your strategy and custom hyperopt losses/spaces for the duplicated argument.
Example fix
# before buy_rsi = DecimalParameter(10, 50, decimals=2, step=0.01, default=30.0) # after buy_rsi = DecimalParameter(10, 50, decimals=2, default=30.0)
Defensive patterns
Strategy: validation
Validate before calling
def make_sk_decimal(low, high, *, step=None, decimals=None, name=None):
if step is not None and decimals is not None:
raise ValueError("Pass only one of step or decimals")
from freqtrade.optimize.space import SKDecimal
return SKDecimal(low, high, step=step, decimals=decimals, name=name) Prevention
- Adopt a project convention: use only `decimals` (or only `step`) across all strategy parameters.
- Lint strategy files for DecimalParameter calls containing both step= and decimals=.
When it happens
Trigger: Constructing SKDecimal(low, high, step=0.001, decimals=3) with both keyword arguments set. In practice this happens via DecimalParameter in a strategy (freqtrade/strategy/parameters.py:282 builds SKDecimal from the strategy parameter) when the user supplies both `step=` and `decimals=`, or in a custom hyperopt file defining a space with both attributes.
Common situations: A strategy author copies a DecimalParameter example that uses `decimals=3` and adds `step=0.001` from another example; upgrading strategies between freqtrade versions where the parameter API changed; writing a custom HyperOpt class with explicit SKDecimal spaces.
Related errors
- You must set one of decimals or step
- Invalid parameter file provided.
- --hyperopt-filename expects only the filename, not an absolu
- This strategy requires {startup_candles} candles to start, w
- This strategy requires {startup_candles} candles to start, w
AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15).
Data as JSON: /api/errors/0c2ca59388d591a6.
Report an issue: GitHub.