RealTest provides several Strategy Element formulas to allow you to define the capacity constraints of a strategy or group of strategies in various ways.
These include:
•MaxEntries  maximum position entries per day (potential selection bias, not topdown)
MaxExposure  maximum percent exposure
MaxInvested  maximum dollars invested
MaxOrders  maximum position entry orders to place per day
MaxPositions  maximum open position count
MaxSameCat  maximum positions in the same category
MaxSameSym  maximum positions in the same security (symbol)
MaxSetups  maximum entry setups per day (processed before other constraints, not topdown)
By default, all of the above constraints are infinite. Therefore if you want any constraints in your strategy or set of strategies, you must provide one or more of the above formulas.
In the new TopDown Mode, most of the above formulas may be included in the definition of a Strategy, a StatsGroup, or the Combined system. In this mode, all constraints are applied during the Setup Selection phase of daily entry processing, such that the set of orders to generate each day would violate none of the constraints.
In the older Legacy Mode, capacity constraints can only be applied to a Strategy and are applied during Entry Simulation, modeling an order management system that handles all such constraints. With capacity constraints only applied at the Strategy level, each strategy must specify from the bottom up how to play its part in modeling your desired higherlevel allocation capacities.
See BackTest Engine Details for more information about how each of these modes works and why this distinction is so important.
To apply topdown constraints to all strategies in a script, simply add a Combined section and define the constraint formulas within that section.
To apply constraints to a specific group of strategies (e.g. all longside ones), define a StatsGroup consisting of those strategies and provide the constraint formulas within it.
In the daily topdown setup selection process, a setup only becomes an order if it does not violate any constraints of its Strategy, StatsGroup(s) or Combined.
The key to how this selection process works is that first all setups are determined for all strategies and ranked by each strategy's SetupScore formula. Then an outer loop by rank number selects one setup at a time from each strategy and checks to see if it can still become an order given the others that have already been selected.
If you only provide Combined capacity formulas, each strategy will keep the maximum possible number of setups that would (after selecting them in turn) not violate any combined capacities.
Within that structure, you might also want to provide strategyspecific capacities to further control strategylevel exposures.
Rather than always depending on the order of strategies in a script to determine which one "goes first" in this selection loop, a StrategyScore formula can optionally be provided. When present this formula is evaluated at each rank number in the topdown loop and determines the sequence in which each strategies will get to confirm its next setup.
One analogy to this topdown mode of capacity constraint application is that it resembles the US football annual "draft". Your capacity formulas at each level along with your StrategyScore and SetupScore formulas provide the framework for deciding who gets the next pick at each stage.
To see all the details of how this works in action, run e.g. the goal_30_15_no_dupes.rts example script with KeepTrades: Skipped and TestOutput: Log checked.
