Home › Documentation › US stocks
Module

💼 Portfolio Backtest: limited capital

The scanner answers "how did my strategy do on each stock, separately?". The Portfolio Backtest answers the question that really matters: "If on January 1st 2000 I had had $100,000 and had run this strategy over the whole NYSE, with a maximum of 10 positions at a time… what would have happened to MY money?"

It lives inside the Stocks → Backtest window, on its own card. It uses the same strategy, the same ticked stocks and the Capital/Positions/Min. value from Money Management — but now with one single shared account for all of them.

🧠

The problem: more signals than money

Your strategy is still exactly the same — its entries and exits rule, there is nothing special to design. But running it over thousands of stocks, any given day can produce 80 buy signals… and with $100,000 and 10 maximum positions only a few fit. Somebody has to decide which ones get executed. That is the module's job:

  • 1.Each day the exits are processed first (they free up money and a slot that same day).
  • 2.ALL the day's new signals are collected.
  • 3.The Selection criterion ranks them (never the list order: see below).
  • 4.The ones that fit are opened (equal weight: each position targets equity ÷ N). The rest are discarded — they are not queued.

If the cash does not reach the target size, you choose between shrinking the position or skipping the signal. Whatever is not invested stays in cash and is part of the backtest (which is why Exposure is measured). A position is only closed when its strategy gives the exit — not because a "better" candidate shows up: this is NOT rotational trading, it is your usual strategy with the money counted.

🎯

The Selection criterion — which ones do I buy?

Highest momentum · ROC(n)

Prioritizes the ones that have risen the most over the last n sessions (the "momentum window": 20 ≈ 1 month, 100 ≈ 5 months, 250 ≈ 1 year). The best documented edge in the literature.

Lowest volatility · ATR%

Prioritizes the calmest ones (entry ATR ÷ price). The low-volatility philosophy: the same edge with fewer scares… if it works in your universe.

Random (the reference)

It picks at random with a fixed seed (reproducible). This is not a joke: it is the bar everything else is measured against.

The alphabetical tie-break sin

Other backtesters, if you define no priority, break ties by symbol order: your result depends on whether the stock is called AAPL or ZTS, and reordering the list changes the backtest. AniQuant never uses the list order: either your criterion decides, or a measured and reproducible randomness does.

🎲

The Random Selection Band — merit or luck?

A 100% AniQuant concept. The Monte Carlo repeats the whole backtest N times (100 by default) letting CHANCE pick the signals — same capital, same rules, same strategy. The result is the p5 / p50 / p95 band: the spread of what you get with no selection criterion at all, pure luck.

It is the classic monkey throwing darts 🐒🎯: if a manager cannot beat the monkey, there is no talent — there is luck. Your criterion lands on a percentile within that band:

✅ Percentile ≥ 95

Above the band: the criterion picks better than chance. A real selection edge.

⚠️ Inside the band

Indistinguishable from luck: the criterion adds nothing. The result would have been similar picking blind.

⛔ Percentile ≤ 5

Below the band: it picks worse than chance. This happens more often than you would think — better to drop it.

A bonus: look at the band's width. If it is very wide, the backtest result depends enormously on which signals you happen to catch — the particular number you got deserves little confidence, whatever it is.

⚖️

Criteria comparison — the Selection Edge, isolated

The table runs all three criteria over the same signals, the same capital and the same rules — the only thing changing between rows is the tie-break. Any difference is, by construction, selection edge (or drag), not strategy edge. Your active criterion is marked with ◀ and every row carries its percentile vs chance.

The breakdown AniQuant proposes:
STRATEGY EDGE (when to buy)
  + SELECTION EDGE (which ones to buy when they do not all fit)
  + SIZING EDGE (how much to buy)
  = PORTFOLIO EDGE

With thousands of signals discarded for lack of capital, the selection edge can be worth as much as the strategy's. This table measures it separately — almost nobody does.

🔭 Multi-window momentum

The table also includes momentum at 1, 3, 5 and 12 months (ROC 20/60/100/250) next to your own window. Comparing their percentiles shows you where the selection edge lives: in recent strength or in the long trend?

🏁 The benchmark row

The last row is buy and hold the universe (equal-weight, point-in-time: the ones that are born come in and the delisted go out with their penalty). It is the definitive yardstick: if your strategy + selection cannot beat this row, everything else is beside the point.

📊

The dashboard

Portfolio equity (realized)

The account day by day: cash + positions at cost, with the P&L booked at each trade's close. The dotted line is your starting capital, and the gray line is the 🏁 equal-weight buy-and-hold benchmark of the same universe.

📊 Portfolio occupancy

% of the time with N positions open (the green bar = portfolio FULL). Full around 90% of the time → capital is the bottleneck and selection matters enormously. Half empty → there is capital to spare: the problem is the signals, not the selection.

🌊 Drawdown  ·  📊 P&L distribution

How deep and for how long the account suffers; and the shape of the P&L per trade (many small ones and a few big? fat tails?).

📅 P&L month×year  ·  🏆 Top tickers

The heatmap shows consistency across decades (a stable edge, or two crazy years?). The top tickers expose concentration: if 2 names explain the whole net, the result is fragile.

Plus the cards: Net, Return, CAGR, Max DD, Ret/DD, trades executed out of total signals, discarded (the real size of the bottleneck), hit rate, average/max positions, exposure, Profit Factor, averages, best/worst trade, losing streak and average duration.

Below, the 📋 Trade detail: every executed trade —with no limit, it does not matter if there are 30,000— with the entry and exit in full (date, price and $ value on each side), shares, days, P&L and equity. Click to select (orange), ↑↓ / PgDn / Home-End to navigate and a ticker search box.

🔬

IS / OOS validation — does the edge persist?

The rolling selection is honest already, but there is a subtle overfit: you choose the criterion, the window and the number of positions while looking at the whole period. The IS/OOS validation exposes it: you define two stretches by exact dates (IS 2010-2020, OOS 2021-2023, say) and each is simulated with fresh capital and against its own random band.

✅ ROBUST

The OOS CAGR keeps ≥50% of the IS one and still beats its own stretch's chance (percentile ≥90). The edge travels through time.

⚠️ DOUBTFUL

It survives but degraded. Ask for more evidence: another OOS stretch, another universe.

⛔ FRAGILE

The OOS does not hold the edge up: the configuration is probably fitted to the past.

The OOS stretch appears shaded in amber over the equity curve. Trades entered within a stretch close on their real date even if it falls outside.

⚠️ Realism: suspicious series, astronomical nets, slippage and liquidity

If the result comes out in the billions, you have not discovered the money machine: some broken series (a recycled ticker, a fat-finger print, an extreme reverse split) is compounding unreal P&L. The Exclude ⚠️ check (on by default) sets aside the series flagged as suspicious, and the Max position value caps the compounding — even so, faced with an unbelievable number, the first hypothesis is always the data, not the edge.

Two costs that separate a backtest from reality: Slippage (the % of the amount lost on each side to friction with the spread — with hundreds of thousands of trades lasting a few days it is the dominant cost; 0.1% per side is a reasonable minimum) and Minimum liquidity ($ traded per day, a 20-session average at the entry: a $100,000 position in a microcap that trades $50,000/day does not get filled — the filter drops those impossible signals and tells you how many there were).

🧪

Portfolio Optimizer

The 🧪 Optimizer button opens the money management lab: it sweeps thousands of combinations of leverage, sizing method, position limits and signal selection over your strategy — with IS/OOS validation, an anti-overfitting map and illustrated reports. It has its own section with all the detail.

💡
How to read it (in this order)

1) Occupancy: was capital the bottleneck? 2) Random band: is your result merit or luck? 3) Comparison: which tie-break genuinely adds something? 4) Heatmap: is it consistent across decades? 5) Top tickers: does it hang on 2 names? Do not chase the biggest Net — look for a high percentile, a narrow band and a consistent heatmap. That is the backtest you can trust.

Try it yourself

AniQuant can be tried free for 30 days, with every module and no card.

← Previous
Stocks: a survivorship-free universe
Next →
Portfolio optimizer
More in US stocks