Search Framework:
SavedOptimizationResults
Namespace: WealthLab.Backtest
Parent: Object

Contains the information saved from an optimization run.

Constructors
SavedOptimizationResults
public SavedOptimizationResults()
public SavedOptimizationResults(Strategy s, OptimizerBase opt)
public SavedOptimizationResults(Strategy s, OptimizerBase opt, WFOOptimizer wfo) : this(s, opt)

Use the appropriate constructor to instantiate an instance based on a standard or a WFO optimization.



Persistence
Parse
public static SavedOptimizationResults Parse(string s)

Returns a new instance from an encoded string that was the result of calling an instance's Persist method.

Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using WealthLab.Data;
using WealthLab.Indicators;
using System.Collections.Generic;
using System.IO;

namespace WealthScript1 
{
    public class MyStrategy : UserStrategyBase
    {
        public override void Initialize(BarHistory bars)
        {
			//load a saved optimization results file
			string dir = Path.Join(WLHost.Instance.DataFolder, "SavedOptimizations");
			string[] files = Directory.GetFiles(dir, "*.WL8Opt");
			if (files.Length > 0)
			{
				string fileName = files[0];
				string s = File.ReadAllText(fileName);
				SavedOptimizationResults sor = SavedOptimizationResults.Parse(s);
				WriteToDebugLog("Saved Optimization File has " + sor.Results.Count + " results.");
			}
        }

        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

Persist
public string Persist()

Returns a string that contains the instance's information in an encoded format that can be reconstituted by calling Parse.



Properties
BacktestSettings
public BacktestSettings BacktestSettings

Returns the backtest settings used during the optimization's backtest runs.


BenchmarkSymbol
public string BenchmarkSymbol

The benchmark symbol that was used during the optimization's backtest runs.


DataRange
public DataRange DataRange

Returns the data range used during the optimization's backtest runs.


DataSetName
public string DataSetName

If SingleSymbol is false, indicates the name of the DataSet that was used for the backtests.


IsComplete
public bool IsComplete

Indicates whether the saved run was a completed, as opposed to a paused, optimization.


Optimizer
public OptimizerBase Optimizer

The OptimizerBase derived instance, indicates which optimization method was used.


OptimizerParameters
public ParameterList OptimizerParameters

The parameters that were used for the Optimizer instance.


PositionSize
public PositionSize PositionSize

The position sizing that was used during the optimization's backtest runs.


Results
public OptimizationResultList Results

If RunType was Standard or WFO, returns an OptimizationResultList instance that contains the optimization results.


RunType
public OptimizationRunType RunType

Indicates the type of optimization results, Standard, WFO, or SymbolBySymbol.


Scale
public HistoryScale Scale

Returns the data scale used during the optimization's backtest runs.


SingleSymbol
public bool SingleSymbol

Indicates whether single symbol or DataSet (portfolio) backtests were used during the optimization.


Strategy
public Strategy Strategy

The Strategy instance that was optimized.


StrategyParameters
public ParameterList StrategyParameters

The Strategy parameters as they existed at the time the optimization run was saved. The Parameter instances will have their IsChecked property set to values that represent which parameter check boxes were enabled during the optimization.


Symbol
public string Symbol

If SingleSymbol was true, indicates which symbol was used for the backtests.


SymBySym
public Dictionary<string, OptimizationResultList> SymBySym

If the RunType was SymbolBySymbol, contains each symbol's OptimizationResultList results in a Dictionary keyed by symbol.


WFOOptimizer
public WFOOptimizer WFOOptimizer

The WFOOptimizer instance used if the optimization was WFO.