DocsBacktestsPosition sizing and capital
BacktestsReference

Position sizing and capital

Starting capital seeds a cash ledger. At every entry, one of five sizing modes resolves an integer lot count for the position, off either a capital (premium) basis or a margin basis. This page covers the sizing modes and their parameters, the premium-vs-margin distinction that decides how a spread is measured, the position limits, and how commissions enter a result.

Updated Jul 20265 min read

Starting capital

Starting capital is the cash the run begins with. It must be greater than 0. There is no default; every run supplies it.

It seeds the cash ledger, and net liquidation value (NLV) is derived from the ledger balance plus the current marks of any open positions. NLV is the figure the percent-of-NLV sizing modes read at each entry, so starting capital sets the ceiling on how large the first position can be.

In the DSL this is the starting_capital field on the run config; in the Capital settings form it is the starting capital field.

The five sizing modes

Every run supplies a sizing mode and a value. There is no default mode. The mode decides what value means and which basis the lot count divides by; value must be greater than 0. Every mode floors to a whole-lot count.

Mode
What value means
Lots resolved at entry
capital_pct_nlv
Fraction of NLV
floor( NLV × value / |per-lot capital| )
capital_dollars
Explicit dollar amount
floor( value / |per-lot capital| )
margin_pct_nlv
Fraction of NLV
floor( NLV × value / per-lot margin )
margin_dollars
Explicit dollar amount
floor( value / per-lot margin )
fixed_lots
Whole integer lot count
value (validated as a whole number)

The two capital_* modes size off the position's per-lot capital (the net cash on open). The two margin_* modes size off the position's per-lot margin requirement. fixed_lots ignores both bases and holds the lot count constant; a non-integer value is rejected before the run starts.

The next section covers how per-lot capital and per-lot margin differ, which is what separates a premium-collecting position from a premium-paying one.

Premium basis vs margin basis

This is the distinction that decides how a position is measured, and it is the reason a credit spread and a debit spread of the same width can size to different lot counts.

The capital_* modes divide by per-lot capital: the signed net cash the position exchanges on open, computed from the entry marks across every leg.

  • Per-lot capital is positive for a credit received (a credit spread, a naked short).
  • Per-lot capital is negative for a debit paid (a debit spread, a long option).

The capital modes divide by its absolute value, so a position sizes by the magnitude of the cash it exchanges, whether that cash is collected or spent. A $2.00 credit and a $2.00 debit size identically under a capital_* mode.

The margin_* modes divide by per-lot margin: the post-buffer margin requirement for one lot, taken from a single decomposition call at one lot. Because that call runs the full multi-leg decomposition, a spread sizes by its netted requirement, not by the sum of its legs. A defined-risk spread therefore sizes far larger under a margin_* mode than its per-leg margin would suggest. See margin and auto-decomposition for how the requirement is decomposed.

Use a capital_* mode when you want to cap the premium or debit committed per trade. Use a margin_* mode when you want to cap the buying power the position ties up.

Per-lot capital and per-lot margin are both computed from the position's mid marks at the entry timestamp. Commissions do not enter either figure; sizing divides by marks alone (see Commissions and fees).

When sizing returns zero

Sizing resolves to 0 lots when any of these hold:

  • NLV is less than or equal to 0 (for the modes that read NLV).
  • The relevant divisor is zero (per-lot capital or per-lot margin is 0).
  • The floored lot count is below 1.

A 0-lot result makes the entry a sizing_zero no-action. Nothing opens, and the run continues to the next opportunity.

A separate check runs after sizing. A position that sizes to one or more lots but would breach the pre-trade margin gate (the account's NLV cannot cover the new position's initial requirement on top of the maintenance requirement of every open position) is a margin_insufficient no-action.

Note

margin_insufficient here is an entry-rejection reason, not a close reason. It rejects an opening that cannot be afforded; it never forces an existing position out. Both no-action reasons surface in backtest results.

Position limits

Two limits cap how many positions can be open and how fast they open.

max_concurrent_positions is the number of positions that may be open at once.

  • Values: integer, must be at least 1.
  • Default: 1.
  • Effect: raising it lets the engine hold several positions simultaneously, which increases margin used and the capital committed across concurrent trades. At the default of 1, the engine opens a new position only after the current one closes.

max_positions_per_day is the number of new positions the engine may open in a single session.

  • Values: integer, or unlimited.
  • Default: unlimited (no per-day cap).
  • Effect: setting it caps how many entries fire in one session even when the entry condition qualifies repeatedly; the remaining qualifying entries become no-actions for that day.

Two other caps apply to an entry beyond the sizing value and these two limits: the maximum position size cap on the Capital settings form, which ceilings the size of any single position, and the capacity lot clamp, which caps an order against available liquidity (see fills, marks and slippage).

Commissions and fees

Every backtest charges a fixed per-contract commission in dollars. The charge is configurable and can be set to zero for a gross result; the full statement lives on fills, marks and slippage. Commissions are a cost booked on fills, not a sizing input: the lot-count math above divides by marks alone. On a high-frequency or high-leg-count strategy, per-contract commissions can dominate the edge, so compare the zero-commission and commissioned runs before trusting a thin margin.

The Capital settings form

Capital settings is the panel on the Backtest tab that gathers everything on this page into one form. The form carries five inputs.

Capital settings field
What it sets
Engine equivalent
starting capital
The cash the run begins with.
starting_capital.
position size
The size per trade, as a fraction of account equity, either a fixed number or a formula referencing the model's prediction.
The sizing mode and value (the fraction-of-NLV modes, or a model-driven size).
maximum position size cap
A ceiling on the size of any single position.
Applied at sizing time, on top of the sizing value.
commissions
The per-contract commission in dollars to charge.
The per-contract commission; see fills, marks and slippage.
position size basis
Whether size is measured against premium or against the broker-required margin. For trades collecting premium rather than spending it, size is calculated against the margin the broker requires, not the premium collected.
The choice between the capital_* modes (premium basis) and the margin_* modes (margin basis).

The position size basis field is the form-level expression of the premium-vs-margin distinction: picking the margin basis routes sizing through a margin_* mode, so a premium-collecting spread sizes against its netted margin requirement rather than the credit it took in.

Was this page helpful?