Home › Documentation › Portfolio, capital & risk
Money management

📐 Position Size

While the Sizing Lab helps you choose the method, this makes it REAL: position size becomes part of the strategy and genuinely changes the equity of the backtest, the Portfolio and the basket — and it travels to the exports. It is the second of AniQuant's three engines: Edge → Position Size → Portfolio.

A design principle: generation and ranking stay at a fixed size (they measure the pure edge, without leverage distorting the search). Sizing is applied afterwards: to the performance you see, to the Portfolio and basket, and to the exported code.

The methods (with their layer of limits)

Fixed size

A constant N contracts/shares.

Fixed amount

Invest a $ amount per position.

% of Capital

Exposure = X% of the balance. Ideal on stocks/ETFs; on futures the notional distorts it.

% Risk (with a stop)

Risks X% of the account using the real stop. The most useful one for systematic trading.

Fixed $ risk

Risks a fixed $ amount per trade (÷ the risk per contract).

1 contract per $X

Scales with the balance (contracts-per-equity).

% Volatility (ATR)

Sizes by each entry's volatility: smaller size when the market gets choppy.

The layer of limits

On top of any method: min/max contracts, max exposure %, max risk per trade, whole units. The formula may ask for 37; you say "never more than 8".

⚠️ % OF CAPITAL ≠ % RISK: the first is notional exposure (how much you buy); the second is how much you lose if the stop fires. They are different concepts and the interface keeps them apart on purpose.
🔬

In the performance

In View Performance, the Position Size tab applies the plan and the equity, the drawdown, the Monte Carlo and the metrics all become sized.

⚖️

It travels with the strategy

The plan is saved with the strategy (right click → Position Size in the Portfolio). The Portfolio and the basket use each one's real equity. A ⚖ in the table marks the ones carrying a plan.

🔤

In the AQ language

AQL describes it with the positionsize: directive — for example positionsize: risk 1% — with a full round trip (see AQ Language).

📤

And in all five exports

The exported code sizes the position just as AniQuant does, each in its own native idiom (not always 1 contract):

EasyLanguage (TradeStation)

AQ_* inputs + the AQ_Contr calculation using BigPointValue/NetProfit → Buy AQ_Contr contracts.

MQL5 (MetaTrader 5)

An AQ_CalcVol() function using the account equity and the tick value, normalized to the symbol's lot.

ProRealTime (ProOrder)

ONCE AQ_* parameters + a per-bar block → BUY AQ_Contr CONTRACT.

AmiBroker (AFL)

SetPositionSize in its native mode: spsShares / spsValue / spsPercentOfEquity depending on the method.

Pine Script (TradingView)

Native default_qty_type: strategy.fixed / strategy.cash / strategy.percent_of_equity. The methods that depend on equity trade by trade (per each X, ATR, Fixed Ratio, target volatility) have no equivalent and come out as 1 contract, with a warning in the code.

An honest note: the exported code runs on outside platforms. Every sizing block carries "verify this on your platform" warnings where the idiom has subtleties (equity, point value, ATR). You have the final word when you paste it.
🎯

Position Size Optimizer — by brute force

Knowing the sizing methods is one thing; choosing the best one for YOUR strategy is quite another. The Optimizer does it for you: it takes a strategy's real trades (or the whole portfolio's) and tries dozens of sizing configurations the hard way — every method with its parameters (Risk 0.25%…3%, % of Capital, 1-per-X, ATR, Fixed Ratio, full/half/quarter Kelly, Target Vol…). It does not keep the one that makes the most, but the one that best combines growing and surviving.

You get in through the 💰 Capital & Risk → Position Size Optimizer menu.
1️⃣

One strategy

It re-tests the chosen strategy and sweeps the entire sizing catalog over its trades. You get a ranking and a recommendation.

🧪

Portfolio (all of them)

It optimizes the sizing of every active strategy in the portfolio and shows you the combined effect (normalized vs optimized equity, % improvement). With an "Apply all" button.

⚖️

How it picks the winner: growing and surviving

  • ·MAR = annual return ÷ maximum drawdown. It measures how much growth you get for each unit of pain. The higher the better.
  • ·Risk of ruin = with a Monte Carlo (shuffling the trade order many times) we measure how often the capital would fall to 50%. That is the survival test.
  • ·Ruin ≤ (you set it, 5% say) = the maximum probability of ruin you accept. The recommendation is the best MAR whose ruin stays below your threshold. If nothing survives, it tells you: lower the risk or revisit the strategy.
📈

Equity · cumulative P&L

The capital curve at 1 contract (gray) against the sizing applied (green). You see at a glance what money management adds.

🌱

Growing vs surviving

CAGR (growing) against the probability of ruin (surviving). The green zone to the left of your threshold is where it holds; the best spot is top-left.

🗺️

Risk · return map

Each point is one sizing configuration (CAGR vs maximum drawdown), colored by method. The recommended one carries a white ring.

📊

MAR ranking

Bars with the best configurations by MAR, colored by method. Click a bar to select that configuration.

🎲

Monte Carlo · final capital

A histogram of the distribution of final capital across the simulations: red = wiped out, orange = below the starting point, green = above. With lines for the starting capital and the ruin level.

Grid and charts side by side: the table lives on the left (fixed, with its own scroll and every column — including Net 1c / Net opt. / Net ×) and the charts on the right. You select a row by clicking, with the ↑/↓ arrow keys or by clicking a ranking bar — it is highlighted in orange and the charts (equity, histogram, points) jump to that configuration. The columns sort by clicking their header, and each one carries its explanation on hover.
⚡

Engine: GPU or CPU (Auto)

The Monte Carlo is the heavy part (dozens of configurations × hundreds of simulations × every trade). It can run on the GPU (graphics card), which speeds it up enormously. The Engine selector offers Auto (GPU if available, otherwise CPU), GPU or CPU. The results are identical on both engines — the GPU is simply faster. When it finishes, the status tells you which engine was used.

🧪

In Portfolio mode

The same two-column layout: on the left the table with each strategy's best sizing (MAR, CAGR, Max DD, Ruin, and Net 1c / Net opt. / Net ×), sortable by any header, with the selection in orange and ↑/↓ keyboard navigation. On the right, the charts:

  • ·Combined equity — the whole portfolio's curve, 1 contract (gray) vs optimized sizing (green), with the before/after summary and the % improvement.
  • ·The selected strategy's equity — pick a row (click or keyboard) and you see its individual curve.
  • ·Improvement per strategy — bars of the Net × (how much the sizing multiplies each one's profit); their height adapts to the number of strategies and clicking a bar selects that strategy.

Each strategy is optimized on its own capital (there is no capital shared between them — that is a separate portfolio engine).

Applying: with "Apply to the strategy" (or "Apply all" in portfolio mode) the winning plan is saved with the strategy and travels to the Portfolio, the basket and the exports, exactly as if you had set it by hand.
💡
The idea behind it

Sizing does not change which signals have an edge — the search measures that at a fixed size. It changes how much you risk, which is what decides whether you survive. That is why we keep the two apart: first you find the edge, then you choose the size you would hold on to without bailing out.

Try it yourself

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

← Previous
Capital & risk
Next →
Confidence-based allocation
More in Portfolio, capital & risk