{"record":{"id":"5c0bd63218a5759f","repo":"freqtrade/freqtrade","slug":"unknown-rounding-mode-rounding-mode","errorCode":null,"errorMessage":"Unknown rounding_mode {rounding_mode}","messagePattern":"Unknown rounding_mode (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"freqtrade/exchange/exchange_utils.py","lineNumber":360,"sourceCode":"            precision = FtPrecise(price_precision)\n            price_str = FtPrecise(price)\n            missing = price_str % precision\n            if not missing == FtPrecise(\"0\"):\n                if rounding_mode == ROUND_UP:\n                    res = price_str - missing + precision\n                elif rounding_mode == ROUND_DOWN:\n                    res = price_str - missing\n                return round(float(str(res)), 14)\n            return price\n        elif precisionMode == DECIMAL_PLACES:\n            ndigits = round(price_precision)\n            ticks = price * (10**ndigits)\n            if rounding_mode == ROUND_UP:\n                return ceil(ticks) / (10**ndigits)\n            if rounding_mode == ROUND_DOWN:\n                return floor(ticks) / (10**ndigits)\n\n            raise ValueError(f\"Unknown rounding_mode {rounding_mode}\")\n        elif precisionMode == SIGNIFICANT_DIGITS:\n            if rounding_mode in (ROUND_UP, ROUND_DOWN):\n                return __price_to_precision_significant_digits(\n                    price, price_precision, rounding_mode=rounding_mode\n                )\n\n        raise ValueError(f\"Unknown precisionMode {precisionMode}\")\n    return price\n","sourceCodeStart":342,"sourceCodeEnd":369,"githubUrl":"https://github.com/freqtrade/freqtrade/blob/1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15/freqtrade/exchange/exchange_utils.py#L342-L369","documentation":"ValueError raised in price_to_precision when precisionMode is DECIMAL_PLACES but rounding_mode is neither ROUND_UP nor ROUND_DOWN. The function only supports those two rounding modes in the decimal-places branch.","triggerScenarios":"Calling price_to_precision (or amount/price precision paths that delegate to it) with a rounding_mode constant other than ROUND_UP/ROUND_DOWN while the exchange's precision mode is DECIMAL_PLACES (e.g. passing ROUND_NEAREST or an arbitrary int).","commonSituations":"Custom strategy or exchange subclass code passing an unsupported rounding mode; importing rounding constants from the wrong module so values collide; new exchange integration with mismatched precision semantics.","solutions":["Pass freqtrade.exchange.exchange_utils ROUND_UP or ROUND_DOWN explicitly when calling price_to_precision","If you need truncation toward zero, compute the side yourself and map it to ROUND_UP/ROUND_DOWN before calling","Check the exchange's markets precisionMode via ccxt (market['precisionMode']) to understand which branch executes"],"exampleFix":"# before\nprice = price_to_precision(pair, price, 8, rounding_mode=some_mode)\n# after\nfrom freqtrade.exchange.exchange_utils import ROUND_UP, ROUND_DOWN\nrounding = ROUND_UP if side == 'buy' else ROUND_DOWN\nprice = price_to_precision(pair, price, 8, rounding_mode=rounding)","handlingStrategy":"validation","validationCode":"from freqtrade.exchange.exchange_utils import ROUND_UP, ROUND_DOWN\nassert rounding_mode in (ROUND_UP, ROUND_DOWN), f'bad rounding_mode: {rounding_mode}'","typeGuard":null,"tryCatchPattern":"try:\n    p = price_to_precision(pair, price, precision, rounding_mode=rounding)\nexcept ValueError as e:\n    raise ConfigurationError(str(e)) from e","preventionTips":["Always pass ROUND_UP/ROUND_DOWN explicitly; never arbitrary integers as rounding_mode","Unit-test precision helpers for custom exchange subclasses"],"tags":["precision","validation","rounding","exchange-utils"],"backgroundTag":null,"analyzedSha":"1c8edfe4d1e8d11bd4b40e8fc3237c26c3a60e15","analyzedAt":"2026-08-15T05:09:08.096Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}