Table of Contents

Class HistoryEmulationConnector

Namespace
StockSharp.Algo.Testing
Assembly
StockSharp.Algo.dll

The emulation connection. It uses historical data and/or occasionally generated.

public class HistoryEmulationConnector : BaseEmulationConnector, IConnector, IPersistable, ILogReceiver, ILogSource, IMarketDataProvider, ITransactionProvider, IPositionProvider, IPortfolioProvider, ISecurityProvider, ISecurityMessageProvider, INewsProvider, IMessageChannel, IDisposable, ICloneable<IMessageChannel>, ICloneable, ISubscriptionProvider
Inheritance
HistoryEmulationConnector
Implements
IPersistable
ICloneable<IMessageChannel>
Inherited Members
Extension Methods

Constructors

HistoryEmulationConnector(ISecurityProvider)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(ISecurityProvider securityProvider)

Parameters

securityProvider ISecurityProvider

The provider of information about instruments.

HistoryEmulationConnector(ISecurityProvider, IPortfolioProvider, IExchangeInfoProvider)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)

Parameters

securityProvider ISecurityProvider

The provider of information about instruments.

portfolioProvider IPortfolioProvider

The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

HistoryEmulationConnector(ISecurityProvider, IPortfolioProvider, IExchangeInfoProvider, IStorageRegistry)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider, IStorageRegistry storageRegistry)

Parameters

securityProvider ISecurityProvider

The provider of information about instruments.

portfolioProvider IPortfolioProvider

The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

storageRegistry IStorageRegistry

Market data storage.

HistoryEmulationConnector(ISecurityProvider, IPortfolioProvider, IStorageRegistry)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IStorageRegistry storageRegistry)

Parameters

securityProvider ISecurityProvider

The provider of information about instruments.

portfolioProvider IPortfolioProvider

The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.

storageRegistry IStorageRegistry

Market data storage.

HistoryEmulationConnector(ISecurityProvider, IEnumerable<Portfolio>)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(ISecurityProvider securityProvider, IEnumerable<Portfolio> portfolios)

Parameters

securityProvider ISecurityProvider

The provider of information about instruments.

portfolios IEnumerable<Portfolio>

Portfolios, the operation will be performed with.

HistoryEmulationConnector(IMessageAdapter, bool, IMessageChannel, ISecurityProvider, IPortfolioProvider, IExchangeInfoProvider)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(IMessageAdapter innerAdapter, bool ownInnerAdapter, IMessageChannel inChannel, ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)

Parameters

innerAdapter IMessageAdapter

Underlying adapter.

ownInnerAdapter bool

Control innerAdapter lifetime.

inChannel IMessageChannel

Incoming messages channel.

securityProvider ISecurityProvider

The provider of information about instruments.

portfolioProvider IPortfolioProvider

The portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

HistoryEmulationConnector(IEnumerable<Security>, IEnumerable<Portfolio>)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(IEnumerable<Security> securities, IEnumerable<Portfolio> portfolios)

Parameters

securities IEnumerable<Security>

Instruments, which will be sent through the NewSecurities event.

portfolios IEnumerable<Portfolio>

Portfolios, which will be sent through the NewPortfolios event.

HistoryEmulationConnector(IEnumerable<Security>, IEnumerable<Portfolio>, IStorageRegistry)

Initializes a new instance of the HistoryEmulationConnector.

public HistoryEmulationConnector(IEnumerable<Security> securities, IEnumerable<Portfolio> portfolios, IStorageRegistry storageRegistry)

Parameters

securities IEnumerable<Security>

Instruments, the operation will be performed with.

portfolios IEnumerable<Portfolio>

Portfolios, the operation will be performed with.

storageRegistry IStorageRegistry

Market data storage.

Properties

CommissionRules

Commission rules.

[Obsolete("Use EmulationSettings.CommissionRules property.")]
public IEnumerable<ICommissionRule> CommissionRules { get; set; }

Property Value

IEnumerable<ICommissionRule>

EmulationSettings

public MarketEmulatorSettings EmulationSettings { get; }

Property Value

MarketEmulatorSettings

HistoryMessageAdapter

The adapter, receiving messages form the storage IStorageRegistry.

public HistoryMessageAdapter HistoryMessageAdapter { get; }

Property Value

HistoryMessageAdapter

IsFinished

Has the emulator ended its operation due to end of data, or it was interrupted through the Disconnect()method.

public bool IsFinished { get; }

Property Value

bool

MarketTimeChangedInterval

The TimeMessage message generating Interval. The default is 10 milliseconds.

public override TimeSpan MarketTimeChangedInterval { set; }

Property Value

TimeSpan

RiskManager

Risk control manager.

public override IRiskManager RiskManager { get; }

Property Value

IRiskManager

State

The emulator state.

public ChannelStates State { get; }

Property Value

ChannelStates

StopOnSubscriptionError

Call Disconnect() when any Subscription failed.

public bool StopOnSubscriptionError { get; set; }

Property Value

bool

SupportSnapshots

public override bool SupportSnapshots { get; }

Property Value

bool

Methods

ClearCache()

Clear cache.

public override void ClearCache()

DisposeManaged()

To release allocated resources. In particular, to disconnect from the trading system via Disconnect().

protected override void DisposeManaged()

OnConnect()

Connect to trading system.

protected override void OnConnect()

OnDisconnect()

Disconnect from trading system.

protected override void OnDisconnect()

OnProcessMessage(Message)

Process message.

protected override void OnProcessMessage(Message message)

Parameters

message Message

Message.

RaiseSubscriptionFailed(Subscription, Exception, bool)

protected override void RaiseSubscriptionFailed(Subscription subscription, Exception error, bool isSubscribe)

Parameters

subscription Subscription
error Exception
isSubscribe bool

RegisterHistorySource(Security, DataType, Func<DateTimeOffset, IEnumerable<Message>>)

Register historical data source.

[Obsolete("Uses custom adapter implementation.")]
public Subscription RegisterHistorySource(Security security, DataType dataType, Func<DateTimeOffset, IEnumerable<Message>> getMessages)

Parameters

security Security

Instrument. If passed null the source will be applied for all subscriptions.

dataType DataType

Data type.

getMessages Func<DateTimeOffset, IEnumerable<Message>>

Historical data source.

Returns

Subscription

Subscription.

Start()

To start the emulation.

public void Start()

Suspend()

To suspend the emulation.

public void Suspend()

UnRegisterHistorySource(Security, DataType)

Unregister historical data source, previously registered by RegisterHistorySource(Security, DataType, Func<DateTimeOffset, IEnumerable<Message>>).

[Obsolete("Uses UnSubscribe method.")]
public void UnRegisterHistorySource(Security security, DataType dataType)

Parameters

security Security

Instrument. If passed null the source will be removed for all subscriptions.

dataType DataType

Data type.

Events

ProgressChanged

Progress changed event.

public event Action<int> ProgressChanged

Event Type

Action<int>

StateChanged

The event on the emulator state change State.

[Obsolete("Use StateChanged2 event.")]
public event Action StateChanged

Event Type

Action

StateChanged2

The event on the emulator state change State.

public event Action<ChannelStates> StateChanged2

Event Type

Action<ChannelStates>