Navigation: Backtest Engine Details >

Asset Allocation and Position Sizing





The initial AccountSize can be defined in the Settings section of your script or via the Settings Panel.

This value becomes the S.StartEquity value and the initial value of S.Equity for each strategy and of the combined system.

On each subsequent date of the backtest, as trades are entered and exited, all of the statistics series including S.Equity are updated.

The daily S.Equity (equity curve) value for a strategy will be the prior day's value plus the net change in value due to closed trade gains or losses plus (optionally) open position mark-to-market value changes. The combined system equity value is calculated the same way by using all positions from all strategies.

By default, S.Equity includes open position mark-to-market value, making it the Net Liquidation Value (NLV) of the account. To model a cash account, in which open position gains can not be reinvested until the position has been closed, use the strategy-level MarkToMarket setting. The default is MarkToMarket: True. For any strategy that specifies MarkToMarket: False, S.Equity will only change when positions are exited. If no strategy marks to market, then the combined system doesn't either.

Each Strategy definition will usually include a Quantity formula, and can optionally include an Allocation formula.

Quantity is evaluated at entry time for every new position, and Allocation is evaluated at the start of every date of a backtest.

If Allocation is not specified, the default is always the combined system S.Equity value.

In formula terms, this is expressed as Allocation: Combined(S.Equity). If that is your desired allocation, you can simply omit it.

Other Allocation possibilities include:

Allocation: S.Equity // don't compound strategy gains together, keep them separate, as if each had its own account

Allocation: S.StartEquity // model an account where all gains are immediately withdrawn and all losses immediately replaced

The current value of the Allocation formula is accessible via the S.Alloc syntax. Whether or not you define a custom allocation formula, it is advisable to use S.Alloc as your reference to current account value when specifying Quantity (position size).

If Quantity is not specified, the default position size will be S.Alloc, i.e., the entire current allocation.

By default, the Quantity formula specifies the number of shares (or contracts for futures) to buy or sell short when entering a new position. The formula can optionally be redefined as either the dollar value of the position or a percent of allocation, by adding QtyType to the strategy.

A very common Quantity formula, as seen in many of the example scripts, is:

In this example, positions is a parameter that defaults to 5. Position size is therefore 20%.

The equivalent to the above using the two other quantity types would be:






Copyright © 2020-2022 Systematic Solutions, LLC