freqtrade/freqtrade · error · OperationalException
Freqtrade only supports isolated futures for leverage tradin
Error message
Freqtrade only supports isolated futures for leverage trading
What it means
Binance.liquidation_price raises OperationalException('Freqtrade only supports isolated futures for leverage trading') when trading_mode is not FUTURES. After computing the maintenance-amount prerequisites, the method's final branch only implements the futures formula; spot/margin modes have no liquidation-price semantics here.
Source
Thrown at freqtrade/exchange/binance.py:381
upnl_ex_1 += trade.amount * mark_price - trade.amount * trade.open_rate
cross_vars = upnl_ex_1 - mm_ex_1
side_1 = -1 if is_short else 1
if maintenance_amt is None:
raise OperationalException(
"Parameter maintenance_amt is required by Binance.liquidation_price"
f"for {self.trading_mode}"
)
if self.trading_mode == TradingMode.FUTURES:
return (
(wallet_balance + cross_vars + maintenance_amt) - (side_1 * amount * open_rate)
) / ((amount * mm_ratio) - (side_1 * amount))
else:
raise OperationalException(
"Freqtrade only supports isolated futures for leverage trading"
)
def load_leverage_tiers(self) -> dict[str, list[dict]]:
if self.trading_mode == TradingMode.FUTURES:
if self._config["dry_run"]:
leverage_tiers_path = Path(__file__).parent / "binance_leverage_tiers.json"
with leverage_tiers_path.open() as json_file:
return json_load(json_file)
else:
return self.get_leverage_tiers()
else:
return {}
async def _async_get_trade_history_id_startup(
self, pair: str, since: int
) -> tuple[list[list], str]:
"""View on GitHub (pinned to 1c8edfe4d1)
Solutions
- Set trading_mode: futures and margin_mode: isolated in config if you need liquidation prices
- Remove/gate liquidation_price calls and liquidation-related callbacks for spot strategies
- Guard strategy code with self.trading_mode == TradingMode.FUTURES (or config check) before touching leverage APIs
Example fix
# before
def custom_stoploss(self, pair, trade, ...):
liq = self.exchange.liquidation_price(...) # crashes on spot
# after
from freqtrade.enums import TradingMode
def custom_stoploss(self, pair, trade, ...):
if self.config['trading_mode'] == TradingMode.FUTURES:
liq = self.exchange.liquidation_price(...) Defensive patterns
Strategy: type-guard
Validate before calling
from freqtrade.enums import TradingMode
if self.config['trading_mode'] == TradingMode.FUTURES:
liq = exchange.liquidation_price(...) Type guard
from freqtrade.enums import TradingMode
def is_futures(config) -> bool:
return config.get('trading_mode') == TradingMode.FUTURES Prevention
- Gate all leverage/liquidation logic (callbacks and direct calls) behind a trading_mode futures check
- When porting a futures strategy to spot, delete rather than comment out liquidation code
- Set trading_mode + margin_mode explicitly in every config to avoid inheriting defaults
When it happens
Trigger: Calling liquidation_price() on an Exchange (or strategy code path reaching it, e.g. leverage/liquidation callbacks) while config trading_mode is spot or margin on the Binance exchange class.
Common situations: A strategy ported from futures to spot that still implements liquidation callbacks or calls exchange.liquidation_price(); misconfigured trading_mode after switching a config from futures back to spot.
Related errors
- Parameter maintenance_amt is required by Binance.liquidation
- Please migrate your time_in_force settings to use 'entry' an
- Please migrate your order_types settings to use the new word
- Please migrate your unfilledtimeout settings to use the new
- Please migrate your pricing settings to use the new wording.
AI-assisted analysis of freqtrade/freqtrade@1c8edfe4d1 (2026-08-15).
Data as JSON: /api/errors/966790de83d859c4.
Report an issue: GitHub.