freqtrade/freqtrade · error · ValueError
Unknown rounding_mode {rounding_mode}
Error message
Unknown rounding_mode {rounding_mode} What it means
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.
Source
Thrown at freqtrade/exchange/exchange_utils.py:360
precision = FtPrecise(price_precision)
price_str = FtPrecise(price)
missing = price_str % precision
if not missing == FtPrecise("0"):
if rounding_mode == ROUND_UP:
res = price_str - missing + precision
elif rounding_mode == ROUND_DOWN:
res = price_str - missing
return round(float(str(res)), 14)
return price
elif precisionMode == DECIMAL_PLACES:
ndigits = round(price_precision)
ticks = price * (10**ndigits)
if rounding_mode == ROUND_UP:
return ceil(ticks) / (10**ndigits)
if rounding_mode == ROUND_DOWN:
return floor(ticks) / (10**ndigits)
raise ValueError(f"Unknown rounding_mode {rounding_mode}")
elif precisionMode == SIGNIFICANT_DIGITS:
if rounding_mode in (ROUND_UP, ROUND_DOWN):
return __price_to_precision_significant_digits(
price, price_precision, rounding_mode=rounding_mode
)
raise ValueError(f"Unknown precisionMode {precisionMode}")
return price
View on GitHub (pinned to 1c8edfe4d1)
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
Example fix
# before price = price_to_precision(pair, price, 8, rounding_mode=some_mode) # after from freqtrade.exchange.exchange_utils import ROUND_UP, ROUND_DOWN rounding = ROUND_UP if side == 'buy' else ROUND_DOWN price = price_to_precision(pair, price, 8, rounding_mode=rounding)
Defensive patterns
Strategy: validation
Validate before calling
from freqtrade.exchange.exchange_utils import ROUND_UP, ROUND_DOWN
assert rounding_mode in (ROUND_UP, ROUND_DOWN), f'bad rounding_mode: {rounding_mode}' Try / catch
try:
p = price_to_precision(pair, price, precision, rounding_mode=rounding)
except ValueError as e:
raise ConfigurationError(str(e)) from e Prevention
- Always pass ROUND_UP/ROUND_DOWN explicitly; never arbitrary integers as rounding_mode
- Unit-test precision helpers for custom exchange subclasses
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Could not create {ordertype} {side} order on market {pair}.
- Unknown precisionMode {precisionMode}
- `{new_path}` already exists. Please choose another Strategy
- Market exit orders require exit_pricing.price_side = "other"
- The config stoploss needs to be different from 0 to avoid pr
AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15).
Data as JSON: /api/errors/5c0bd63218a5759f.
Report an issue: GitHub.