VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Trading costs and execution

Margin trading explained: leverage, margin calls and backtest risk

Margin lets you control a position larger than your cash, so leverage multiplies both gains and losses. A backtest only reflects that risk when you size it with your real account and contract count and check whether the worst drawdown would have triggered a margin call.

By · Published · updated · Editorial policy

Contents
  1. What is margin trading?
  2. How is stock margin different from futures margin?
  3. How does leverage multiply gains and losses?
  4. What happens in a margin call and forced liquidation?
  5. How does leverage change drawdown in a backtest?
  6. How do you backtest with a realistic account size and contract count?
  7. Why do backtests rarely show margin calls?
  8. Frequently asked questions

What is margin trading?

Margin trading means controlling a position larger than your cash by putting up only part of its value. In stocks, the broker lends you the rest. In futures, margin is a security deposit held against daily losses. In both cases, leverage multiplies gains and losses. A backtest should therefore use your real account size and contract count.

How is stock margin different from futures margin?

Stock margin is a loan, and futures margin is a deposit. Both create leverage, but they work differently day to day.

Stock margin is like a mortgage: you borrow money to buy something, and you pay interest on the loan. Futures margin is like the deposit on a rented apartment: it is not part of the price. The landlord holds it to cover any damage, and you must top it up if some of it gets used.

Stock marginFutures margin
What it isA loan from the broker to buy more sharesA performance bond: a deposit that covers daily losses
InterestYou pay interest on the borrowed amountNo loan, so no interest on borrowed money
Who sets the minimumRegulators set minimums (in the US, Regulation T and FINRA rules); brokers can require moreThe exchange or clearing house sets it per contract; brokers can require more
Typical sizeIn the US, at least 50% of the purchase price at the start for most stocksUsually a small fraction of the contract's full value
How gains and losses settleThe value of the shares changes; the loan stays the sameGains and losses are paid in and out of the account every trading day
Stock margin versus futures margin: with stocks you pay part of the price in cash and borrow the rest, paying interest on the loan; with futures you put up a small deposit against the full contract value, with no loan and no interest, and daily losses are taken from that deposit A loan or a deposit? Stock margin vs futures margin Stock margin Cash Loan Rest is borrowed You pay interest Futures margin Full value Small deposit No interest Futures margin is not a loan. So: losses come out of it daily.
Stock margin borrows the rest of the price and charges interest; futures margin is a deposit held against daily losses, with no loan.

Futures have two levels. Initial margin is the deposit needed to open a position. Maintenance margin is the lower level the account must stay above while the position is open. Exchanges can change both values at any time, and they often raise them after volatile moves, so the exchange's contract page is the final word on current margin. For Taiwan index futures, the TAIEX futures margin calculator shows the margin per contract for TAIEX, Mini-TAIEX and Micro-TAIEX futures. Brokers often ask for more than the exchange minimum. Our guide to futures margin by broker, intraday and overnight covers how these levels differ.

How does leverage multiply gains and losses?

Leverage multiplies every price move by the ratio of your position's full value to your account. The same move that changes the market by 2% can change your account by 8%, 30% or more.

Think of a lever: a small push at one end moves the other end a long way, and it does this in both directions. Leverage is the ratio between the full value of your positions and the money in your account. In futures, the full value is called notional value. Notional value is the price of the contract multiplied by its point value, which is the money gained or lost per one-point move. The calculation is:

Leverage = notional value ÷ account equity

Here, notional value means the notional value of all your open contracts added together. Account equity is the cash in your account plus or minus the profit or loss of open positions.

Hypothetical example

An index future trades at 4,000 points, and one point is worth $50. One contract therefore has a notional value of 4,000 × $50 = $200,000. Initial margin is $10,000 per contract, and maintenance margin is $9,000. The account holds $50,000.

With one contract, leverage is $200,000 ÷ $50,000 = 4. A 2% move is 80 points, or $4,000. That is 8% of the account.

With four contracts, the margin uses $40,000, and the notional value is $800,000. Leverage is 16. The same 80-point move is now $16,000, or 32% of the account. If the move goes against you, equity falls to $34,000. That is below the $36,000 maintenance level for four contracts, so the broker issues a margin call.

Hypothetical example with a fifty-thousand-dollar account: the market moves 2 percent, the account moves 8 percent with one contract at leverage 4 and 32 percent with four contracts at leverage 16 A 2% move, a 32% loss Hypothetical: same account each time Market 2% 1 contract 8% 4 contracts 32% Leverage multiplies every move. So: size from drawdown, not margin.
Hypothetical example: the market moves 2%, but the account moves 8% with one contract and 32% with four.

What happens in a margin call and forced liquidation?

A margin call asks you to add money. If you do not add it, the broker closes your positions for you.

A margin call is a demand from your broker to deposit more money because your equity has fallen below the maintenance margin. In futures, the call usually asks you to bring the account back up to the initial margin level, not just to the maintenance level. Forced liquidation is the broker closing some or all of your positions without your instruction, because the account no longer has enough margin.

The usual order of events is:

  1. Losses on open positions reduce your equity, either at the daily settlement or during the session.
  2. Equity falls below maintenance margin, and the broker issues a margin call.
  3. You deposit money, or you close positions yourself, within the time the broker allows.
  4. If you do neither, the broker liquidates positions at market prices. When losses grow fast, many brokers liquidate during the session under their own risk rules and do not wait for the deadline.
  5. If the liquidation price leaves a negative balance, you owe the broker that amount.
Flow from loss to liquidation: when equity falls below maintenance margin the broker issues a margin call; if money is added the positions stay open, if not the broker closes them at market prices From loss to forced close Equity under maintenance margin Equity too low Margin call Money added Positions stay No money Broker closes A forced close locks in the loss. So: keep room above maintenance.
From loss to liquidation: equity falls below maintenance margin, the broker issues a margin call, and if no money is added the broker closes the positions.

Forced liquidation tends to happen at bad prices. It happens because the market has moved sharply against you, often during a gap or a fast session. The loss is locked in at that point. If the market later recovers, the account does not recover with it.

How does leverage change drawdown in a backtest?

With a fixed number of contracts, the money lost in a drawdown grows in direct proportion to the contract count, while the account stays the same size. The percentage drawdown can therefore jump from tolerable to account-ending with only a few more contracts. The free risk of ruin calculator shows the same effect on randomly drawn trade sequences, where raising the risk per trade changes how often the account loses half and how deep the drawdown runs.

Maximum drawdown is the largest fall in equity from a previous peak to a later low, before a new peak is reached. Many backtests report results for one contract in points or currency, with no account attached. That equity curve looks the same whether you trade it with a large account or a small one. The risk only becomes visible when you divide the drawdown by the money you would actually have.

Hypothetical example

A backtest on one contract shows a net result of $30,000 and a maximum drawdown of $12,000. The account holds $50,000, and maintenance margin is $9,000 per contract.

ContractsDrawdown in moneyDrawdown as % of accountMaintenance marginMargin call during the drawdown?
1$12,00024%$9,000No: equity stays at $38,000 or above
3$36,00072%$27,000Yes: after a loss of $23,000
5$60,000120%$45,000Yes: after a loss of $5,000; the drawdown is larger than the account

With three contracts, the backtest shows the drawdown recovering, and the strategy ending well ahead. The real account would have received a margin call about two thirds of the way into the drawdown. Without new money, it would have been liquidated there, so the recovery would never have reached it.

Hypothetical backtest at three contracts on a fifty-thousand-dollar account: the equity curve falls through the maintenance margin line, where a margin call ends the real account, while the backtest curve recovers afterwards in a part that exists only in the backtest Liquidated before recovery Hypothetical backtest, 3 contracts Real account Backtest only Margin call Maintenance The account ends at the margin call. So: check margin at your real size.
Hypothetical example: the backtest curve recovers, but the account crosses the maintenance margin line first. Everything after that point exists only in the backtest.

How do you backtest with a realistic account size and contract count?

Size the strategy from its drawdown and the margin it needs, not from the margin alone. Then check the result as a percentage of the account you will really trade.

  1. Test one contract with real costs first. Include commission, slippage and next-bar execution, so the drawdown is not understated. Write down the maximum drawdown per contract. Use a drawdown that includes losses on open trades if your tool reports it, because a margin call reacts to open losses, not only to closed trades.
  2. Look up today's margin. Take the initial and maintenance margin from the exchange's contract page. If your broker requires more, use the broker's figure.
  3. Choose a planning drawdown larger than the historical one. The worst drawdown in a backtest is one event from one stretch of history, not a ceiling. One possible choice is to plan for 1.5 to 2 times the backtest figure. The factor is a judgment, so write down the one you choose.
  4. Test each contract count. Multiply the planning drawdown by the number of contracts. Add the maintenance margin for that number of contracts. The total must stay below your account equity, with room to spare.
  5. Rerun the backtest at that size. Use the chosen contract count and your real starting account, then read the drawdown as a percentage of the account.
  6. Stress the margin. Repeat step 4 with a higher margin, for example 50% above today's level. Exchanges tend to raise margin in exactly the volatile periods when drawdowns happen.

If your strategy uses a fixed stop, the position size calculator turns account risk and stop distance into a contract count. Use it as a second check next to the drawdown test. To measure the drawdown and recovery time from your own equity series, use the drawdown calculator.

Why do backtests rarely show margin calls?

Most backtests assume the account can keep trading no matter how much it has lost, so a margin call never appears in the results. You have to add that check yourself.

Several common assumptions hide the problem:

  • Unlimited capital. Equity can fall below zero in the simulation, and the strategy keeps taking trades.
  • No margin, or today's margin only. Margin levels in the past were different, and exchanges change them often. Few backtests store a history of margin levels.
  • Closed-trade equity. If the curve only updates when a trade closes, a deep open loss in the middle of a trade does not show.
  • Clean fills. A real forced liquidation fills during a fast move or after a gap, for example at a weekend or holiday reopening. That is usually worse than the price the backtest uses.
  • Broker rules. Each broker has its own deadlines and intraday risk rules. A backtest cannot know them.

You can add a simple margin check after the backtest:

  1. Take the daily equity curve at your chosen contract count and starting account.
  2. For each day, subtract the maintenance margin for the open contracts.
  3. Find the first day the result falls below zero.
  4. Treat the strategy as ended on that day at that size, and compare that outcome with the full backtest.

If the two differ, the backtest result at that size was never reachable for your account.

In AlphaPrime (Valynox), the backtesting evaluates each strategy with fees, slippage, next-bar execution and trading sessions. The drawdown you size from therefore already includes costs. The Performance Report shows the equity curve, drawdown, trades and periodic performance, which are the inputs for the contract-count test above.

What this means if you use AlphaPrime: run your research on one contract with realistic costs, and take the drawdown from the Performance Report. Then decide the contract count for your own account with the margin and drawdown test before you trade.

Frequently asked questions

Is futures margin a loan?

No. Futures margin is a deposit that covers losses on your open positions. Nobody lends you the rest of the contract's value, so you pay no interest on borrowed money. Gains and losses are paid in and out of the account every trading day.

What happens if I do not meet a margin call?

The broker can close some or all of your positions at market prices, often during the session and without waiting for a deadline. The loss is final at the liquidation price. If that price leaves a negative balance, you owe the broker the difference.

How much leverage is too much for a futures strategy?

The limit comes from the strategy's drawdown, not from the margin. Multiply a planning drawdown that is larger than the backtest's worst by the number of contracts, then add the maintenance margin. If the total comes close to your account equity, you are using too many contracts.

Can a backtest simulate a margin call?

Most backtests do not, because they let the account keep trading after any loss. You can approximate one with the daily equity at your real account size. Mark the first day equity minus maintenance margin falls below zero, and treat the strategy as stopped there.