API documentation, members, signatures, and C# examples.
Search the framework
Find classes, members, and documentation.
NamespaceWealthLab.Backtest
Parent
Object
Represents the position sizing settings established for a backtest. PositionSize defines the sizing method and amount, starting capital, margin factor, maximum open positions, maximum entry signals per bar, and optional advanced PositionSizer. It also contains the settings used when optimizing position sizing parameters.
Determines how the basis price used for position sizing is established.
When false, which is the default, the basis price is based on the closing price of the signal bar. If the market gaps on the following bar, the actual cost of the trade can exceed the amount available and potentially cause the simulated trade to receive NSF status.
When true, the basis price is based on the open price of the following bar. This can avoid NSF results caused by opening gaps, but assumes that the execution environment can accommodate the resulting position size.
The parameterless constructor creates a PositionSize configured to use 5% of equity, $100,000 starting capital, and a margin factor of 1.0.
The second constructor creates a PositionSize using the specified pst sizing method and amt amount. StartingCapital defaults to $100,000 and MarginFactor to 1.0.
Returns true if obj is a PositionSize whose primary backtest sizing settings are equal to this instance.
The comparison includes StartingCapital, PositionSizeType, Amount, MarginFactor, UseNextBarOpenAsBasisPrice, and MaxOpenPositions.
Returns true if the two PositionSize instances have equal primary sizing settings.
The comparison includes StartingCapital, PositionSizeType, Amount, MarginFactor, UseNextBarOpenAsBasisPrice, and MaxOpenPositions.
The operator also handles null PositionSize references.
Applies the optimization settings represented by Parameterp to one of the built-in PositionSize parameters.
The tag identifies the PositionSize parameter:
0 - StartingCapital
1 - Amount
2 - MarginFactor
3 - MaxOpenPositions
When assignValue is true, the Parameter's current value is also assigned to the corresponding PositionSize property.
Applies optimized values from the specified ParameterList to this PositionSize.
Built-in PositionSize parameters are identified by their PositionSize optimization tags. When an advanced PositionSizer is being used, matching optimized PositionSizer Parameters are also updated.
Gets or sets the optimization range used for Amount when PositionSizeType is PositionSizeType.Dollar.
The default range is 1,000 through 10,000 in steps of 1,000.
Gets or sets the optimization range used for Amount when PositionSizeType is PositionSizeType.Quantity.
The default range is 100 through 1,000 in steps of 100.
Returns a ParameterList containing the PositionSize parameters currently enabled for optimization.
If PositionSizeType is PositionSizeType.PosSizer, optimizable Parameters belonging to the advanced PositionSizer are also included.
Returns true if any PositionSize parameter is enabled for optimization.
This includes StartingCapOpt, AmountOpt, MarginOpt, MaxOpenPosOpt, or an optimizable Parameter belonging to an advanced PositionSizer.
Gets or sets the optimization range used for Amount when PositionSizeType is PositionSizeType.MaxRiskPct.
The default range is 5% through 50% in steps of 5%.
Gets or sets the optimization range used for Amount when PositionSizeType is PositionSizeType.PctOfEquity.
The default range is 1% through 20% in steps of 1%.
Returns a new PositionSize containing a copy of the current settings.
When using an advanced PositionSizer, the PositionSizer and its Parameters are also cloned.
Optimization settings and their Steppable ranges are copied to the new instance.
Creates and returns a PositionSize by parsing the persisted representation specified in s.
The method also supports legacy PositionSize persistence formats.
If a persisted advanced PositionSizer cannot be created, PositionSizeType is changed to PositionSizeType.Dollar.
Returns a string containing a serialized representation of the PositionSize settings.
The persisted data includes the sizing type and amount, starting capital, margin factor, advanced PositionSizer information when applicable, maximum open Positions, basis-price setting, optimization settings, maximum Signals per bar, and optimization ranges.