Why Simulate Liquidation?
A leveraged backtest without liquidation simulation is fiction. A 10× leveraged position can be liquidated by a 10% adverse move — but without liquidation modeling, the backtest simply holds through the drawdown and recovers. This produces impossibly good results. ClyptQ simulates liquidation per exchange with the correct maintenance margin rate (MMR), liquidation fee, and margin ratio formula for each venue.How Liquidation Works
The Check
After every tick, for every futures account with open positions, ClyptQ checks whether the account should be liquidated:Two Margin Ratio Formulas
Exchanges use one of two formulas to compute margin ratio: Inverted (Binance):Exchange-Specific Parameters
The Default MMR values are Tier 1 (smallest position) rates. In reality, exchanges use tiered MMR where larger positions require higher maintenance margin. ClyptQ supports dynamic tier resolution for exchanges that expose tier data via CCXT: Binance (requires API key), Bybit, Gateio, and Kraken fetch real-time tier brackets. Coinbase does not expose tier data — it always uses the static default (6.67%).
Liquidation Calculation Step by Step
Example: Binance Futures (Inverted Formula)
Example: Bybit Futures (Normal Formula)
Example: Gateio (Higher Threshold)
Gateio uses a 1.5 threshold instead of 1.0 — meaning liquidation triggers earlier than on other exchanges:What Happens at Liquidation
When liquidation triggers:- All positions in the account are closed at current market price (with slippage applied)
- Liquidation fee is deducted from equity
- ExecutionResult is created with
trigger_type: "liquidation"metadata - Console warning is printed:
⚠️ [LIQUIDATION] binance:futures: 2 positions liquidated - Remaining equity (if positive) stays as cash in the account
Cross vs Isolated Margin
Cross Margin (Default)
All positions in an account share the same margin pool. The entire account balance is used as collateral:Isolated Margin
Each position has its own margin allocation. Losses on one position cannot consume margin from another:ClyptQ’s current backtest uses cross margin by default (all positions share the account balance). Isolated margin simulation is planned for a future release.
Configuration
Default Behavior
No configuration needed. Liquidation is checked automatically for every futures account after each tick:Custom MMR Override
For tiered positions or custom risk parameters:Impact on Strategy Design
Leverage Selection
Higher leverage means less equity buffer before liquidation:
Without liquidation simulation, a 10× backtest survives a 50% drawdown and “recovers.” With simulation, it gets liquidated at ~8% and the equity goes to near zero.
Stop Loss as Liquidation Prevention
Using stop-loss orders prevents liquidation and preserves capital:Related Pages
Exchange Specifics
Full exchange parameter tables including margin tiers
Cost Models
Fee structures that interact with liquidation costs

