Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

SavedOptimizationResults

API documentation, members, signatures, and C# examples.

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.Backtest
Parent
Object

Contains the information saved from a WealthLab optimization run, including the Strategy, Optimizer, position sizing, backtest settings, optimization parameters, and generated results. SavedOptimizationResults supports standard, Walk-Forward Optimization (WFO), and Symbol-by-Symbol optimization runs.

Constructors

1

SavedOptimizationResults

public SavedOptimizationResults()
public SavedOptimizationResults(
Strategy s,
OptimizerBase opt)
public SavedOptimizationResults(
Strategy s,
OptimizerBase opt,
WFOOptimizer wfo)

The parameterless constructor creates an empty SavedOptimizationResults instance. The second constructor initializes the instance from Strategy s and Optimizer opt. It captures the Strategy's optimized parameters, PositionSize, benchmark, symbol or DataSet settings, scale, data range, and BacktestSettings, along with the Optimizer and its Parameters. The third constructor additionally assigns the specified WFOOptimizer and sets RunType to OptimizationRunType.WFO.

Persistence

2

Parse

public static SavedOptimizationResults Parse(string s)

Creates and returns a SavedOptimizationResults instance from a string previously generated by Persist. Parse restores the Strategy and Optimizer by their saved names using StrategyFactory and OptimizerFactory, restores their Parameters and settings, and reconstructs the PositionSize, HistoryScale, DataRange, and BacktestSettings. For WFO results, the method also recreates and parses the WFOOptimizer. For Symbol-by-Symbol results, it recreates the SymBySym Dictionary and its OptimizationResultList values. Parse also applies several restored settings back to the Strategy instance, including PositionSize, Benchmark, SingleSymbol mode, Symbol, DataSetName, Scale, and DataRange. An ArgumentException is thrown if the saved Strategy or Optimizer cannot be found.

Persist

public string Persist()

Returns an encoded string containing the SavedOptimizationResults configuration and results. The persisted information includes:

  • RunType
  • Results
  • IsComplete
  • Strategy qualified name
  • Strategy Parameters
  • Optimizer name, Parameters, and internal state
  • PositionSize
  • BenchmarkSymbol
  • SingleSymbol mode
  • Symbol
  • DataSetName
  • HistoryScale
  • DataRange
  • BacktestSettings For WFO runs, the WFOOptimizer state is also persisted. For Symbol-by-Symbol runs, the symbol keys and corresponding OptimizationResultList values in SymBySym are also persisted. The returned string can later be passed to Parse to recreate the SavedOptimizationResults instance.

Properties

17

BenchmarkSymbol

public string BenchmarkSymbol

Gets or sets the benchmark symbol used during the optimization's backtest runs.

DataRange

public DataRange DataRange

Gets or sets the DataRange used during the optimization's backtest runs.

DataSetName

public string DataSetName

Gets or sets the name of the DataSet used during the optimization. This property is relevant when SingleSymbol is false.

IsComplete

public bool IsComplete

Indicates whether the saved optimization run completed normally. A false value can indicate that the saved run represents an incomplete or paused optimization.

Optimizer

public OptimizerBase Optimizer

Gets or sets the OptimizerBase-derived instance that performed the optimization.

OptimizerParameters

public ParameterList OptimizerParameters

Gets or sets the Parameters associated with Optimizer. When a SavedOptimizationResults instance is parsed, this property references the Optimizer's restored ParameterList.

PositionSize

public PositionSize PositionSize

Gets or sets the PositionSize configuration used for the optimization's backtest runs.

Results

public OptimizationResultList Results

Gets or sets the OptimizationResultList containing the optimization results. For standard and WFO optimization runs, this property contains the primary set of results. A new SavedOptimizationResults instance initializes Results to an empty OptimizationResultList.

RunType

public OptimizationRunType RunType

Gets or sets the type of optimization represented by this instance. Possible values include:

  • OptimizationRunType.Standard
  • OptimizationRunType.WFO
  • OptimizationRunType.SymbolBySymbol The default is OptimizationRunType.Standard.

Scale

public HistoryScale Scale

Gets or sets the HistoryScale used during the optimization's backtest runs.

SingleSymbol

public bool SingleSymbol

Indicates whether the optimization used single-symbol backtests rather than DataSet portfolio backtests.

Strategy

public Strategy Strategy

Gets or sets the Strategy that was optimized.

StrategyParameters

public ParameterList StrategyParameters

Gets or sets the Strategy Parameters captured when the optimization results were saved. These Parameters preserve the optimization state used for the run, including which Parameters were enabled for optimization.

Symbol

public string Symbol

Gets or sets the symbol used for the optimization when SingleSymbol is true.

SymBySym

public Dictionary<string, OptimizationResultList> SymBySym

Gets or sets the Symbol-by-Symbol optimization results. The Dictionary key is the symbol and the corresponding value is that symbol's OptimizationResultList. This property is used when RunType is OptimizationRunType.SymbolBySymbol. A new SavedOptimizationResults instance initializes SymBySym to an empty Dictionary.

WFOOptimizer

public WFOOptimizer WFOOptimizer

Gets or sets the WFOOptimizer associated with the saved results. This property is used when RunType is OptimizationRunType.WFO. The default value is null.

Need help with this API?

Ask the community or explore custom development services.