Risk Management
Risk management is the set of limits that decide how much a strategy can lose before something stops it. It covers position size, stop orders, caps on exposure, limits on single orders and switches that halt trading. Signal research asks when a rule is right. Risk management asks what happens when the rule is wrong, and in automated trading that second question has to be answered in advance, because nobody is watching every tick.
The backtests in the library give measured figures for the idea. Over 2021-01-04 to 2026-10-02, buy-and-hold on SPY had a maximum drawdown of 23.99%. The same window on TQQQ, a leveraged fund, produced an 81.68% fall from its peak, and holding UVXY ended 97.84% below the start. Those three numbers are the reason risk limits exist: the same account, with the same rules, can see very different losses depending on what it holds and how much of it.
Three related terms cover the parts of the subject in detail: position sizing, the stop-loss order and the kill switch. The sections here connect them to numbers from the engine, then describe the limits DeployQuant applies around a live strategy.
What a drawdown measures, with real funds
A drawdown is the fall from a prior peak in account value to the lowest point before a new peak. The maximum drawdown is the worst one in the window. It is the figure that tells a trader how bad the path was, which a final return cannot show.
The funds in the data show a wide spread. SPY fell 24.51% from 2022-01-03 to 2022-10-12 and did not recover until 2023-12-13, a stretch of 488 sessions below the old peak. QQQ fell 35% from 2021-11-19 to 2022-11-03, with a 516-session wait. IWM fell 31.92% and its longest spell under water was 752 sessions. TLT, a long-bond fund, fell 44.06% from its peak on 2021-01-04 to 2023-10-19 and had not recovered by the end of the data, so its longest drawdown covered 1,443 sessions.
The leveraged and volatility funds sit further out. TQQQ fell 81.68% from 2021-11-19 to 2022-12-28 and took until 2024-12-04 to recover, with annualized volatility of 67.11%. Its $10,000 buy-and-hold account run drew down 80.77%, with a Sharpe ratio of 0.69. UVXY had annualized volatility of 103.95%, a maximum drawdown of 99.95% and a total return of -99.94%.
Depth and time to recover are separate risks. A 24.51% fall that takes 488 sessions to repair can be harder to sit through than a quicker, deeper one. A trader who sizes a position needs both numbers: how far it can go against the account and how long it can stay there.
Position size sets the risk before any rule fires
Position sizing is the largest risk control, because it scales every later loss. The strategy templates in the library all buy with 98% of the sleeve, so each backtest measures a nearly fully invested account. That choice makes the drawdown of the strategy close to the drawdown of the fund it holds when it is invested.
Holding a different fund changes the risk as much as holding more of it. QQQ had a buy-and-hold drawdown of 34.23% and TQQQ one of 80.77% over the same dates, and both runs bought at the first open of the window. Only the fund differed. TQQQ had a realized beta of 3 to QQQ and 3.86 to SPY. A position of the same dollar size is therefore a much larger risk in TQQQ, and a smaller dollar position in TQQQ can carry the same market exposure as a full position in a broad fund.
Sizing also interacts with volatility. The average daily range was 1.15% for SPY, 1.58% for QQQ and 4.74% for TQQQ. A daily range that wide can reach a stop level in one session, which is why a rule that works on a calm fund can behave very differently on a volatile one without any change to the rule.
Position sizing covers the mechanics: percent of equity, fixed dollars or share count. A sleeve is the slice of an account that one strategy may use. DeployQuant gives each deployed strategy a sleeve holding its own cash, positions and profit and loss, so the sleeve works as a size limit: an order that needs more cash than the sleeve holds is stopped before it leaves.
Stops and exits built into the rules
A stop-loss order sells when price falls to a set level. Four of the 12 templates build the exit into the rules in different ways. The momentum breakout hands the exit to a 10% trailing stop after a +10% four-week burst. The trend plus trailing stop holds above the 200-day average until a 15% trailing stop fires. The weekly 7% target rests a +7% target and sells losers on Thursday afternoon. The dip buyer sells at +8%.
Their median results across the 59 funds show what each exit style did to drawdown. The trend plus trailing stop had a median maximum drawdown of 31.15%, the second deepest of the 12 templates, with a median of 4 round trips. A 15% trailing stop is wide, so a large part of a decline can happen before it fires. The momentum breakout had a median drawdown of 20.1%, with a median CAGR of 0% and 6 round trips. The weekly 7% target had 26.26% with 106 round trips and a median CAGR of 6.61%. The shallowest median drawdown among the 12 was the RSI(2) snapback at 17.47%, with 166 round trips, and the deepest was the monthly cycle at 36.63%.
A stop turns open-ended risk into a defined amount, at the price of sometimes selling a low that would have recovered. TLT shows the setting where that cost is highest. It closed above its 200-day average on only 35.18% of sessions and crossed the line 95 times, more than any other fund in the examples, so trend and stop rules there kept buying and selling without a long move to ride.
Gaps limit what a stop can deliver. Once triggered, a stop normally turns into a market order, so a gap through the level fills the sale lower than the stop price. Average overnight gaps were 0.44% on SPY, 0.59% on QQQ, 1.78% on TQQQ and 2.53% on UVXY. The headline backtests fill at the bar price with no slippage, which understates a gap. The 5 and 10 basis point runs on each strategy page give one measure of that cost.
Regime filters and drawdown across the 12 templates
A regime filter is a rule that holds cash when the market is in a state the strategy has not handled well. The 200-day regime filter owns the fund when price closes above its 200-day average and holds cash below. Its median maximum drawdown was 22.16% across the 59 funds, and it beat buy-and-hold on 26 of 59, with a median CAGR of 1.84%. The golden cross had a median of 3 round trips, a median drawdown of 21.84% and beat buy-and-hold on 27 of 59.
Neither filter beat holding on half the funds. The EMA 12/26 trend had a median drawdown of 22.87% and beat holding on 22 funds. The SMA 10/50 trend was at 23.02% and 21 funds.
The RSI(2) snapback and the weekly 7% target each beat buy-and-hold on 34 of the 59 funds, the highest count among the 12. Both trade often, with exits tied to a short hold or a profit target. The monthly cycle beat holding on 14, the lowest count. In this window the rules that exited quickly were ahead of the rules that stayed invested through the 2022 decline, which is a result for one period only.
One bad year across the example funds
Calendar 2022 is the clearest test of risk in the window, because all six example funds lost money in it. SPY returned -18.16%, QQQ -32.39%, IWM -20.5% and TLT -31.21%. TQQQ returned -79.07%. A portfolio that held a stock fund and a bond fund as a hedge saw both fall in 2022, and TLT's correlation to SPY over the full window was only 0.08, which says the two moved independently on average and offered no protection that year.
The year after shows the other side. TQQQ returned 198.32% in 2023 and QQQ 54.81%, while TLT returned 2.79%. An account that stopped trading after 2022 would have missed it, and an account that held a full position through 2022 had to sit through the 81.68% drawdown to collect it. Risk limits decide which of those two paths a user takes, and the backtests give no way to say beforehand which choice would have paid.
UVXY fell in every calendar year of the data: -89.67% in 2021, -44.65% in 2022 and -87.75% in 2023. Its average up day was 5.15% and its beta to SPY was -4.84. A fund like that can look like a hedge on a single day and still lose almost everything over years of holding, which is why a position limit on such a fund needs to count time as well as size.
The rails DeployQuant puts around a live strategy
A backtest checks a rule. Going live adds other failure modes: a bad price, a repeated order, a dropped connection, a strategy that misbehaves. DeployQuant puts its limits outside the strategy code, so they apply whatever the rules say.
- A live deployment starts only after the user types a confirmation.
- Price bands reject a limit order set far from the market.
- Dollar caps apply per order and per position, and a further cap limits orders per sync. An order that cuts exposure always passes the caps.
- Dry-run mode goes through the full order flow and sends nothing to the broker.
- A pause switch exists for one strategy and another for every strategy on a broker connection.
- Books are built from the broker's own fill reports, so they follow what actually filled.
- A broker connection can trade and read. It cannot move money out.
The kill switch is the control a user reaches for first. When behavior is unexpected, new orders stop before anyone debugs, and trading restarts only by a separate, deliberate action.
Sleeves add separation. When one strategy liquidates, only its own holdings are sold. Two strategies may hold one symbol while each keeps its own share on the books. Cash outside every sleeve is never traded, and anything the user buys by hand remains untouched.
The pattern day trader rule is a regulatory limit that sits outside any strategy. It is covered in a separate answer on whether it affects automated strategies. Questions about account rules and taxes belong with the broker or a tax professional.
Testing risk before using money
A backtest reports risk as measured numbers, which makes it the cheapest place to learn how large a loss a rule produced. Each strategy page lists the three largest drawdowns with the peak, the low, the recovery date and the days involved. It also shows the year-by-year and month-by-month table, so a reader can see whether the maximum drawdown came from a single bad stretch or from a run of small losses.
The test has limits. It is one 5.74-year window that holds one deep bear market, in 2022, and it contains no other regime of that size. Drawdowns in other windows can be deeper. The headline run applies no fees or slippage and trades one fund at a time with no margin. A past worst case is not a ceiling on what can happen.
Paper trading is the next stage. It runs a strategy on the live market data feed without a broker, and it needs no brokerage account. After that a user can connect Webull, Charles Schwab or Alpaca and run a dry run before any real order. The stages put the loss figures and the order behavior in front of the user before real money is at risk. Each step is still only a test of the rule as written, and the fills in a live account can differ from the backtest.
Frequently asked questions
What is risk management in algorithmic trading?
It is the set of limits that bound what a strategy can lose: position size, stops, exposure caps, per-order limits and kill switches. Automated strategies need these rules written down in advance, because no one is watching every tick.
What is a good maximum drawdown for a strategy?
The data gives reference points rather than a target. Buy-and-hold on SPY had a maximum drawdown of 23.99% in the test window and QQQ 34.23%. The median drawdown across the 59 funds ranged from 17.47% for the RSI(2) snapback to 36.63% for the monthly cycle. The right limit depends on what an account can tolerate.
How does position size affect risk?
It scales every loss. The templates buy with 98% of the sleeve, so the drawdown follows the fund held. A fund like TQQQ, with a realized beta of 3 to QQQ, had an 80.77% buy-and-hold drawdown against 34.23% for QQQ.
Do stop-loss orders always protect a position?
They cap a loss only approximately. A triggered stop usually becomes a market order, so a gap can fill below the stop price, and average overnight gaps ran from 0.44% on SPY to 2.53% on UVXY. A stop can also sell a low that would have recovered.
What risk controls does DeployQuant apply to a live strategy?
A live deployment needs a typed confirmation, orders pass price bands and dollar caps, and an order that reduces exposure is never blocked by a cap. There is a dry-run mode, a pause for one strategy and a pause for a whole broker connection. Each strategy also has its own sleeve of cash.
Can a backtest show how risky a strategy is?
It shows the losses the rule produced in one window. Each page lists the largest drawdowns with dates, plus year and month tables. It cannot show regimes the window did not contain, and the headline run has no fees or slippage.
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
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.