BaseOptimizer

StockSharp.Algo.Strategies.Optimization

The base optimizer of strategies.

Inherits: BaseLogReceiver

Constructors

BaseOptimizer
protected BaseOptimizer(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat, IMarketDataDrive drive)
baseOptimizer = BaseOptimizer(securityProvider, portfolioProvider, exchangeInfoProvider, storageRegistry, storageFormat, drive)

Initializes a new instance of the BaseOptimizer.

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.

Properties

AdapterCache
public MarketDataStorageCache AdapterCache { get; set; }
value = baseOptimizer.AdapterCache
baseOptimizer.AdapterCache = value

AdapterCache.

EmulationSettings
public OptimizerSettings EmulationSettings { get; }
value = baseOptimizer.EmulationSettings

Emulation settings.

ExchangeInfoProvider
public IExchangeInfoProvider ExchangeInfoProvider { get; }
value = baseOptimizer.ExchangeInfoProvider

IExchangeInfoProvider

IsPaused
public bool IsPaused { get; }
value = baseOptimizer.IsPaused

Whether optimization is currently paused.

PortfolioProvider
public IPortfolioProvider PortfolioProvider { get; }
value = baseOptimizer.PortfolioProvider

IPortfolioProvider

SecurityProvider
public ISecurityProvider SecurityProvider { get; }
value = baseOptimizer.SecurityProvider

ISecurityProvider

StopOnSubscriptionError
public bool StopOnSubscriptionError { get; set; }
value = baseOptimizer.StopOnSubscriptionError
baseOptimizer.StopOnSubscriptionError = value

StopOnSubscriptionError

StorageCache
public MarketDataStorageCache StorageCache { get; set; }
value = baseOptimizer.StorageCache
baseOptimizer.StorageCache = value

StorageCache.

StorageSettings
public StorageCoreSettings StorageSettings { get; }
value = baseOptimizer.StorageSettings

Storage settings.

Methods

AllocateAdapterCache
protected internal MarketDataStorageCache AllocateAdapterCache()
result = baseOptimizer.AllocateAdapterCache()

Allocate AdapterCache.

Returns: AdapterCache

AllocateStorageCache
protected internal MarketDataStorageCache AllocateStorageCache()
result = baseOptimizer.AllocateStorageCache()

Allocate StorageCache.

Returns: StorageCache

CompleteChannel
protected void CompleteChannel()
baseOptimizer.CompleteChannel()

Complete the channel so RunAsync enumeration ends.

DisposeManaged
protected override void DisposeManaged()
baseOptimizer.DisposeManaged()

Release resources.

FreeAdapterCache
protected internal void FreeAdapterCache(MarketDataStorageCache cache)
baseOptimizer.FreeAdapterCache(cache)

Free AdapterCache.

cache
AdapterCache
FreeStorageCache
protected internal void FreeStorageCache(MarketDataStorageCache cache)
baseOptimizer.FreeStorageCache(cache)

Free StorageCache.

cache
StorageCache
InitializeRunAsync
protected void InitializeRunAsync(int totalIterations, CancellationToken cancellationToken)
baseOptimizer.InitializeRunAsync(totalIterations, cancellationToken)

Initialize channel, batch manager, and linked CTS for RunAsync.

totalIterations
Total number of iterations (or int.MaxValue if unknown).
cancellationToken
External cancellation token.
Pause
public Task Pause()
result = baseOptimizer.Pause()

Pause optimization. New iterations won't start until Resume is called, and the backtests that are already running are suspended so progress halts promptly.

Returns: Task

ReadResultsAsync
protected IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ReadResultsAsync(CancellationToken cancellationToken)
result = baseOptimizer.ReadResultsAsync(cancellationToken)

Yield results from channel reader.

Resume
public Task Resume()
result = baseOptimizer.Resume()

Resume paused optimization.

Returns: Task

TryNextRunAsync
protected internal ValueTask<bool> TryNextRunAsync(DateTime startTime, DateTime stopTime, Func<IPortfolioProvider, ValueTuple<Strategy, IStrategyParam[]>?> tryGetNext, MarketDataStorageCache adapterCache, MarketDataStorageCache storageCache, CancellationToken cancellationToken)
result = baseOptimizer.TryNextRunAsync(startTime, stopTime, tryGetNext, adapterCache, storageCache, cancellationToken)

Try start next iteration. Returns if iteration was started and completed, if no more iterations available.

startTime
Date in history for starting the paper trading.
stopTime
Date in history to stop the paper trading (date is included).
tryGetNext
Handler to try to get next strategy object.
adapterCache
AdapterCache
storageCache
StorageCache
cancellationToken
Cancellation token.

Events

ConnectorInitialized
public event Action<Connector> ConnectorInitialized
baseOptimizer.ConnectorInitialized += handler

Init Connector. Called before Connect.

SingleProgressChanged
public event Action<Strategy, IStrategyParam[], int> SingleProgressChanged
baseOptimizer.SingleProgressChanged += handler

The event of single progress change.

StrategyInitialized
public event Action<Strategy, IStrategyParam[]> StrategyInitialized
baseOptimizer.StrategyInitialized += handler

Strategy initialized event.