Sub topic 14
Practical ways to limit leverage risk
This chapter assumes you have read the earlier chapters. You should know how margin, maintenance margin and liquidation price work, how mark price triggers liquidations, and how funding and open interest describe crowded positioning. You should also be able to read short Python functions.
The earlier chapters explained why leverage is dangerous. This chapter covers what you can do about it. Every control here does one of two things. It moves the liquidation price further from the market price, or it caps how much you lose before liquidation matters.
Treat leverage as a result, not a setting
Exchanges let you slide a leverage control up to 50x or 100x. That slider is a maximum the exchange allows. It says nothing about how much risk you should take.
A better order of decisions:
- Pick an entry price and a stop price where your trade idea is wrong.
- Decide the share of your account you will lose if the stop is hit.
- Compute the position size from those two numbers.
- Set leverage only as high as needed to post the margin, and no higher.
The size formula is:
position value = (account × risk fraction) / stop distance
Here stop distance is the gap between entry and stop as a fraction of the entry price.
def size_position(account, risk_fraction, entry, stop):
"""Position value (notional) that loses risk_fraction of the account at the stop.
Ignores fees, funding and slippage."""
risk_amount = account * risk_fraction
stop_distance = abs(entry - stop) / entry
notional = risk_amount / stop_distance
return notional, notional / account
notional, account_leverage = size_position(10000, 0.01, 100.0, 95.0)
print(round(notional, 2), round(account_leverage, 2)) # 2000.0 0.2You risk 1% of a 10,000 account, which is 100. The stop is 5% away, so the position is worth 2,000. Relative to the whole account that is only 0.2x. The exchange leverage setting could still be 10x, which would post 200 of margin. What matters for risk is the account-level number, not the slider.
Keep the stop well inside the liquidation price
A stop only protects you if it triggers before liquidation. The gap between the two is your safety margin. It needs to absorb slippage, fast wicks, and fees.
A practical rule is to keep the liquidation price at least twice as far from entry as your stop. The function below reuses the isolated-position approximation from earlier and reports that ratio.
def liquidation_price(entry, leverage, maintenance_rate, side):
"""Approximate liquidation price for an isolated linear position.
Ignores fees, funding and exchange-specific tiering."""
initial = 1.0 / leverage
if side == 'long':
return entry * (1 - initial) / (1 - maintenance_rate)
if side == 'short':
return entry * (1 + initial) / (1 + maintenance_rate)
raise ValueError('side must be long or short')
def buffer_ratio(entry, stop, liq):
"""How many times farther the liquidation price is from entry than the stop."""
return abs(entry - liq) / abs(entry - stop)
entry, stop = 100.0, 95.0
for lev in (3, 5, 10, 20):
liq = liquidation_price(entry, lev, 0.005, 'long')
print(f"{lev}x liq={liq:.2f} ratio={buffer_ratio(entry, stop, liq):.2f}")
# 3x liq=67.00 ratio=6.60
# 5x liq=80.40 ratio=3.92
# 10x liq=90.45 ratio=1.91
# 20x liq=95.48 ratio=0.90At 20x the liquidation price (95.48) is closer than the stop (95). The exchange closes the position before your stop can act, so the stop does nothing. At 10x the ratio is just under 2, which is the edge of acceptable. At 5x you have room for a bad fill.
Choose the margin mode and collateral deliberately
Margin mode decides how far a single bad trade can reach into the rest of your money.
| Choice | What it limits | Failure mode |
|---|---|---|
| Isolated margin | The loss on one position is capped at the margin assigned to it | Liquidation can come sooner because no other balance backs the position |
| Cross margin | Gives a position the whole account balance as a buffer, so liquidation is further away | A single bad position can consume everything in the account |
| Stablecoin collateral | The collateral value does not fall when the market falls | Depends on the stablecoin holding its peg |
| Same-asset collateral, for example BTC margin on a BTC long | Avoids converting funds | Your collateral falls at the same time as your position loses value |
For speculative trades, isolated margin is the safer default. You decide in advance the most you can lose on that idea. Cross margin suits hedged positions, where one leg offsets the other, because the offsetting profit really does support the loss.
Collateral that falls with the position is a hidden form of leverage. If you post a volatile coin against a long on that same coin, a 20% drop hurts twice. The position loses value and the margin shrinks.
Keep a health factor buffer in DeFi lending
On a lending protocol the equivalent of a stop is not available. Nobody closes your loan at a price you choose, and liquidation happens whenever the health factor drops below 1. The control you have is the starting buffer.
If the health factor is HF, the collateral can fall by a fraction of 1 − 1/HF before liquidation, assuming the debt value stays fixed.
def collateral_drop_to_liquidation(health_factor):
"""Fractional fall in collateral value that takes the health factor to 1,
assuming the debt value does not change."""
return 1 - 1 / health_factor
for hf in (1.1, 1.5, 2.0):
print(hf, f"{collateral_drop_to_liquidation(hf):.1%}")
# 1.1 9.1%
# 1.5 33.3%
# 2.0 50.0%A health factor of 1.1 looks safe on the dashboard, but a 9% fall liquidates it. Crypto assets often move that much in a day. Many borrowers aim for 1.5 or higher on volatile collateral.
Two further points apply on-chain:
- Liquidators take a bonus, so you lose more than the debt shortfall. The penalty is a cost on top of the market move.
- Repaying or adding collateral needs a transaction. During network congestion, fees spike and confirmations slow, exactly when prices are moving. Plan the buffer so you do not need to act in a hurry.
Price in funding and crowding
On perpetual futures, funding is a running cost, and it grows with leverage when measured against your own money. A funding rate of 0.01% per 8 hours is 0.03% per day, about 10.95% per year on the position value. On a 10x position that is roughly 109.5% of the margin per year. A trade you plan to hold for weeks must be able to pay that.
Funding and open interest also give a rough read on crowding:
- Funding strongly positive and open interest rising means longs are crowded and paying to stay in. A small dip can start forced selling.
- Funding strongly negative with rising open interest means shorts are crowded, and a squeeze up is more likely.
Crowding is not a timing signal. Markets can stay crowded for weeks. Use it to size down or to widen your buffer, not as a reason to open a trade in the opposite direction with high leverage.
Operational habits
- Set alerts on distance to liquidation. Alert when the mark price has covered half the gap, not when it is nearly there.
- Decide your top-up in advance. Adding margin is a fine response only if it was planned. Adding margin to a losing trade because you hope it turns is how a 1% risk becomes a 30% loss.
- Do not average down with leverage. Adding to a losing leveraged position moves your average entry and your liquidation price in ways that are easy to misjudge.
- Cut size when volatility rises. The stop distance that suits a quiet week is too tight in a volatile one. Recompute the size with the wider stop.
- Leave only what you need on the exchange. Withdraw profits. Exchange insurance funds and auto-deleveraging protect the exchange, not you.
- Set a daily loss limit. After reaching it, stop trading for the day.
Common errors
- Using the maximum leverage because the exchange offers it.
- Placing a stop beyond the liquidation price, as in the 20x example.
- Trusting the approximate formula. Real maintenance rates rise with position size through tiers, and fees and funding reduce equity, so the real liquidation price is closer than the formula says.
- Assuming a stop-market order fills at the stop. In a cascade it fills at whatever the book offers.
- Forgetting that stops and liquidations may trigger on mark price, while the chart you watch shows last price.
Exercises
Exercise
Your account holds 5,000. You go long at 200 with a stop at 190, and you risk 2% of the account. (a) What position value do you open, and what leverage is that on the whole account? (b) If you post margin at 10x leverage with a 0.5% maintenance rate, where is the liquidation price, and does the stop sit safely inside it by the 2x rule?
Show answer
(a) The risk amount is 5,000 × 0.02 = 100. The stop distance is 10/200 = 5%. The position value is 100 / 0.05 = 2,000, which is 0.4x on the account. (b) Liquidation is 200 × 0.9 / 0.995 ≈ 180.90. That is 19.10 below entry, against a stop 10 below entry, so the ratio is about 1.91. It is just under 2, so the rule says to lower leverage, for example to 5x, which puts liquidation near 160.80 and gives a ratio of about 3.9.
Exercise
A lending position has a health factor of 1.25 and the debt is a stablecoin. (a) How far can the collateral fall before liquidation? (b) What starting health factor would let the collateral fall 40% before liquidation?
Show answer
(a) 1 − 1/1.25 = 0.20, so a 20% fall. (b) Solve 1 − 1/HF = 0.40, so 1/HF = 0.60 and HF ≈ 1.67.