Search Framework:
WFOResult
Namespace: WealthLab.Backtest
Parent: OptimizationResult

The WFOResult class extends OptimizationResult with information specific to a single Walk-Forward Optimization interval. A WFOResult can represent either the in-sample optimization result or the corresponding out-of-sample result for an interval. It also stores the date ranges, WFO Efficiency, selected parameter values and performance metrics inherited from OptimizationResult, and optional details about the complete in-sample optimization. WFOResult is also used to represent the optional Pre-Live WFO run.

Members
AnnualizedReturn
public double AnnualizedReturn

Inherited from OptimizationResult. Contains the annualized return of the optimization result. WFOOptimizer uses the in-sample and out-of-sample AnnualizedReturn values when calculating WFOEfficiency.


AvgBars
public double AvgBars

Contains the average number of BarHistory bars available across the symbols used for this WFO result. This is useful for examining how much historical data was actually available within a particular WFO interval.


BaseOptimization
public StrategyOptimizer BaseOptimization

Contains the StrategyOptimizer that produced the in-sample optimization for this WFO interval. This gives callers access to the complete collection of OptimizationResult instances generated during the in-sample optimization. BaseOptimization is normally associated with an in-sample WFOResult. It can be null when no underlying optimization is available.


DateRange
public string DateRange

Returns the appropriate formatted date range for this result. For an in-sample result, this returns InSampleRange. For an out-of-sample result, this returns OutOfSampleRange.


EndDate
public DateTime EndDate

Returns the ending date appropriate for this result. For an in-sample result:

InSampleEndDate

For an out-of-sample result:

OutOfSampleEndDate

ErrorMessage
public string ErrorMessage

Inherited from OptimizationResult. Contains the Exception message associated with the optimization result if an error occurred. Returns null when no error was recorded.


InOutSample
public string InOutSample

Returns a descriptive string identifying the type of WFO result. Possible values are:

  • In-Sample
  • Out-of-Sample
  • Pre-Live Pre-Live takes precedence over the normal in-sample/out-of-sample distinction.

InSampleEndDate
public DateTime InSampleEndDate

The ending date of the in-sample portion of this WFO interval.


InSampleRange
public string InSampleRange

Returns the in-sample date range as a formatted string: InSampleStartDate to InSampleEndDate.


InSampleStartDate
public DateTime InSampleStartDate

The starting date of the in-sample portion of this WFO interval.


IntervalNumber
public int IntervalNumber

The interval number associated with this WFOResult. WFOOptimizer numbers normal intervals starting at 1. If Pre-Live processing is enabled, the Pre-Live result uses:

Intervals + 1

IsInSample
public bool IsInSample

Indicates whether this WFOResult represents an in-sample result. The default value is true. For normal WFO runs:

  • true indicates an in-sample optimization result.
  • false indicates the corresponding out-of-sample backtest result.

IsNormalRun
public bool IsNormalRun

Returns true if this result is not a Pre-Live result. Equivalent to: !IsPreLiveRun


IsPreLiveRun
public bool IsPreLiveRun

Returns true if this WFOResult represents the optional Pre-Live run. A Pre-Live result is identified by: OutOfSampleStartDate == DateTime.MinValue WFOOptimizer uses a special open-ended out-of-sample date range for Pre-Live results because there is no historical out-of-sample period following the final optimization.


MaxBars
public int MaxBars

Contains the maximum number of BarHistory bars available for any symbol used in this WFO result.


MetricNames
public List<string> MetricNames

Inherited from OptimizationResult. Returns the names of the performance metrics associated with the optimization result. These metrics are determined by the ScoreCard used during optimization.


MinBars
public int MinBars

Contains the minimum number of BarHistory bars available for any symbol used in this WFO result.


OutOfSampleEndDate
public DateTime OutOfSampleEndDate

The ending date of the out-of-sample portion of this WFO interval. For a Pre-Live result this is typically DateTime.MaxValue.


OutOfSampleRange
public string OutOfSampleRange

Returns the out-of-sample date range as a formatted string:

OutOfSampleStartDate to OutOfSampleEndDate

OutOfSampleStartDate
public DateTime OutOfSampleStartDate

The starting date of the out-of-sample portion of this WFO interval. For a Pre-Live result, this is DateTime.MinValue.


ParameterValues
public List<double> ParameterValues

Inherited from OptimizationResult. Contains the parameter values represented by this optimization result. For a completed WFO interval, these are the parameter values selected from the in-sample optimization and used for the corresponding out-of-sample test.


PerformanceMetrics
public Dictionary<string, double> PerformanceMetrics

Inherited from OptimizationResult. Contains the performance metric values calculated for this result. The available metrics are determined by the ScoreCard used during the optimization.


RunNumber
public int RunNumber

Inherited from OptimizationResult. Returns the run number associated with the optimization result.


SortDate
public DateTime SortDate

Returns the date used for chronological sorting. For an in-sample result, this returns: InSampleStartDate. For an out-of-sample result, it returns: OutOfSampleStartDate.


StartDate
public DateTime StartDate

Returns the starting date appropriate for this result. For an in-sample result: InSampleStartDate. For an out-of-sample result: OutOfSampleStartDate.


TimeSpan
public TimeSpan TimeSpan

Returns the complete time span represented by the WFO interval. For a normal WFO result, this is calculated as: OutOfSampleEndDate - InSampleStartDate. For a Pre-Live result, it is calculated as: InSampleEndDate - InSampleStartDate.


TimeSpanString
public string TimeSpanString

Returns TimeSpan formatted as a human-readable duration.


ToString
public override string ToString()

Returns a string containing both the in-sample and out-of-sample date ranges. The format is: InSampleStart-InSampleEnd, OutOfSampleStart-OutOfSampleEnd.


WFOEfficiency
public double WFOEfficiency

Contains the Walk-Forward Optimization Efficiency for this interval. WFOOptimizer calculates this by comparing the annualized return of the out-of-sample run with the annualized return of the corresponding in-sample result. Conceptually: OOS Annualized Return / IS Annualized Return � 100. A value of 100 means the out-of-sample annualized return matched the in-sample annualized return. A value below 100 indicates deterioration out of sample, while a value above 100 indicates stronger out-of-sample performance.


WFOEfficiencyDisplay
public string WFOEfficiencyDisplay

Returns WFOEfficiency formatted to two decimal places for an in-sample result. Returns an empty string for an out-of-sample result. This allows the WFO Efficiency value to be displayed once per interval rather than repeated on both the in-sample and out-of-sample rows.



Persistence
Parse
public override void Parse(string s)

Restores a WFOResult from a string created by Persist. In addition to the OptimizationResult base-class data, the method restores:

  • IntervalNumber
  • InSampleStartDate
  • InSampleEndDate
  • OutOfSampleStartDate
  • OutOfSampleEndDate
  • WFOEfficiency
  • IsInSample
  • BaseOptimization results
  • AvgBars
  • MinBars
  • MaxBars If persisted BaseOptimization results are present, WealthLab creates a StrategyOptimizer and restores its Results collection.

Persist
public override string Persist()

Serializes the WFOResult. The serialized value includes the inherited OptimizationResult data as well as the WFO-specific date ranges, interval information, WFO Efficiency, in/out-of-sample state, BaseOptimization results, and bar-count statistics.