BacktestSettings
public BacktestSettings BacktestSettingsReturns the BacktestSettings used for the optimization.
API documentation, members, signatures, and C# examples.
Find classes, members, and documentation.
The WFOOptimizer class performs Walk-Forward Optimization (WFO). A WFO divides the available historical data into a sequence of in-sample and out-of-sample intervals. For each interval, WealthLab optimizes the Strategy using the in-sample period, selects the best parameter set using a WFOResultSelectorBase, and then applies those parameters to the corresponding out-of-sample period. WFOOptimizer collects the resulting WFOResult instances for use by Walk-Forward Optimization Visualizers and other extension code. WFOOptimizer implements IOptimizerHost because each in-sample interval is executed internally by a StrategyOptimizer.
public BacktestSettings BacktestSettingsReturns the BacktestSettings used for the optimization.
public StrategyBase CompiledStrategyReturns the compiled StrategyBase instance being optimized.
public OptimizerBase OptimizationMethodReturns the Optimizer selected for the optimization.
public IOptimizerHost OptimizerHostReturns the IOptimizerHost that hosts the WFO optimization.
public PositionSize PositionSizeReturns the PositionSize used during the optimization.
public void ReportEstimatedCompletion(double value)Allows the optimization process to report an estimated completion percentage. The value parameter is expressed from 0 to 100.
public ScoreCardBase ScoreCardReturns the ScoreCard selected for the optimization.
public List<BarHistory> SymbolDataContains the historical BarHistory instances being optimized.
public static List<WFOResult> CreateResultList( List<DateTime> lst, int intervals, double oosPercent, WFOWindowType wt, IOptimizerHost host, bool preLive)Creates a list of WFOResult instances containing the date ranges for a Walk-Forward Optimization. The returned objects define the in-sample and out-of-sample periods but do not yet contain optimization performance results. lst supplies the DateTimes spanning the data being optimized. intervals specifies the number of walk-forward intervals. oosPercent specifies the percentage of each window allocated to out-of-sample testing. wt specifies whether the WFO uses Sliding or Expanding windows. If preLive is true, an additional Pre-Live interval is added after the final standard WFO interval. For an Expanding WFO, all in-sample intervals use the same initial start date while their end dates advance through time.
public DataSet DataSetGets or sets the DataSet associated with the Walk-Forward Optimization. WealthLab uses this when loading benchmark and optimization data for individual WFO intervals.
public string DataSetNameContains the name of the DataSet associated with persisted WFO results. This property is populated when a saved WFOOptimizer is restored using Parse.
public WFOParametersList GenerateResultList()Creates a WFOParametersList from the completed WFO results. The returned list contains the parameter values selected for each out-of-sample interval. For each applicable WFOResult, WealthLab stores:
public double InSamplePercentReturns the percentage of each WFO window allocated to in-sample optimization. It is calculated as:
100.0 - OutOfSamplePercent
public int IntervalsGets or sets the number of intervals in the Walk-Forward Optimization. Each normal interval consists of an in-sample optimization period followed by an out-of-sample test period.
public bool IsCancelledGets or sets whether the Walk-Forward Optimization has been canceled. The optimization checks this property between interval runs and stops processing when it becomes true. The default value is false.
public string ModeGets or sets the Selector mode used to choose the best OptimizationResult for each in-sample interval. The exact meaning of Mode depends on the selected Selector. For example, a Selector based on ScoreCard metrics can use Mode to identify which metric should be maximized or minimized when selecting the best optimization result.
public double OutOfSamplePercentGets or sets the percentage of each WFO window allocated to out-of-sample testing. InSamplePercent is automatically calculated from this value.
public override void PerformOptimization( IOptimizerHost host, PositionSize posSize, BacktestSettings bts, bool resuming)Executes the Walk-Forward Optimization. For each interval, WFOOptimizer:
public bool PreLiveRunGets or sets whether WealthLab should perform an additional Pre-Live optimization after the normal WFO intervals.
The default value is false.
A Pre-Live run performs another in-sample optimization using the most recent available historical data but does not have a normal historical out-of-sample period.
Its resulting parameter values can be used as the parameters intended for current or subsequent live execution.
When a Pre-Live result is created, its out-of-sample range is represented using DateTime.MinValue and DateTime.MaxValue.
public WFOResultSelectorBase SelectorGets or sets the WFOResultSelectorBase used to choose the best OptimizationResult from each in-sample optimization. The Selector works in conjunction with Mode to determine which result should be carried forward into the corresponding out-of-sample run.
public List<WFOResult> WFOResultsContains the WFOResult instances generated during the Walk-Forward Optimization. The collection contains both in-sample and out-of-sample results. After the optimization completes, results are sorted by interval number, with the in-sample result preceding the corresponding out-of-sample result. If Pre-Live processing is enabled, its result is also included.
public WFOWindowType WindowTypeGets or sets the type of Walk-Forward Optimization window. Possible values include:
WFOWindowType.Sliding
WFOWindowType.Expanding
With a Sliding window, both the beginning and end of the in-sample period move forward for each interval. With an Expanding window, the in-sample start date remains fixed while the end date advances with each interval.
public Backtester BenchmarkBacktesterReturns the benchmark Backtester for the WFO interval currently being processed. The internal StrategyOptimizer uses this benchmark when calculating optimization results for the current window.
public List<string> MetricNamesReturns the metric names exposed by the parent OptimizerHost.
public new ParameterList OptimizableParametersReturns the Strategy's optimizable parameters from the parent OptimizerHost.
public void ReportProgress(double pctCompleted)Forwards optimization progress from the StrategyOptimizer running the current WFO interval to the parent OptimizerHost.
public void Parse(string s)Restores the WFOOptimizer state from a string previously created by Persist. The restored information includes:
public string Persist()Serializes the current WFOOptimizer state to a string. In addition to the WFO configuration and completed WFOResults, the serialized data includes enough state to support resuming an interrupted optimization.
Ask the community or explore custom development services.