Sub topic 1
Margin and leverage: controlling more than you deposit
Leverage lets a trader hold a position larger than the money they deposit. This chapter covers the basic vocabulary and arithmetic: margin, position size, leverage, and the borrowed part of a trade. Later chapters build on these terms to explain profit and loss, liquidation prices, and cascades.
Prerequisites
This chapter assumes you already have the following:
- A basic idea of buying, selling and holding crypto assets.
- Familiarity with long positions (profiting when the price rises) and short positions (profiting when the price falls).
- Comfort with percentages and simple arithmetic.
- Basic Python reading ability, since the examples are short Python functions.
You do not need to have traded with leverage before.
The core idea
A leveraged position is a trade whose size (its notional value) is larger than the capital the trader puts up. The capital the trader puts up is called margin. Margin is collateral: money or crypto that the exchange or protocol holds to cover possible losses on the trade.
The trader does not necessarily receive a loan of cash. On a derivatives exchange, the exchange lets the trader open a position bigger than their balance, as long as enough margin is set aside to absorb a reasonable loss. In a lending protocol, the trader borrows an asset against collateral. The effect is the same in both cases: exposure to price changes that is larger than the deposit.
Three quantities define a leveraged position:
| Term | Meaning | Example |
|---|---|---|
| Margin | The trader's own capital locked in the position | 1,000 USDT |
| Position size (notional) | Total market value of the position | 10,000 USDT |
| Leverage | Position size divided by margin | 10x |
The relationship is simple:
leverage = position size / margin
margin = position size / leverageThe margin a position needs when it is opened is called the initial margin. At 10x leverage, the initial margin is 1/10, or 10%, of the position size. At 5x it is 20%. At 100x it is 1%.
A worked example
Suppose Bitcoin trades at 50,000 USDT. A trader has 1,000 USDT and wants to go long.
- Without leverage, 1,000 USDT buys 0.02 BTC.
- With 10x leverage, the trader opens a position worth 10,000 USDT, which is 0.2 BTC. The 1,000 USDT is the margin.
The position is ten times larger than the account balance. If Bitcoin rises 2% to 51,000, the 0.2 BTC position gains 200 USDT. That is a 20% return on the 1,000 USDT margin. If Bitcoin falls 2% to 49,000, the position loses 200 USDT, a 20% loss on margin.
The same position can be written as a small function:
def position_size(margin, leverage):
"""Notional value controlled by a given margin at a given leverage."""
return margin * leverage
def required_margin(size, leverage):
"""Initial margin needed to open a position of a given notional size."""
return size / leverage
def quantity(margin, leverage, price):
"""Units of the asset controlled."""
return position_size(margin, leverage) / price
print(position_size(1000, 10)) # 10000
print(required_margin(10000, 10)) # 1000.0
print(quantity(1000, 10, 50000)) # 0.2Running this prints 10000, 1000.0 and 0.2, matching the worked example above.
Where the borrowed exposure comes from
Where the extra exposure comes from depends on the venue.
Margin trading on spot markets
On a margin spot market, the exchange lends the trader extra funds or assets. To go long with 3x leverage on 1,000 USDT, the trader borrows 2,000 USDT, buys 3,000 USDT of the asset, and pays interest on the loan. To go short, the trader borrows the asset itself, sells it, and hopes to buy it back cheaper. The loan is real, and it accrues interest.
Derivatives such as perpetual futures
On a futures exchange, the trader does not buy the asset. They enter a contract whose profit and loss follow the asset's price. There is no loan of cash, but the exchange requires margin so that it can cover the trader's losses. Perpetual futures are the main venue for crypto leverage and get their own chapter.
Lending protocols
In decentralized finance (DeFi), a user can deposit collateral, borrow another asset against it, and use the borrowed asset to buy more of the collateral. Repeating this loop builds leveraged exposure without a derivatives contract. A later chapter covers the liquidation rules in these protocols.
Why exchanges allow it, and what they require
An exchange earns fees on every trade, so larger positions mean more fee revenue. It also takes on risk: if a trader's loss exceeds their margin, someone has to cover the difference. To limit this, the exchange imposes rules:
- A minimum initial margin, which sets the maximum leverage for a given market.
- A maintenance margin, a smaller threshold below which the position is closed automatically.
- A forced-closing process, called liquidation, that runs when the margin falls too low.
Higher leverage means a thinner cushion. With 10x leverage, a 10% adverse move wipes out the whole margin. With 2x leverage, it takes a 50% move. This cushion is the central idea of the whole tutorial, and the next chapters turn it into formulas.
flowchart TD
A[Trader deposits margin] --> B[Exchange allows a larger position]
B --> C[Price moves in the trader's favour]
B --> D[Price moves against the trader]
C --> E[Gain is a multiple of margin]
D --> F[Loss eats into margin]
F --> G[Margin falls below maintenance level]
G --> H[Position is liquidated]The block above is only a rough sketch of the flow. The version below uses the required diagram format.
Leverage is a choice, not a fixed property
Two traders can hold the same position size with different leverage. Suppose both want a 10,000 USDT long.
- Trader A deposits 1,000 USDT as margin and uses 10x leverage.
- Trader B holds 5,000 USDT in the account and sets the position to use only 2,000 USDT as margin. That is 5x leverage on the position.
Trader B still has 3,000 USDT of free balance. If the price falls, that balance may or may not be available to support the position, depending on the margin mode. Chapter 6 covers isolated and cross margin. For now, note that the leverage of a position is a ratio between position size and the margin assigned to it, and it can change as the price moves.
Effective leverage drifts
The leverage you chose when opening the trade is not the leverage you have later. Take the 10x long from the worked example. If the price falls and the position loses 300 USDT, the equity (margin plus unrealized profit or loss) is now 700 USDT. The position's market value is about 9,700 USDT. Effective leverage is now roughly 9,700 / 700, or 13.9x. As losses grow, effective leverage rises, and the trade becomes more fragile. A winning long does the opposite: effective leverage falls as equity grows.
def effective_leverage(entry, price, margin, leverage):
"""Current notional divided by current equity for a long position."""
qty = margin * leverage / entry
notional = qty * price
equity = margin + qty * (price - entry)
return notional / equity
print(round(effective_leverage(50000, 50000, 1000, 10), 2)) # 10.0
print(round(effective_leverage(50000, 48500, 1000, 10), 2)) # 13.86
print(round(effective_leverage(50000, 51500, 1000, 10), 2)) # 7.9A 3% drop raises effective leverage from 10x to about 13.9x. A 3% rise lowers it to about 7.9x.
Common mistakes
- Confusing leverage with the amount borrowed. A 10x position on 1,000 USDT is 10,000 USDT of exposure, but only 9,000 USDT of it is "extra". Be consistent about whether you mean total exposure or the borrowed part.
- Thinking the exchange's maximum leverage is a safe level. The maximum is a limit the venue sets for its own risk. It says nothing about what is sensible for a trader.
- Ignoring costs. Trading fees, interest on borrowed funds, and funding payments on perpetuals all reduce equity. On a highly leveraged position, a few percent of the margin can disappear in fees and funding alone.
- Treating margin as a fee. Margin is not spent when the position opens. It is returned, adjusted for profit and loss, when the position closes. It is lost only if the position is liquidated or loses money.
- Assuming the loss is capped at margin. On most exchanges, liquidation is designed to close a position before the margin is gone, but fast markets can gap past the closing price. Later chapters cover what happens then.
Summary
- Margin is the capital you lock up. Position size is the exposure you control. Leverage is the ratio of the two.
- Initial margin is position size divided by leverage.
- Leverage can come from margin loans, derivatives contracts, or DeFi borrowing loops.
- Effective leverage changes as equity changes, rising after losses and falling after gains.
- The cushion between your margin and the point of forced closing shrinks as leverage rises.
Exercise
A trader opens a long position worth 20,000 USDT using 4,000 USDT of margin. (a) What is the leverage? (b) If the price rises 3%, what is the profit in USDT and as a percentage of margin? (c) What price fall would remove all of the margin, ignoring fees and any maintenance requirement?
Show answer
(a) Leverage = 20,000 / 4,000 = 5x. (b) Profit = 3% of 20,000 = 600 USDT, which is 600 / 4,000 = 15% of margin (5 x 3%). (c) The margin is wiped out when the loss equals 4,000 USDT, which is 4,000 / 20,000 = 20% of the position value, so a 20% price fall (1 / leverage). In practice, liquidation happens before this point because of the maintenance margin.
Exercise
A trader goes long 0.5 BTC at 40,000 USDT using 5x leverage. (a) How much margin is required? (b) The price falls to 38,000 USDT. What is the equity, and what is the effective leverage? Round to one decimal place.
Show answer
(a) Position size = 0.5 x 40,000 = 20,000 USDT. Margin = 20,000 / 5 = 4,000 USDT. (b) Unrealized loss = 0.5 x (38,000 - 40,000) = -1,000 USDT, so equity = 4,000 - 1,000 = 3,000 USDT. Notional at the new price = 0.5 x 38,000 = 19,000 USDT. Effective leverage = 19,000 / 3,000 = 6.3x.
Exercise
Explain in one or two sentences why a trader who chose 10x leverage at entry can be holding a much higher effective leverage later, even though they never changed the position.
Show answer
Effective leverage is the current position value divided by current equity. When the price moves against the trader, equity shrinks while the position value stays almost the same, so the ratio rises. A losing 10x position is therefore riskier than it was at entry, and it sits closer to the maintenance level.