StrategyParamHelper

StockSharp.Algo.Strategies

The auxiliary class for StrategyParam.

Methods

CanOptimize
public static bool CanOptimize(Type type)
result = StrategyParamHelper.CanOptimize(type)

Check can optimize parameter.

type
The type of the parameter value.

Returns: , if can optimize the parameter, otherwise, .

CreateParam
public static IStrategyParam CreateParam(Type type, string id)
result = StrategyParamHelper.CreateParam(type, id)

Create parameter.

type
Type
id
Id

Returns: IStrategyParam

GetIterationsCount
public static int GetIterationsCount(IStrategyParam param)
result = StrategyParamHelper.GetIterationsCount(param)

Get the number of optimization iterations for the parameter.

param
IStrategyParam

Returns: Number of iterations.

GetIterationsCount
public static int GetIterationsCount(Type type, object from, object to, object step, IEnumerable values)
result = StrategyParamHelper.GetIterationsCount(type, from, to, step, values)

Get the number of optimization iterations for a parameter shape.

type
The type of the parameter value.
from
Initial value, or .
to
Final value, or .
step
Increment value, or .
values
Explicit values, or . Win over the range when not empty.

Returns: Number of iterations, zero when the shape defines no values of its own.

GetName
public static string GetName(IStrategyParam param)
result = StrategyParamHelper.GetName(param)

Get the parameter name.

param
IStrategyParam

Returns: Display name.

GetOptimizationValues
public static IEnumerable<object> GetOptimizationValues(Type type, object from, object to, object step, IEnumerable values)
result = StrategyParamHelper.GetOptimizationValues(type, from, to, step, values)

Get all optimization values for a parameter shape.

type
The type of the parameter value.
from
Initial value, or .
to
Final value, or .
step
Increment value, or .
values
Explicit values, or . Win over the range when not empty.

Returns: Enumerable of all optimization values, empty when the shape defines none of its own.

GetOptimizationValues
public static IEnumerable<object> GetOptimizationValues(IStrategyParam param)
result = StrategyParamHelper.GetOptimizationValues(param)

Get all optimization values for the parameter.

param
IStrategyParam

Returns: Enumerable of all optimization values.

GetRandom
public static object GetRandom(IStrategyParam param, IRandomProvider provider)
result = StrategyParamHelper.GetRandom(param, provider)

Generate a random value within the optimization range for the parameter.

param
IStrategyParam
provider
Where the value is drawn from. A search worth keeping the result of is worth running again, so the caller states the source rather than a default deciding for it - RandomProvider is the one a strategy runs on.

Returns: Random value within the optimization range.

GetRandomValues
public static HashSet<object> GetRandomValues(IStrategyParam param, int count, IRandomProvider provider)
result = StrategyParamHelper.GetRandomValues(param, count, provider)

Generate a set of unique random values for the parameter.

param
IStrategyParam
count
Number of random values to generate.
provider
Where the values are drawn from.

Returns: Set of unique random values.

GetRandomValues``1
public static HashSet<T> GetRandomValues<T>(StrategyParam<T> param, int count, IRandomProvider provider)
result = StrategyParamHelper.GetRandomValues(param, count, provider)

Generate a set of unique random values for the parameter.

param
StrategyParam
count
Number of random values to generate.
provider
Where the values are drawn from.

Returns: Set of unique random values.

GetRandom``1
public static T GetRandom<T>(StrategyParam<T> param, IRandomProvider provider)
result = StrategyParamHelper.GetRandom(param, provider)

Generate a random value within the optimization range for the parameter.

param
StrategyParam
provider
Where the value is drawn from.

Returns: Random value within the optimization range.

ToBruteForce
public static IEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForce(Strategy strategy, IEnumerable<ValueTuple<IStrategyParam, IEnumerable>> parameters, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForce(strategy, parameters, optimizedParams, totalCount)

Generate all strategy clones with parameter permutations for brute force optimization. Supports explicit value lists for parameters like Security, DataType.

strategy
The base strategy to clone.
parameters
The parameters with optional explicit values to use instead of range.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToBruteForce
public static IEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForce(Strategy strategy, IStrategyParam[] parameters, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForce(strategy, parameters, optimizedParams, totalCount)

Generate all strategy clones with parameter permutations for brute force optimization.

strategy
The base strategy to clone.
parameters
The parameters to optimize.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToBruteForceAsync
public static IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForceAsync(Strategy strategy, IStrategyParam[] parameters, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForceAsync(strategy, parameters, optimizedParams, totalCount)

Generate all strategy clones with parameter permutations for brute force optimization.

strategy
The base strategy to clone.
parameters
The parameters to optimize.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToBruteForceAsync
public static IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForceAsync(Strategy strategy, IEnumerable<ValueTuple<IStrategyParam, IEnumerable>> parameters, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForceAsync(strategy, parameters, optimizedParams, totalCount)

Generate all strategy clones with parameter permutations for brute force optimization. Supports explicit value lists for parameters like Security, DataType.

strategy
The base strategy to clone.
parameters
The parameters with optional explicit values to use instead of range.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToBruteForceRandom
public static IEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForceRandom(Strategy strategy, IStrategyParam[] parameters, int randomCount, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForceRandom(strategy, parameters, randomCount, optimizedParams, totalCount)

Generate all strategy clones with random parameter values for brute force optimization.

strategy
The base strategy to clone.
parameters
The parameters to optimize.
randomCount
Number of random samples per parameter.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToBruteForceRandomAsync
public static IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ToBruteForceRandomAsync(Strategy strategy, IStrategyParam[] parameters, int randomCount, IStrategyParam[] optimizedParams, int totalCount)
result = StrategyParamHelper.ToBruteForceRandomAsync(strategy, parameters, randomCount, optimizedParams, totalCount)

Generate all strategy clones with random parameter values for brute force optimization.

strategy
The base strategy to clone.
parameters
The parameters to optimize.
randomCount
Number of random samples per parameter.
optimizedParams
Output: all parameters involved in optimization.
totalCount
Output: total number of iterations.

Returns: Lazy enumerable of strategy clones with their parameter arrays.

ToGeneticParameters
public static ValueTuple<IStrategyParam, object, object, object, IEnumerable>[] ToGeneticParameters(Strategy strategy, IStrategyParam[] parameters)
result = StrategyParamHelper.ToGeneticParameters(strategy, parameters)

Convert strategy parameters to genetic optimizer format.

strategy
The strategy with parameters.
parameters
The parameters to optimize.

Returns: Array of tuples suitable for CancellationToken).

ToGeneticParameters
public static ValueTuple<IStrategyParam, object, object, object, IEnumerable>[] ToGeneticParameters(Strategy strategy, IEnumerable<ValueTuple<IStrategyParam, IEnumerable>> parameters)
result = StrategyParamHelper.ToGeneticParameters(strategy, parameters)

Convert strategy parameters to genetic optimizer format with explicit values support.

strategy
The strategy with parameters.
parameters
The parameters with optional explicit values to use instead of range.

Returns: Array of tuples suitable for CancellationToken).