GeneticOptimizer
StockSharp.Algo.Strategies.Optimization
The genetic optimizer of strategies.
Inherits: BaseOptimizer
Constructors
GeneticOptimizer
public GeneticOptimizer(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IStorageRegistry storageRegistry, IFileSystem fileSystem)
geneticOptimizer = GeneticOptimizer(securityProvider, portfolioProvider, storageRegistry, fileSystem)
Initializes a new instance of the GeneticOptimizer.
- securityProvider
- The provider of information about instruments.
- portfolioProvider
- The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
- storageRegistry
- Market data storage.
- fileSystem
- File system.
GeneticOptimizer
public GeneticOptimizer(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat, IMarketDataDrive drive, IFileSystem fileSystem)
geneticOptimizer = GeneticOptimizer(securityProvider, portfolioProvider, exchangeInfoProvider, storageRegistry, storageFormat, drive, fileSystem)
Initializes a new instance of the GeneticOptimizer.
- securityProvider
- The provider of information about instruments.
- portfolioProvider
- The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
- exchangeInfoProvider
- Exchanges and trading boards provider.
- storageRegistry
- Market data storage.
- storageFormat
- The format of market data. Binary is used by default.
- drive
- The storage which is used by default. By default, DefaultDrive is used.
- fileSystem
- File system.
GeneticOptimizer
public GeneticOptimizer(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat, IMarketDataDrive drive, IFitnessFormulaProvider formulaProvider)
geneticOptimizer = GeneticOptimizer(securityProvider, portfolioProvider, exchangeInfoProvider, storageRegistry, storageFormat, drive, formulaProvider)
Initializes a new instance of the GeneticOptimizer.
- securityProvider
- The provider of information about instruments.
- portfolioProvider
- The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
- exchangeInfoProvider
- Exchanges and trading boards provider.
- storageRegistry
- Market data storage.
- storageFormat
- The format of market data. Binary is used by default.
- drive
- The storage which is used by default. By default, DefaultDrive is used.
- formulaProvider
- Fitness formula provider.
Properties
Methods
HasRemainingIterations
private bool HasRemainingIterations()
result = geneticOptimizer.HasRemainingIterations()
Check if there are remaining iterations.
RunAsync
public IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> RunAsync(DateTime startTime, DateTime stopTime, Strategy strategy, IEnumerable<ValueTuple<IStrategyParam, object, object, object, IEnumerable>> parameters, Func<Strategy, decimal> calcFitness, ISelection selection, ICrossover crossover, IMutation mutation, CancellationToken cancellationToken)
result = geneticOptimizer.RunAsync(startTime, stopTime, strategy, parameters, calcFitness, selection, crossover, mutation, cancellationToken)
Run optimization and yield completed iterations as they finish.
- startTime
- Date in history for starting the paper trading.
- stopTime
- Date in history to stop the paper trading (date is included).
- strategy
- Strategy.
- parameters
- Parameters used to generate chromosomes.
- calcFitness
- Calc fitness value function. If the value from Fitness will be used.
- selection
- ISelection. If the value from Selection will be used.
- crossover
- ICrossover. If the value from Crossover will be used.
- mutation
- IMutation. If the value from Mutation will be used.
- cancellationToken
- Cancellation token.
Returns: Async enumerable of completed (strategy, parameters) pairs.
TryConsumeIteration
private bool TryConsumeIteration()
result = geneticOptimizer.TryConsumeIteration()
Try to consume one iteration from the limit.
Returns: True if iteration was consumed, false if limit reached.