BaseOptimizer
战略基础优化.
继承自: BaseLogReceiver
构造函数
protected BaseOptimizer(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry, StorageFormats storageFormat, IMarketDataDrive drive)
baseOptimizer = BaseOptimizer(securityProvider, portfolioProvider, exchangeInfoProvider, storageRegistry, storageFormat, drive)
初始化了 & ##BaseOptimizer+#的新实例.
- securityProvider
- 提供各种文书的信息。
- portfolioProvider
- 用于注册命令的组合。 如果未给出值, 将创建默认名称模拟器的组合 。
- exchangeInfoProvider
- 交易所和交易委员会供应商。
- storageRegistry
- 市场数据存储.
- storageFormat
- 市场数据的格式。默认情况下使用二进制。
- drive
- 默认使用的存储。 默认情况下, 使用 DefaultDrive 。
属性
public MarketDataStorageCache AdapterCache { get; set; }
value = baseOptimizer.AdapterCache
baseOptimizer.AdapterCache = value
AdapterCache.
public OptimizerSettings EmulationSettings { get; }
value = baseOptimizer.EmulationSettings
模拟设置.
public IExchangeInfoProvider ExchangeInfoProvider { get; }
value = baseOptimizer.ExchangeInfoProvider
IExchangeInfoProvider
public IPortfolioProvider PortfolioProvider { get; }
value = baseOptimizer.PortfolioProvider
IPortfolioProvider
protected CancellationToken RunToken { get; }
value = baseOptimizer.RunToken
Cancellation token for the current optimization run, including optimizer disposal and consumer cancellation.
public ISecurityProvider SecurityProvider { get; }
value = baseOptimizer.SecurityProvider
ISecurityProvider
public bool StopOnSubscriptionError { get; set; }
value = baseOptimizer.StopOnSubscriptionError
baseOptimizer.StopOnSubscriptionError = value
StopOnSubscriptionError
public MarketDataStorageCache StorageCache { get; set; }
value = baseOptimizer.StorageCache
baseOptimizer.StorageCache = value
StorageCache.
public StorageCoreSettings StorageSettings { get; }
value = baseOptimizer.StorageSettings
存储设置.
方法
protected internal MarketDataStorageCache AllocateAdapterCache()
result = baseOptimizer.AllocateAdapterCache()
Allocate AdapterCache.
返回值: AdapterCache
protected internal MarketDataStorageCache AllocateStorageCache()
result = baseOptimizer.AllocateStorageCache()
Allocate StorageCache.
返回值: StorageCache
protected void CancelRun()
baseOptimizer.CancelRun()
Cancel the current optimization run and let its producers drain.
protected void CompleteChannel()
baseOptimizer.CompleteChannel()
完成频道, RunAsync 计数结束 。
protected internal void FreeAdapterCache(MarketDataStorageCache cache)
baseOptimizer.FreeAdapterCache(cache)
Free AdapterCache.
- cache
- AdapterCache
protected internal void FreeStorageCache(MarketDataStorageCache cache)
baseOptimizer.FreeStorageCache(cache)
Free StorageCache.
- cache
- StorageCache
protected void InitializeRunAsync(int totalIterations, CancellationToken cancellationToken)
baseOptimizer.InitializeRunAsync(totalIterations, cancellationToken)
初始化频道,批量管理器,并链接到RunAsync的CTS.
- totalIterations
- 重复次数总数(或 如未知为 * * int.MaxValue * *) 。
- cancellationToken
- 外出取消证.
public Task Pause()
result = baseOptimizer.Pause()
暂停优化。 在调用Resume之前, 新的迭代不会开始, 已经运行的后置测试被暂停, 因此进度会很快停止 。
返回值: 任务
protected IAsyncEnumerable<ValueTuple<Strategy, IStrategyParam[]>> ReadResultsAsync(CancellationToken cancellationToken)
result = baseOptimizer.ReadResultsAsync(cancellationToken)
频道阅读器的 Yield 成绩 。
private void StopStartedConnector(HistoryEmulationConnector connector)
baseOptimizer.StopStartedConnector(connector)
Disconnect a connector that is up, so its iteration reaches Stopped and signals the worker waiting on it. One that is already stopping gets there on its own.
protected internal ValueTask<bool> TryNextRunAsync(DateTime startTime, DateTime stopTime, Func<IPortfolioProvider, CancellationToken, ValueTask<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.
事件
public event Action<Connector> ConnectorInitialized
baseOptimizer.ConnectorInitialized += handler
Init Connector. Called before Connect.
public event Action<Strategy, IStrategyParam[], int> SingleProgressChanged
baseOptimizer.SingleProgressChanged += handler
单项进展变化事件.
public event Action<Strategy, IStrategyParam[]> StrategyInitialized
baseOptimizer.StrategyInitialized += handler
战略启动活动。