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
-
IPersistableICloneable<IMessageChannel>
- Inherited Members
- Extension Methods
Constructors
HistoryEmulationConnector(ISecurityProvider)
Initializes a new instance of the HistoryEmulationConnector.
public HistoryEmulationConnector(ISecurityProvider securityProvider)
Parameters
securityProvider
ISecurityProviderThe provider of information about instruments.
HistoryEmulationConnector(ISecurityProvider, IPortfolioProvider, IStorageRegistry)
Initializes a new instance of the HistoryEmulationConnector.
public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IStorageRegistry storageRegistry)
Parameters
securityProvider
ISecurityProviderThe provider of information about instruments.
portfolioProvider
IPortfolioProviderThe portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
storageRegistry
IStorageRegistryMarket data storage.
HistoryEmulationConnector(ISecurityProvider, IPortfolioProvider, IExchangeInfoProvider)
Initializes a new instance of the HistoryEmulationConnector.
public HistoryEmulationConnector(ISecurityProvider securityProvider, IPortfolioProvider portfolioProvider, IExchangeInfoProvider exchangeInfoProvider)
Parameters
securityProvider
ISecurityProviderThe provider of information about instruments.
portfolioProvider
IPortfolioProviderThe portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
ISecurityProviderThe provider of information about instruments.
portfolioProvider
IPortfolioProviderThe portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
storageRegistry
IStorageRegistryMarket data storage.
HistoryEmulationConnector(ISecurityProvider, IEnumerable<Portfolio>)
Initializes a new instance of the HistoryEmulationConnector.
public HistoryEmulationConnector(ISecurityProvider securityProvider, IEnumerable<Portfolio> portfolios)
Parameters
securityProvider
ISecurityProviderThe 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
IMessageAdapterUnderlying adapter.
ownInnerAdapter
boolControl
innerAdapter
lifetime.inChannel
IMessageChannelIncoming messages channel.
securityProvider
ISecurityProviderThe provider of information about instruments.
portfolioProvider
IPortfolioProviderThe portfolio to be used to register orders. If value is not given, the portfolio with default name Simulator will be created.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
IStorageRegistryMarket data storage.
Properties
CommissionRules
Commission rules.
[Obsolete("Use EmulationSettings.CommissionRules property.")]
public IEnumerable<ICommissionRule> CommissionRules { get; set; }
Property Value
EmulationSettings
public MarketEmulatorSettings EmulationSettings { get; }
Property Value
HistoryMessageAdapter
The adapter, receiving messages form the storage IStorageRegistry.
public HistoryMessageAdapter HistoryMessageAdapter { get; }
Property Value
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
MarketTimeChangedInterval
The TimeMessage message generating Interval. The default is 10 milliseconds.
public override TimeSpan MarketTimeChangedInterval { set; }
Property Value
MaxMessageCount
public int MaxMessageCount { get; set; }
Property Value
RiskManager
Risk control manager.
public override IRiskManager RiskManager { get; }
Property Value
State
The emulator state.
public ChannelStates State { get; }
Property Value
StopOnSubscriptionError
Call Disconnect() when any Subscription failed.
public bool StopOnSubscriptionError { get; set; }
Property Value
SupportSnapshots
public override bool SupportSnapshots { get; }
Property Value
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
MessageMessage.
RaiseSubscriptionFailed(Subscription, Exception, bool)
protected override void RaiseSubscriptionFailed(Subscription subscription, Exception error, bool isSubscribe)
Parameters
subscription
Subscriptionerror
ExceptionisSubscribe
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
SecurityInstrument. If passed null the source will be applied for all subscriptions.
dataType
DataTypeData 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
SecurityInstrument. If passed null the source will be removed for all subscriptions.
dataType
DataTypeData type.
Events
ProgressChanged
Progress changed event.
public event Action<int> ProgressChanged
Event Type
StateChanged
The event on the emulator state change State.
[Obsolete("Use StateChanged2 event.")]
public event Action StateChanged
Event Type
StateChanged2
The event on the emulator state change State.
public event Action<ChannelStates> StateChanged2