Class MessageAdapter
- Namespace
- StockSharp.Messages
- Assembly
- StockSharp.Messages.dll
The base adapter converts messages Message to the command of the trading system and back.
public abstract class MessageAdapter : BaseLogReceiver, IMessageAdapter, IMessageTransport, IPersistable, ILogReceiver, ILogSource, IDisposable, ICloneable<IMessageAdapter>, ICloneable, INotifyPropertyChanged
- Inheritance
-
MessageAdapter
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MessageAdapter(IdGenerator)
Initialize MessageAdapter.
protected MessageAdapter(IdGenerator transactionIdGenerator)
Parameters
transactionIdGeneratorIdGeneratorTransaction id generator.
Properties
AssociatedBoards
The adapter can process subscription only with instruments associated with the specified board.
[Browsable(false)]
public virtual string[] AssociatedBoards { get; }
Property Value
- string[]
CandlesBuildFrom
Possible options for candles building.
[Browsable(false)]
public virtual IEnumerable<Level1Fields> CandlesBuildFrom { get; }
Property Value
Categories
Message adapter categories.
[Browsable(false)]
public virtual MessageAdapterCategories Categories { get; }
Property Value
CheckTimeFrameByRequest
Check possible time-frame by request.
[Browsable(false)]
public virtual bool CheckTimeFrameByRequest { get; }
Property Value
DisconnectTimeout
Gets the timeout to wait for a graceful disconnect.
[Browsable(false)]
public virtual TimeSpan DisconnectTimeout { get; }
Property Value
EnqueueSubscriptions
Enqueue subscriptions.
[Display(ResourceType = typeof(LocalizedStrings), Name = "EnqueueSubscriptions", Description = "EnqueueSubscriptionsDesc", GroupName = "Adapters", Order = 301)]
public virtual bool EnqueueSubscriptions { get; set; }
Property Value
Remarks
Do not send new request before received confirmation for previous.
ExtraSetup
The adapter requires extra setup.
[Browsable(false)]
public virtual bool ExtraSetup { get; }
Property Value
FaultDelay
Gets or sets the delay applied between faulted iterations.
[Display(ResourceType = typeof(LocalizedStrings), Name = "FaultDelay", Description = "FaultDelayDesc", GroupName = "Adapters", Order = 310)]
public TimeSpan FaultDelay { get; set; }
Property Value
FeatureName
Feature name.
[Browsable(false)]
public virtual string FeatureName { get; }
Property Value
FileSystem
Ecng.IO.IFileSystem
[Browsable(false)]
public IFileSystem FileSystem { get; set; }
Property Value
- IFileSystem
HeartbeatBeforeConnect
Start sending TimeMessage before connection established.
[Browsable(false)]
public virtual bool HeartbeatBeforeConnect { get; }
Property Value
HeartbeatInterval
Server check interval for track the connection alive. The value is Zero turned off tracking.
[Display(ResourceType = typeof(LocalizedStrings), Name = "HeartBeat", Description = "HeartBeatDesc", GroupName = "Adapters", Order = 300)]
public TimeSpan HeartbeatInterval { get; set; }
Property Value
Icon
Icon.
[Browsable(false)]
public virtual Uri Icon { get; }
Property Value
IsAutoReplyOnTransactonalUnsubscription
Send auto response for OrderStatusMessage and PortfolioLookupMessage unsubscribes.
[Browsable(false)]
public virtual bool IsAutoReplyOnTransactonalUnsubscription { get; }
Property Value
IsFullCandlesOnly
Translates CandleMessage as only fully filled.
[Browsable(false)]
public virtual bool IsFullCandlesOnly { get; }
Property Value
IsNativeIdentifiers
Identify security in messages by native identifier Native.
[Browsable(false)]
public virtual bool IsNativeIdentifiers { get; }
Property Value
IsNativeIdentifiersPersistable
Native identifier can be stored.
[Browsable(false)]
public virtual bool IsNativeIdentifiersPersistable { get; }
Property Value
IsPositionsEmulationRequired
Adapter required emulation PositionChangeMessage.
[Browsable(false)]
public virtual bool? IsPositionsEmulationRequired { get; }
Property Value
- bool?
Remarks
IsReplaceCommandEditCurrent
Is the OrderReplaceMessage command edit a current order.
[Browsable(false)]
public virtual bool IsReplaceCommandEditCurrent { get; }
Property Value
IsSecurityNewsOnly
Adapter provides news related with specified security.
[Browsable(false)]
public virtual bool IsSecurityNewsOnly { get; }
Property Value
IsSupportExecutionsPnL
Adapter fills PnL.
[Browsable(false)]
public virtual bool IsSupportExecutionsPnL { get; }
Property Value
IsSupportOrderBookIncrements
Adapter translates incremental order books.
[Browsable(false)]
public virtual bool IsSupportOrderBookIncrements { get; }
Property Value
IsSupportSubscriptions
Support any subscriptions (ticks, order books etc.).
[Browsable(false)]
public virtual bool IsSupportSubscriptions { get; }
Property Value
IsSupportTransactionLog
Adapter translates orders changes on reply of OrderStatusMessage.
[Browsable(false)]
public virtual bool IsSupportTransactionLog { get; }
Property Value
IterationInterval
Interval between iterations.
[Display(ResourceType = typeof(LocalizedStrings), Name = "Iterations", Description = "IterationInterval", GroupName = "Adapters", Order = 304)]
public virtual TimeSpan IterationInterval { get; set; }
Property Value
LookupTimeout
Lookup timeout.
[Browsable(false)]
public virtual TimeSpan? LookupTimeout { get; }
Property Value
MaxParallelMessages
Gets or sets the maximum number of parallel (non-control) messages that can be processed. Must be greater than or equal to1.
[Display(ResourceType = typeof(LocalizedStrings), Name = "Parallel", Description = "ParallelDesc", GroupName = "Adapters", Order = 310)]
public int MaxParallelMessages { get; set; }
Property Value
Name
The source name.
public override string Name { get; set; }
Property Value
NotSupportedResultMessages
Not supported by adapter result message types.
[Browsable(false)]
public virtual IEnumerable<MessageTypes> NotSupportedResultMessages { get; set; }
Property Value
OrderConditionType
Type of OrderCondition.
[Browsable(false)]
public virtual Type OrderConditionType { get; }
Property Value
Remarks
If the connection does not support the order type Conditional, it will be returned null.
Platform
Bit process, which can run the adapter.
[Browsable(false)]
public Platforms Platform { get; protected set; }
Property Value
PossibleSupportedMessages
Possible supported by adapter message types.
[Browsable(false)]
public virtual IEnumerable<MessageTypeInfo> PossibleSupportedMessages { get; set; }
Property Value
ReConnectionSettings
Connection tracking settings IMessageAdapter with a server.
[Display(ResourceType = typeof(LocalizedStrings), Name = "ReConnectionSettings", Description = "ReConnectionDesc", GroupName = "Connection")]
public ReConnectionSettings ReConnectionSettings { get; }
Property Value
SecurityExtendedFields
Names of extended security fields in SecurityMessage.
[Browsable(false)]
public virtual IEnumerable<(string, Type)> SecurityExtendedFields { get; }
Property Value
- IEnumerable<(string name, Type type)>
StorageName
The storage name, associated with the adapter.
[Browsable(false)]
public virtual string StorageName { get; }
Property Value
SupportedInMessages
Supported by adapter message types.
[Browsable(false)]
public virtual IEnumerable<MessageTypes> SupportedInMessages { get; set; }
Property Value
SupportedOrderBookDepths
Available options for MaxDepth.
[Browsable(false)]
public virtual IEnumerable<int> SupportedOrderBookDepths { get; }
Property Value
TransactionIdGenerator
Transaction id generator.
[Browsable(false)]
public IdGenerator TransactionIdGenerator { get; set; }
Property Value
UseInChannel
Use channels for in messages.
[Browsable(false)]
public virtual bool UseInChannel { get; }
Property Value
UseOutChannel
Use channels for out messages.
[Browsable(false)]
public virtual bool UseOutChannel { get; }
Property Value
Methods
BoardLookupAsync(BoardLookupMessage, CancellationToken)
protected virtual ValueTask BoardLookupAsync(BoardLookupMessage lookupMsg, CancellationToken cancellationToken)
Parameters
lookupMsgBoardLookupMessagecancellationTokenCancellationToken
Returns
CancelOrderAsync(OrderCancelMessage, CancellationToken)
protected virtual ValueTask CancelOrderAsync(OrderCancelMessage cancelMsg, CancellationToken cancellationToken)
Parameters
cancelMsgOrderCancelMessagecancellationTokenCancellationToken
Returns
CancelOrderGroupAsync(OrderGroupCancelMessage, CancellationToken)
protected virtual ValueTask CancelOrderGroupAsync(OrderGroupCancelMessage cancelMsg, CancellationToken cancellationToken)
Parameters
cancelMsgOrderGroupCancelMessagecancellationTokenCancellationToken
Returns
ChangePasswordAsync(ChangePasswordMessage, CancellationToken)
protected virtual ValueTask ChangePasswordAsync(ChangePasswordMessage pwdMsg, CancellationToken cancellationToken)
Parameters
pwdMsgChangePasswordMessagecancellationTokenCancellationToken
Returns
Clone()
Create a copy of MessageAdapter.
public virtual IMessageAdapter Clone()
Returns
- IMessageAdapter
Copy.
ConnectAsync(ConnectMessage, CancellationToken)
protected virtual ValueTask ConnectAsync(ConnectMessage connectMsg, CancellationToken cancellationToken)
Parameters
connectMsgConnectMessagecancellationTokenCancellationToken
Returns
CreateOrderLogMarketDepthBuilder(SecurityId)
Create market depth builder.
public virtual IOrderLogMarketDepthBuilder CreateOrderLogMarketDepthBuilder(SecurityId securityId)
Parameters
securityIdSecurityIdSecurity ID.
Returns
- IOrderLogMarketDepthBuilder
Order log to market depth builder.
DisconnectAsync(DisconnectMessage, CancellationToken)
protected virtual ValueTask DisconnectAsync(DisconnectMessage disconnectMsg, CancellationToken cancellationToken)
Parameters
disconnectMsgDisconnectMessagecancellationTokenCancellationToken
Returns
GetSupportedMarketDataTypesAsync(SecurityId, DateTime?, DateTime?)
Get supported by adapter message types.
public virtual IAsyncEnumerable<DataType> GetSupportedMarketDataTypesAsync(SecurityId securityId, DateTime? from, DateTime? to)
Parameters
securityIdSecurityIdfromDateTime?Start date for request. If null, then all available messages will be returned.
toDateTime?End date for request. If null, then all available messages will be returned.
Returns
- IAsyncEnumerable<DataType>
Supported by adapter market data types.
IsAllDownloadingSupported(DataType)
Is for the specified dataType all securities downloading enabled.
public virtual bool IsAllDownloadingSupported(DataType dataType)
Parameters
dataTypeDataTypeData type info.
Returns
- bool
Check result.
IsSecurityRequired(DataType)
Support filtering subscriptions (subscribe/unsubscribe for specified security).
public virtual bool IsSecurityRequired(DataType dataType)
Parameters
dataTypeDataTypeData type info.
Returns
- bool
Check result.
IsSupportCandlesPriceLevels(MarketDataMessage)
Support candles PriceLevels.
public virtual bool IsSupportCandlesPriceLevels(MarketDataMessage subscription)
Parameters
subscriptionMarketDataMessage
Returns
- bool
Check result.
IsSupportCandlesUpdates(MarketDataMessage)
Support candles subscription and live updates.
public virtual bool IsSupportCandlesUpdates(MarketDataMessage subscription)
Parameters
subscriptionMarketDataMessage
Returns
- bool
Check result.
Load(SettingsStorage)
Load settings.
public override void Load(SettingsStorage storage)
Parameters
storageSettingsStorageSettings storage.
MarketDataAsync(MarketDataMessage, CancellationToken)
protected virtual ValueTask MarketDataAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessagecancellationTokenCancellationToken
Returns
OnCandlesSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for candles data. Override to provide implementation for candles subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnCandlesSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnLevel1SubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for level1 data. Override to provide implementation for level1 subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnLevel1SubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnMarketDepthSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for market depth data. Override to provide implementation for market depth subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnMarketDepthSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnNewsSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for news data. Override to provide implementation for news subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnNewsSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnOrderLogSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for order log (trades/transactions) data. Override to provide implementation for order log subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnOrderLogSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnPropertyChanged(string)
Raise PropertyChanged event.
protected void OnPropertyChanged(string propertyName = null)
Parameters
propertyNamestringThe name of the property that changed.
OnSendInMessageAsync(Message, CancellationToken)
Send in message handler.
protected virtual ValueTask OnSendInMessageAsync(Message message, CancellationToken cancellationToken)
Parameters
messageMessagecancellationTokenCancellationToken
Returns
OnTFCandlesSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for time-frame candles (TF candles) data. Override to provide implementation for TF candles subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnTFCandlesSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OnTicksSubscriptionAsync(MarketDataMessage, CancellationToken)
Handles subscription request for ticks data. Override to provide implementation for ticks subscription processing. The default implementation throws NotSupported.
protected virtual ValueTask OnTicksSubscriptionAsync(MarketDataMessage mdMsg, CancellationToken cancellationToken)
Parameters
mdMsgMarketDataMessageMarket data subscription message.
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
OrderStatusAsync(OrderStatusMessage, CancellationToken)
protected virtual ValueTask OrderStatusAsync(OrderStatusMessage statusMsg, CancellationToken cancellationToken)
Parameters
statusMsgOrderStatusMessagecancellationTokenCancellationToken
Returns
PortfolioLookupAsync(PortfolioLookupMessage, CancellationToken)
protected virtual ValueTask PortfolioLookupAsync(PortfolioLookupMessage lookupMsg, CancellationToken cancellationToken)
Parameters
lookupMsgPortfolioLookupMessagecancellationTokenCancellationToken
Returns
RegisterOrderAsync(OrderRegisterMessage, CancellationToken)
protected virtual ValueTask RegisterOrderAsync(OrderRegisterMessage regMsg, CancellationToken cancellationToken)
Parameters
regMsgOrderRegisterMessagecancellationTokenCancellationToken
Returns
ReplaceOrderAsync(OrderReplaceMessage, CancellationToken)
protected virtual ValueTask ReplaceOrderAsync(OrderReplaceMessage replaceMsg, CancellationToken cancellationToken)
Parameters
replaceMsgOrderReplaceMessagecancellationTokenCancellationToken
Returns
ResetAsync(ResetMessage, CancellationToken)
protected virtual ValueTask ResetAsync(ResetMessage resetMsg, CancellationToken cancellationToken)
Parameters
resetMsgResetMessagecancellationTokenCancellationToken
Returns
Save(SettingsStorage)
Save settings.
public override void Save(SettingsStorage storage)
Parameters
storageSettingsStorageSettings storage.
SecurityLookupAsync(SecurityLookupMessage, CancellationToken)
protected virtual ValueTask SecurityLookupAsync(SecurityLookupMessage lookupMsg, CancellationToken cancellationToken)
Parameters
lookupMsgSecurityLookupMessagecancellationTokenCancellationToken
Returns
SendInMessageAsync(Message, CancellationToken)
Processes a generic message asynchronously.
public virtual ValueTask SendInMessageAsync(Message message, CancellationToken cancellationToken)
Parameters
messageMessageThe message to process.
cancellationTokenCancellationToken
Returns
SendOutConnectionStateAsync(ConnectionStates, CancellationToken)
Send to SendOutMessageAsync(Message, CancellationToken) connection state message.
protected ValueTask SendOutConnectionStateAsync(ConnectionStates state, CancellationToken cancellationToken)
Parameters
stateConnectionStatescancellationTokenCancellationTokenCancellation token.
Returns
SendOutDisconnectMessageAsync(bool, CancellationToken)
Send to SendOutMessageAsync(Message, CancellationToken) disconnect message.
protected ValueTask SendOutDisconnectMessageAsync(bool expected, CancellationToken cancellationToken)
Parameters
expectedboolIs disconnect expected.
cancellationTokenCancellationTokenCancellation token.
Returns
SendOutDisconnectMessageAsync(Exception, CancellationToken)
Send to SendOutMessageAsync(Message, CancellationToken) disconnect message.
protected ValueTask SendOutDisconnectMessageAsync(Exception error, CancellationToken cancellationToken)
Parameters
errorExceptionError info. Can be null.
cancellationTokenCancellationTokenCancellation token.
Returns
SendOutErrorAsync(Exception, CancellationToken)
Initialize a new message ErrorMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendOutErrorAsync(Exception error, CancellationToken cancellationToken)
Parameters
errorExceptionError details.
cancellationTokenCancellationTokenCancellation token.
Returns
SendOutErrorAsync(string, CancellationToken)
Initialize a new message ErrorMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendOutErrorAsync(string description, CancellationToken cancellationToken)
Parameters
descriptionstringError details.
cancellationTokenCancellationTokenCancellation token.
Returns
SendOutMessageAsync(Message, CancellationToken)
Send outgoing message and raise NewOutMessageAsync event.
public virtual ValueTask SendOutMessageAsync(Message message, CancellationToken cancellationToken)
Parameters
messageMessageMessage.
cancellationTokenCancellationToken
Returns
SendSubscriptionFinishedAsync(long, CancellationToken, DateTime?)
Initialize a new message SubscriptionFinishedMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendSubscriptionFinishedAsync(long originalTransactionId, CancellationToken cancellationToken, DateTime? nextFrom = null)
Parameters
originalTransactionIdlongID of the original message for which this message is a response.
cancellationTokenCancellationTokenCancellation token.
nextFromDateTime?
Returns
SendSubscriptionNotSupportedAsync(long, CancellationToken)
Initialize a new message SubscriptionResponseMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendSubscriptionNotSupportedAsync(long originalTransactionId, CancellationToken cancellationToken)
Parameters
originalTransactionIdlongID of the original message for which this message is a response.
cancellationTokenCancellationTokenCancellation token.
Returns
SendSubscriptionOnlineAsync(long, CancellationToken)
Initialize a new message SubscriptionOnlineMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendSubscriptionOnlineAsync(long originalTransactionId, CancellationToken cancellationToken)
Parameters
originalTransactionIdlongID of the original message for which this message is a response.
cancellationTokenCancellationTokenCancellation token.
Returns
SendSubscriptionReplyAsync(long, CancellationToken, Exception)
Initialize a new message SubscriptionResponseMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendSubscriptionReplyAsync(long originalTransactionId, CancellationToken cancellationToken, Exception error = null)
Parameters
originalTransactionIdlongID of the original message for which this message is a response.
cancellationTokenCancellationTokenCancellation token.
errorExceptionSubscribe or unsubscribe error info. To be set if the answer.
Returns
SendSubscriptionResultAsync(ISubscriptionMessage, CancellationToken)
Initialize a new message SubscriptionOnlineMessage or SubscriptionFinishedMessage and pass it to the method SendOutMessageAsync(Message, CancellationToken).
protected ValueTask SendSubscriptionResultAsync(ISubscriptionMessage message, CancellationToken cancellationToken)
Parameters
messageISubscriptionMessageSubscription.
cancellationTokenCancellationTokenCancellation token.
Returns
TimeAsync(TimeMessage, CancellationToken)
protected virtual ValueTask TimeAsync(TimeMessage timeMsg, CancellationToken cancellationToken)
Parameters
timeMsgTimeMessagecancellationTokenCancellationToken
Returns
ValidateSecurityId(SecurityId)
Validate the specified security id is supported by the adapter and subscription can be done.
protected virtual bool ValidateSecurityId(SecurityId secId)
Parameters
secIdSecurityId
Returns
- bool
Check result.
Events
NewOutMessageAsync
New message event.
public event Func<Message, CancellationToken, ValueTask> NewOutMessageAsync