Learn › Glossary › Margin

Margin

Borrowing from your broker against your holdings to buy more than your cash allows. Margin amplifies both directions, accrues interest, and introduces the margin call — forced liquidation at the worst moment. Cash-only automated strategies avoid the entire category of margin surprises.

Margin is a loan from a broker, secured by the securities already in the account. It allows a trader to hold more than the cash balance would pay for. If the account holds $10,000 and borrows against it, the positions are larger than $10,000, and every percentage move in the price is a larger dollar move in the account. A gain is bigger, a loss is bigger, and the loan accrues interest whether the position wins or loses.

The part that matters most for automated trading is the margin call. When the account value falls far enough against the loan, the broker can require more cash or sell positions to bring the loan back inside its limits. The sale happens at whatever price the market gives at that moment, which is usually after a fall. A trade that would have recovered if it had been held can be closed at the low, and the recovery goes to the person who bought it.

Every backtest in the DeployQuant Learn library runs without margin. Each starts with $10,000 in cash, buys with 98% of the sleeve at most, and never borrows. The results in the library, from the tables on SPY to the volatility products, show what each rule did with cash alone. Nothing on this page is a measurement of a margin account, because none was run. What the data can show is how much the underlying funds moved, which is the quantity margin multiplies, and how a leveraged fund behaves when the multiplication is built into the fund.

Margin sits next to two other terms in the glossary. Leverage is the wider idea of controlling more exposure than the capital in the account, through margin or through leveraged funds. Risk management covers the limits that keep a strategy's loss bounded, and a cash-only rule is one of the simplest of those limits.

What margin multiplies: the size of the moves

Margin does not change what a fund does. It changes how much of the account is exposed to the move. To see what is being multiplied, look at how large the moves were in the 2021-01-04 to 2026-10-02 window.

SPY returned 125.29% in total, a CAGR of 15.2%, with annualized volatility of 16.41%. Its worst fall ran from a peak on 2022-01-03 to a trough on 2022-10-12, a drawdown of 24.51%, and it took until 2023-12-13 to recover. The longest drawdown lasted 488 sessions. SPY fell 10% inside a 20-session window on 11 occasions, spread over 23 days in all.

QQQ returned 151.07%, a CAGR of 17.39%, with volatility of 22.39% and a drawdown of 35% from 2021-11-19 to 2022-11-03, recovering on 2023-12-12. It had 21 episodes of a 10% fall inside 20 sessions, over 82 days. IWM returned 55.8% with volatility of 22.35% and a drawdown of 31.92% that took until 2024-11-06 to recover, with a longest drawdown of 752 sessions. Its drawdown events numbered 26 over 67 days.

A cash account that held QQQ through 2022 lost money and waited. The loss was real, the position stayed in the account, and the recovery in 2023 and later came back to the holder. A margin account in the same position faces a different set of choices at the bottom, because the loan is a fixed amount and the equity behind it has shrunk. The account value, not the price of the fund, is what the broker watches. The same price move takes a larger bite out of the equity, and the drawdown of the account is a multiple of the drawdown of the fund. The facts here do not include a margin run, so the size of that multiple is not stated, and it depends on how much was borrowed.

What the data does give is the baseline. SPY's 24.51% fall in 2022 is the reference point. QQQ fell by more, and a fund with a drawdown of 35% leaves much less room before a lender asks for a response than a fund with a drawdown of 24.51%. Volatility is the other measure. SPY's average up day was 0.74% and its average down day minus 0.74%. QQQ's were 1.01% and minus 1.06%. IWM's were 1.09% and minus 1.08%. A borrowed position takes each of those days at a larger scale.

Leverage built into a fund: TQQQ and UVXY

Some funds apply the borrowing inside the fund, so the account can stay cash-only and still hold a leveraged position. TQQQ is a fund with nominal leverage of 3 on QQQ. Its measured numbers show what a large multiple does over a few years.

TQQQ returned 291.92% over the window, a CAGR of 26.86%, with annualized volatility of 67.11%. Its maximum drawdown was 81.68%, from 2021-11-19 to 2022-12-28, and it did not recover until 2024-12-04. The longest drawdown lasted 762 sessions. The fund fell 10% inside 20 sessions on 56 occasions, over 478 days in all. Its average up day was 3.01% and its average down day minus 3.22%, and its average intraday range was 4.74%.

The calendar years show how the multiple works in both directions. TQQQ returned 90.95% in 2021 when QQQ returned 29.18%. It lost 79.07% in 2022 when QQQ lost 32.39%. In 2023 it gained 198.32% against 54.81% for QQQ, then 58.22% in 2024, 34.36% in 2025 and 54.6% in 2026 so far. A holder had to sit through the 2022 fall to collect the later years, and the same would be true for a borrower, with the added possibility that the lender acts first.

The measured numbers also show that a fixed multiple does not give a simple return. Over the common window QQQ returned 151.07%. Three times that is 453.22%, and a daily-rebalanced 3x position would have returned 568.66% on the same path. TQQQ itself returned 291.92%. The realized beta to QQQ was 3, and the gap between the simple multiple and the fund return, as the fact table has it, is minus 161.29 percentage points. The gap changes sign from year to year: it was 3.42 points in 2021, 18.12 in 2022 and 33.9 in 2023, then minus 18.56 in 2024, minus 27.96 in 2025 and minus 12.71 in 2026. A fund that resets its exposure each day compounds differently from a position held at a fixed multiple, and the difference is large enough to see in these figures. Margin on a fixed loan has its own path, and this table is not a model of it.

UVXY sits at the far end of the range. It lost 99.94% over the window, a CAGR of minus 72.83%, with annualized volatility of 103.95% and a drawdown of 99.95% that never recovered. Its beta to SPY was minus 4.84. Buy-and-hold in the test turned $10,000 into $216. A position with a loss of that size shows why the cash-only limit matters: the most the account can lose is the cash put in. A borrower could lose more than the deposit on a fund that moves as UVXY does, and what a broker does in that case is a matter to check with the broker.

What cash-only means for an automated strategy

The Learn library's backtests assume no margin, and the cash-only rule has a plain effect. A strategy can buy only what the sleeve's cash covers. The rules that size positions at 98% of the sleeve use cash and nothing else.

DeployQuant checks every order against its sleeve's cash before the order is sent. Each strategy runs in its own sleeve, with its own cash, positions and profit and loss, so one strategy cannot spend another's money. Per-order and per-position dollar caps add a second limit, and caps never block an order that reduces exposure. Price bands refuse limit orders priced too far from the market. Cash in the account that is not allocated to a sleeve is never traded. Positions the user trades by hand stay theirs.

Those checks work on cash in the sleeve. They do not describe how a broker treats a margin account, and the product reference does not claim that they do. The broker's own margin settings and rules are set between the user and the broker. A user who has margin enabled on a brokerage account should read the broker's terms for how borrowing, interest and forced sales work there.

The pattern day trader rule is one place where account type and rules meet automation. The answer to whether the pattern day trader rule affects automated strategies covers it. Rules like that depend on the broker and the account, and a broker or a tax professional is the right source for the specifics.

What the cash-only rules returned

Because the library is cash-only, its numbers show the rules without any borrowing, and they show how modest cash-only returns can be. Across the 59 ETFs, the median CAGR of the weekly 7% target was 6.61%, with a median maximum drawdown of 26.26% and a median of 106 round trips. It beat buy-and-hold on 34 of 59 funds. The RSI(2) snapback had a median CAGR of 4.74%, a median drawdown of 17.47% and a median of 166 round trips, and it also beat buy-and-hold on 34 of 59.

The slower rules sit lower. The golden cross had a median CAGR of 2.05% with a median drawdown of 21.84% and 3 round trips. The 200-day regime filter had 1.84%, and the dip buyer had 1.33%. The monthly cycle had a median CAGR of 5.46% but a median drawdown of 36.63%, the deepest of the 12, and beat buy-and-hold on 14 of 59 funds. The trend plus trailing stop rule had a median drawdown of 31.15%.

A common reaction to modest returns is to want more size. Margin is one way to get it. The numbers here show the other side of that choice. A rule with a median drawdown of 26.26% and a median CAGR of 6.61% is exposed to a fall of 26.26% before any borrowing. With borrowing, the fall in the account is larger, and the margin call arrives sooner. The drawdown figures in the tables are the ones to read first, because they set how much room a lender would leave.

These are medians across 59 funds, and individual pages differ widely. The same rules produced much larger drawdowns on volatile funds, and the backtests are hypothetical, with one window, no fees in the headline runs, and daily decisions.

Interest, timing and the order of events

Margin has a cost that does not appear in any chart in the library: interest on the borrowed amount. The charge accrues for as long as the loan is open, so a position that goes nowhere still loses ground. The rate is set by the broker. This library does not state a rate, because none was measured, and a reader should ask the broker for its current schedule.

A second cost is timing. A margin call turns a drawdown into a sale. In the measured data, the recoveries took a long time. SPY needed until 2023-12-13 after its 2022-01-03 peak. QQQ needed until 2023-12-12. TQQQ needed until 2024-12-04. IWM needed until 2024-11-06 and TLT, which fell 44.06% from 2021-01-04 to 2023-10-19, had not recovered by the end of the window. A cash holder in any of those funds could wait through the whole stretch. A borrower who was forced out at the bottom could not.

TLT is a useful case because it is a bond fund with moderate volatility of 15.33%, lower than QQQ, and it still had a 44.06% drawdown with a longest drawdown of 1,443 sessions. Low volatility day to day did not protect against a long, deep decline. A loan sized to the volatility of a fund like TLT would have been sized to the wrong risk, and the data on TLT is a reminder that the volatility figure alone does not describe the worst case.

The order of events in an automated system also matters. A strategy that decides once a day at the open and sends market orders reacts to the price it sees at that open. A broker's margin system can act at any time during the session. A rule that would have held through an intraday dip can be closed by the broker before the rule gets a chance to decide. The backtests here cannot show that, because they have no lender in them.

Questions for the broker and a tax professional

Margin raises several questions that depend on the broker, the account and the country, and the library has no figures for them. The interest rate, the maximum borrowing, the point at which a call is issued and the order in which positions are sold are all set by the broker. The tax treatment of interest paid and of gains on borrowed positions depends on the reader's situation. A tax professional can answer that, and the broker's agreement answers the rest.

For an automated strategy the practical questions are these. Is margin turned on in the brokerage account that the strategy trades. If it is, how much of the account value can the broker lend, and what happens to open orders when a call is issued. Does the strategy's sleeve see the cash balance or the buying power. Each of these has a definite answer in the broker's documentation, and none of them can be read from a backtest.

Where this evidence stops

The tables behind this page cover US stocks and ETFs from 2021-01-04 to 2026-10-02, a window of 5.74 years that contains one large bear market in 2022 and several sharp drops in 2025 and 2026. They contain no margin runs, no interest costs and no broker behaviour. They measure the funds and the rules, and the claim that margin multiplies those figures is general finance, not a result of this test.

The leveraged and inverse funds in the library are the closest measured stand-in, and even they are different from a margin loan. A fund resets its exposure daily and a loan does not. The fund cannot be called, and a loan can. The fund's loss is bounded by what was put in, and a loan's is not.

Frequently asked questions

What is margin in trading?

Margin is borrowing from a broker against the securities in an account, to hold more than the cash balance would pay for. It enlarges gains and losses, accrues interest, and allows the broker to sell positions through a margin call.

Do the backtests on Learn use margin?

No. Every backtest starts with $10,000 in cash, uses no margin, and holds at most 98% of the sleeve in one position. The headline runs also have no fees or slippage.

How big were the market falls that margin would multiply?

SPY fell 24.51% from 2022-01-03 to 2022-10-12 and QQQ fell 35% from 2021-11-19 to 2022-11-03. TQQQ, a fund with 3 times nominal leverage on QQQ, fell 81.68% in its worst drawdown.

Is a leveraged ETF the same as margin?

No. The borrowing is inside the fund, which resets its exposure daily, and the investor's account stays cash-only. TQQQ returned 291.92% over the window, while a simple 3 times QQQ's 151.07% would be 453.22%, so the fund path differs from a fixed multiple.

Does DeployQuant use margin?

Orders are checked against each sleeve's own cash before they are sent, and the backtests use no margin. How a broker's margin features apply to a connected account is set by the broker, and users should read the broker's terms.

Can a margin call happen to an automated strategy?

If the brokerage account has margin enabled and the account value falls far enough, the broker can issue a call or sell positions whatever the strategy is doing. The backtests here do not model that, so check the broker's rules.

Why does the library show drawdown first for risky funds?

Drawdown shows how far an account fell and how long it took to recover, which is what a lender watches. TQQQ's drawdown of 81.68% took until 2024-12-04 to recover, and UVXY's drawdown of 99.95% never recovered.

Run a strategy that uses this yourself, free →

Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.

Related terms

LeverageControlling more exposure than your capital: through margin borrowing …Risk ManagementEverything that bounds what a strategy can lose: position sizing, stop…

Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.