{"record":{"id":"0c2ca59388d591a6","repo":"freqtrade/freqtrade","slug":"you-can-only-set-one-of-decimals-or-step","errorCode":null,"errorMessage":"You can only set one of decimals or step","messagePattern":"You can only set one of decimals or step","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"freqtrade/optimize/space/decimalspace.py","lineNumber":24,"sourceCode":"        self,\n        low: float,\n        high: float,\n        *,\n        step: float | None = None,\n        decimals: int | None = None,\n        name: str | None = None,\n    ):\n        \"\"\"\n        FloatDistribution with a fixed step size.\n        Only one of step or decimals can be set.\n        :param low: lower bound\n        :param high: upper bound\n        :param step: step size (e.g. 0.001)\n        :param decimals: number of decimal places to round to (e.g. 3)\n        :param name: name of the distribution\n        \"\"\"\n        if decimals is not None and step is not None:\n            raise ValueError(\"You can only set one of decimals or step\")\n        if decimals is None and step is None:\n            raise ValueError(\"You must set one of decimals or step\")\n        # Convert decimals to step\n        self.step = step or (1 / 10**decimals if decimals else 1)\n        self.name = name or \"\"\n\n        super().__init__(\n            low=round(low, decimals) if decimals else low,\n            high=round(high, decimals) if decimals else high,\n            step=self.step,\n        )\n","sourceCodeStart":6,"sourceCodeEnd":36,"githubUrl":"https://github.com/freqtrade/freqtrade/blob/1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15/freqtrade/optimize/space/decimalspace.py#L6-L36","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nbuy_rsi = DecimalParameter(10, 50, decimals=2, step=0.01, default=30.0)\n\n# after\nbuy_rsi = DecimalParameter(10, 50, decimals=2, default=30.0)","handlingStrategy":"validation","validationCode":"def make_sk_decimal(low, high, *, step=None, decimals=None, name=None):\n    if step is not None and decimals is not None:\n        raise ValueError(\"Pass only one of step or decimals\")\n    from freqtrade.optimize.space import SKDecimal\n    return SKDecimal(low, high, step=step, decimals=decimals, name=name)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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=."],"tags":["hyperopt","parameter-validation","strategy","configuration"],"backgroundTag":null,"analyzedSha":"1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15","analyzedAt":"2026-08-15T05:09:08.096Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}