freqtrade/freqtrade · error · OperationalException
RangeStabilityFilter requires sort_direction to be either No
Error message
RangeStabilityFilter requires sort_direction to be either None (undefined), 'asc' or 'desc'
What it means
RangeStabilityFilter raises this OperationalException when sort_direction is not None (unset), 'asc', or 'desc'. The setting optionally sorts the filtered pairs by their rate-of-change score.
Source
Thrown at freqtrade/plugins/pairlist/rangestabilityfilter.py:45
self._days = self._pairlistconfig.get("lookback_days", 10)
self._min_rate_of_change = self._pairlistconfig.get("min_rate_of_change", 0.01)
self._max_rate_of_change = self._pairlistconfig.get("max_rate_of_change")
self._refresh_period = self._pairlistconfig.get("refresh_period", 86400)
self._def_candletype = self._config["candle_type_def"]
self._sort_direction: str | None = self._pairlistconfig.get("sort_direction", None)
self._pair_cache: FtTTLCache = FtTTLCache(maxsize=1000, ttl=self._refresh_period)
candle_limit = self._exchange.ohlcv_candle_limit("1d", self._def_candletype)
if self._days < 1:
raise OperationalException("RangeStabilityFilter requires lookback_days to be >= 1")
if self._days > candle_limit:
raise OperationalException(
"RangeStabilityFilter requires lookback_days to not "
f"exceed exchange max request size ({candle_limit})"
)
if self._sort_direction not in [None, "asc", "desc"]:
raise OperationalException(
"RangeStabilityFilter requires sort_direction to be "
"either None (undefined), 'asc' or 'desc'"
)
def short_desc(self) -> str:
"""
Short whitelist method description - used for startup-messages
"""
max_rate_desc = ""
if self._max_rate_of_change:
max_rate_desc = f" and above {self._max_rate_of_change}"
return (
f"{self.name} - Filtering pairs with rate of change below "
f"{self._min_rate_of_change}{max_rate_desc} over the "
f"last {plural(self._days, 'day')}."
)
@staticmethodView on GitHub (pinned to 1c8edfe4d1)
Solutions
- Use exactly 'asc' or 'desc'
- Omit sort_direction to keep the default undefined behavior
Example fix
# before
{"method": "RangeStabilityFilter", "config": {"sort_direction": "descending"}}
# after
{"method": "RangeStabilityFilter", "config": {"sort_direction": "desc"}} Defensive patterns
Strategy: type-guard
Validate before calling
sd = pairlist_config.get("sort_direction")
if sd is not None and sd not in ("asc", "desc"):
raise ValueError("sort_direction must be None, 'asc' or 'desc'") Type guard
def is_valid_sort_direction(v: object) -> bool:
return v is None or (isinstance(v, str) and v in ("asc", "desc")) Prevention
- Use only lowercase 'asc'/'desc' or omit the key
- Share one enum definition across filters and config validation
When it happens
Trigger: Pairlist config contains an invalid sort_direction string (e.g. 'ascending', 'ASC'). The check runs in __init__.
Common situations: Wrong wording or capitalization copied from forum posts or another filter's docs.
Related errors
- StaticPairList requires pair_whitelist to be set.
- VolatilityFilter requires lookback_days to be >= 1
- VolatilityFilter requires sort_direction to be either None (
- key {self._sort_key} not in {SORT_VALUES}
- VolumeFilter requires lookback_period to be >= 0
AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15).
Data as JSON: /api/errors/db8fc1b952688feb.
Report an issue: GitHub.