Leverage and margin explained: how liquidation really works

Leverage is the single biggest reason trading bots blow up. It lets you control a position larger than your capital by borrowing against margin — and it multiplies losses exactly as it multiplies gains. At 10× leverage, a 10% move against you wipes out your entire margin and the exchange liquidates the position. Most beginners do not understand the liquidation math until it happens to them. This guide explains leverage and margin plainly, shows the maintenance-margin and liquidation-price formula, contrasts isolated and cross margin, and explains why a leveraged bot dies.

On this page
  1. What leverage is
  2. Initial & maintenance margin
  3. The liquidation math
  4. Isolated vs cross
  5. Why bots blow up
  6. Using leverage safely
  7. FAQ

What leverage actually is

Leverage lets you open a position larger than your account by borrowing from the exchange against collateral called margin. 10× leverage means $1,000 of margin controls a $10,000 position. Your gains and losses are calculated on the full $10,000 — so a 1% move is a 10% swing on your capital. The borrow is free of directional risk to the exchange because they liquidate you before your margin runs out.

Initial and maintenance margin

Initial margin is what you post to open the position. Maintenance margin is the minimum equity you must keep — fall below it and you are liquidated. The gap between them is your buffer, and higher leverage shrinks it toward zero.

The liquidation math

For a long position, the liquidation price is roughly where your losses eat the margin down to the maintenance level:

python · liquidation.pydef liq_price_long(entry, leverage, mmr=0.005):
    # mmr = maintenance margin rate (e.g. 0.5%)
    return entry * (1 - 1/leverage + mmr)

print(liq_price_long(100, 10))   # ~90.5  → a 9.5% drop liquidates 10x
print(liq_price_long(100, 25))   # ~96.5  → a 3.5% drop liquidates 25x
entry 5x: -19% to liq 10x: -9.5% 25x: -3.5%
At 25× a routine 3.5% wick liquidates you; at 5× you have a 19% buffer. Leverage is liquidation distance.

Isolated versus cross margin

Isolated margin walls off a fixed amount per position — if it liquidates, only that margin is lost. Cross margin shares your whole balance as collateral, giving more buffer but risking the entire account on one bad trade. Most disciplined bots use isolated margin to cap the damage of any single position.

Why leveraged bots blow up

Leverage turns volatility into ruin

Crypto routinely wicks 5–10% in minutes. At 10–20× leverage those normal wicks hit your liquidation price and close the position at the worst possible moment — often right before price recovers. The bot did nothing wrong; the leverage guaranteed the wick would kill it. This is the dominant failure mode in futures bots.

Using leverage safely

Keep leverage low (2–3× at most while learning), use isolated margin, set a hard stop well inside the liquidation price, and size from that stop with the position calculator — never from the leverage. Backtest the strategy unlevered first on the backtester; leverage cannot rescue a losing edge, it only accelerates the loss.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

What is leverage in trading?

Leverage lets you control a position larger than your account by borrowing against collateral called margin. At 10× leverage, $1,000 controls a $10,000 position and your gains and losses are calculated on the full amount, so a 1% price move becomes a 10% swing on your capital.

What is a liquidation price?

The liquidation price is the level at which your losses have eroded your margin down to the maintenance minimum, forcing the exchange to close your position. Higher leverage moves this price closer to your entry — at 25× a roughly 3.5% adverse move liquidates you, versus about 19% at 5×.

What is the difference between isolated and cross margin?

Isolated margin walls off a fixed amount per position, so a liquidation loses only that margin. Cross margin shares your entire balance as collateral, giving more buffer but risking the whole account on one bad trade. Disciplined bots usually use isolated margin to cap the damage.

Why do leveraged trading bots blow up?

Crypto routinely wicks 5–10% in minutes, and at 10–20× leverage those normal wicks reach the liquidation price and close the position at the worst moment, often just before price recovers. The leverage, not the strategy, guarantees the wick is fatal — which is why keeping leverage low and using hard stops is essential.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.