Table of Contents

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, IMessageChannel, ICloneable<IMessageChannel>, ICloneable, IPersistable, ILogReceiver, ILogSource, IDisposable, INotifyPropertyChanged
Inheritance
MessageAdapter
Implements
ICloneable<IMessageChannel>
IPersistable
Derived
Inherited Members
Extension Methods

Constructors

MessageAdapter(IdGenerator)

Initialize MessageAdapter.

protected MessageAdapter(IdGenerator transactionIdGenerator)

Parameters

transactionIdGenerator IdGenerator

Transaction 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

IEnumerable<Level1Fields>

Categories

Message adapter categories.

[Browsable(false)]
public virtual MessageAdapterCategories Categories { get; }

Property Value

MessageAdapterCategories

CheckTimeFrameByRequest

Check possible time-frame by request.

[Browsable(false)]
public virtual bool CheckTimeFrameByRequest { get; set; }

Property Value

bool

EnqueueSubscriptions

Enqueue subscriptions.

[Display(ResourceType = typeof(LocalizedStrings), Name = "EnqueueSubscriptions", Description = "EnqueueSubscriptionsDesc", GroupName = "Adapters", Order = 301)]
public virtual bool EnqueueSubscriptions { get; set; }

Property Value

bool

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

bool

FeatureName

Feature name.

[Browsable(false)]
public virtual string FeatureName { get; }

Property Value

string

GenerateOrderBookFromLevel1

[Display(ResourceType = typeof(LocalizedStrings), Name = "Level1", Description = "Level1ToOrderBooks", GroupName = "Adapters", Order = 302)]
public virtual bool GenerateOrderBookFromLevel1 { get; set; }

Property Value

bool

HeartbeatBeforConnect

Start sending TimeMessage before connection established.

[Browsable(false)]
public virtual bool HeartbeatBeforConnect { get; }

Property Value

bool

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

TimeSpan

Icon

Icon.

[Browsable(false)]
public virtual Uri Icon { get; }

Property Value

Uri

IsAutoReplyOnTransactonalUnsubscription

Send auto response for OrderStatusMessage and PortfolioLookupMessage unsubscribes.

[Browsable(false)]
public virtual bool IsAutoReplyOnTransactonalUnsubscription { get; }

Property Value

bool

IsFullCandlesOnly

Translates CandleMessage as only fully filled.

[Browsable(false)]
public virtual bool IsFullCandlesOnly { get; }

Property Value

bool

IsNativeIdentifiers

Identify security in messages by native identifier Native.

[Browsable(false)]
public virtual bool IsNativeIdentifiers { get; }

Property Value

bool

IsNativeIdentifiersPersistable

Native identifier can be stored.

[Browsable(false)]
public virtual bool IsNativeIdentifiersPersistable { get; }

Property Value

bool

IsPositionsEmulationRequired

Adapter required emulation PositionChangeMessage.

[Browsable(false)]
public virtual bool? IsPositionsEmulationRequired { get; }

Property Value

bool?

Remarks

null means no emulatior, true by order balance, false by trades.

IsReplaceCommandEditCurrent

Is the OrderReplaceMessage command edit a current order.

[Browsable(false)]
public virtual bool IsReplaceCommandEditCurrent { get; }

Property Value

bool

IsSecurityNewsOnly

Adapter provides news related with specified security.

[Browsable(false)]
public virtual bool IsSecurityNewsOnly { get; }

Property Value

bool

IsSupportExecutionsPnL

Adapter fills PnL.

[Browsable(false)]
public virtual bool IsSupportExecutionsPnL { get; }

Property Value

bool

IsSupportOrderBookIncrements

Adapter translates incremental order books.

[Browsable(false)]
public virtual bool IsSupportOrderBookIncrements { get; }

Property Value

bool

IsSupportPartialDownloading

Support partial downloading.

[Browsable(false)]
public virtual bool IsSupportPartialDownloading { get; }

Property Value

bool

IsSupportSubscriptions

Support any subscriptions (ticks, order books etc.).

[Browsable(false)]
public virtual bool IsSupportSubscriptions { get; }

Property Value

bool

IsSupportTransactionLog

Adapter translates orders changes on reply of OrderStatusMessage.

[Browsable(false)]
public virtual bool IsSupportTransactionLog { get; }

Property Value

bool

IterationInterval

Interval between iterations.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Iterations", Description = "IterationInterval", GroupName = "Adapters", Order = 304)]
public virtual TimeSpan IterationInterval { get; set; }

Property Value

TimeSpan

LookupTimeout

Lookup timeout.

[Browsable(false)]
public virtual TimeSpan? LookupTimeout { get; }

Property Value

TimeSpan?

Name

The source name.

public override string Name { get; set; }

Property Value

string

OrderConditionType

Type of OrderCondition.

[Browsable(false)]
public virtual Type OrderConditionType { get; }

Property Value

Type

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

Platforms

PossibleSupportedMessages

Possible supported by adapter message types.

[Browsable(false)]
public virtual IEnumerable<MessageTypeInfo> PossibleSupportedMessages { get; set; }

Property Value

IEnumerable<MessageTypeInfo>

ReConnectionSettings

Connection tracking settings IMessageAdapter with a server.

[Display(ResourceType = typeof(LocalizedStrings), Name = "ReConnectionSettings", Description = "ReConnectionDesc", GroupName = "Connection")]
public ReConnectionSettings ReConnectionSettings { get; }

Property Value

ReConnectionSettings

SecurityExtendedFields

Names of extended security fields in SecurityMessage.

[Browsable(false)]
public virtual IEnumerable<Tuple<string, Type>> SecurityExtendedFields { get; }

Property Value

IEnumerable<Tuple<string, Type>>

StorageName

The storage name, associated with the adapter.

[Browsable(false)]
public virtual string StorageName { get; }

Property Value

string

SupportedInMessages

Supported by adapter message types.

[Browsable(false)]
public virtual IEnumerable<MessageTypes> SupportedInMessages { get; set; }

Property Value

IEnumerable<MessageTypes>

SupportedMarketDataTypes

Supported by adapter market data types.

[Browsable(false)]
public virtual IEnumerable<DataType> SupportedMarketDataTypes { get; set; }

Property Value

IEnumerable<DataType>

SupportedOrderBookDepths

Available options for MaxDepth.

[Browsable(false)]
public virtual IEnumerable<int> SupportedOrderBookDepths { get; }

Property Value

IEnumerable<int>

SupportedResultMessages

Supported by adapter result message types.

[Browsable(false)]
public virtual IEnumerable<MessageTypes> SupportedResultMessages { get; set; }

Property Value

IEnumerable<MessageTypes>

TimeFrames

Get possible time-frames for the specified instrument.

protected virtual IEnumerable<TimeSpan> TimeFrames { get; }

Property Value

IEnumerable<TimeSpan>

TransactionIdGenerator

Transaction id generator.

[Browsable(false)]
public IdGenerator TransactionIdGenerator { get; set; }

Property Value

IdGenerator

UseChannels

Use channels for in and out messages.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Channels", Description = "UseChannels", GroupName = "Adapters", Order = 303)]
public virtual bool UseChannels { get; set; }

Property Value

bool

Methods

Clone()

Create a copy of MessageAdapter.

public virtual IMessageChannel Clone()

Returns

IMessageChannel

Copy.

CreateOrderLogMarketDepthBuilder(SecurityId)

Create market depth builder.

public virtual IOrderLogMarketDepthBuilder CreateOrderLogMarketDepthBuilder(SecurityId securityId)

Parameters

securityId SecurityId

Security ID.

Returns

IOrderLogMarketDepthBuilder

Order log to market depth builder.

GetCandleArgs(Type, SecurityId, DateTimeOffset?, DateTimeOffset?)

Get possible args for the specified candle type and instrument.

public virtual IEnumerable<object> GetCandleArgs(Type candleType, SecurityId securityId, DateTimeOffset? from, DateTimeOffset? to)

Parameters

candleType Type

The type of the message CandleMessage.

securityId SecurityId

Security ID.

from DateTimeOffset?

The initial date from which you need to get data.

to DateTimeOffset?

The final date by which you need to get data.

Returns

IEnumerable<object>

Possible args.

GetHistoryStepSize(SecurityId, DataType, out TimeSpan)

Get maximum size step allowed for historical download.

public virtual TimeSpan GetHistoryStepSize(SecurityId securityId, DataType dataType, out TimeSpan iterationInterval)

Parameters

securityId SecurityId

SecurityId

dataType DataType

Data type info.

iterationInterval TimeSpan

Interval between iterations.

Returns

TimeSpan

Step.

GetMaxCount(DataType)

Get maximum possible items count per single subscription request.

public virtual int? GetMaxCount(DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

int?

Max items count.

GetSupportedDataTypes(SecurityId)

Get supported data types for the specified SecurityId.

public virtual IEnumerable<DataType> GetSupportedDataTypes(SecurityId securityId)

Parameters

securityId SecurityId

SecurityId

Returns

IEnumerable<DataType>

Supported data types.

GetTimeFrames(SecurityId, DateTimeOffset?, DateTimeOffset?)

Get possible time-frames for the specified instrument.

[Obsolete("Use GetCandleArgs method.")]
protected virtual IEnumerable<TimeSpan> GetTimeFrames(SecurityId securityId, DateTimeOffset? from, DateTimeOffset? to)

Parameters

securityId SecurityId

Security ID.

from DateTimeOffset?

The initial date from which you need to get data.

to DateTimeOffset?

The final date by which you need to get data.

Returns

IEnumerable<TimeSpan>

Possible time-frames.

IsAllDownloadingSupported(DataType)

Is for the specified dataType all securities downloading enabled.

public virtual bool IsAllDownloadingSupported(DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

bool

Check result.

IsSecurityRequired(DataType)

Support filtering subscriptions (subscribe/unsubscribe for specified security).

public virtual bool IsSecurityRequired(DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

bool

Check result.

IsSupportCandlesPriceLevels(MarketDataMessage)

Support candles PriceLevels.

public virtual bool IsSupportCandlesPriceLevels(MarketDataMessage subscription)

Parameters

subscription MarketDataMessage

MarketDataMessage

Returns

bool

Check result.

IsSupportCandlesUpdates(MarketDataMessage)

Support candles subscription and live updates.

public virtual bool IsSupportCandlesUpdates(MarketDataMessage subscription)

Parameters

subscription MarketDataMessage

MarketDataMessage

Returns

bool

Check result.

Load(SettingsStorage)

Load settings.

public override void Load(SettingsStorage storage)

Parameters

storage SettingsStorage

Settings storage.

OnPropertyChanged(string)

Raise PropertyChanged event.

protected void OnPropertyChanged(string propertyName = null)

Parameters

propertyName string

The name of the property that changed.

OnSendInMessage(Message)

Send message.

protected abstract bool OnSendInMessage(Message message)

Parameters

message Message

Message.

Returns

bool

true if the specified message was processed successfully, otherwise, false.

Save(SettingsStorage)

Save settings.

public override void Save(SettingsStorage storage)

Parameters

storage SettingsStorage

Settings storage.

SendInMessage(Message)

Send message.

public bool SendInMessage(Message message)

Parameters

message Message

Message.

Returns

bool

true if the specified message was processed successfully, otherwise, false.

SendOutDisconnectMessage(bool)

Send to SendOutMessage(Message) disconnect message.

protected void SendOutDisconnectMessage(bool expected)

Parameters

expected bool

Is disconnect expected.

SendOutDisconnectMessage(Exception)

Send to SendOutMessage(Message) disconnect message.

protected void SendOutDisconnectMessage(Exception error)

Parameters

error Exception

Error info. Can be null.

SendOutError(Exception)

Initialize a new message ErrorMessage and pass it to the method SendOutMessage(Message).

protected void SendOutError(Exception error)

Parameters

error Exception

Error details.

SendOutError(string)

Initialize a new message ErrorMessage and pass it to the method SendOutMessage(Message).

protected void SendOutError(string description)

Parameters

description string

Error details.

SendOutMessage(Message)

Send outgoing message and raise NewOutMessage event.

protected virtual void SendOutMessage(Message message)

Parameters

message Message

Message.

SendSubscriptionFinished(long, DateTimeOffset?)

Initialize a new message SubscriptionFinishedMessage and pass it to the method SendOutMessage(Message).

protected void SendSubscriptionFinished(long originalTransactionId, DateTimeOffset? nextFrom = null)

Parameters

originalTransactionId long

ID of the original message for which this message is a response.

nextFrom DateTimeOffset?

NextFrom.

SendSubscriptionNotSupported(long)

Initialize a new message SubscriptionResponseMessage and pass it to the method SendOutMessage(Message).

protected void SendSubscriptionNotSupported(long originalTransactionId)

Parameters

originalTransactionId long

ID of the original message for which this message is a response.

SendSubscriptionOnline(long)

Initialize a new message SubscriptionOnlineMessage and pass it to the method SendOutMessage(Message).

protected void SendSubscriptionOnline(long originalTransactionId)

Parameters

originalTransactionId long

ID of the original message for which this message is a response.

SendSubscriptionReply(long, Exception)

Initialize a new message SubscriptionResponseMessage and pass it to the method SendOutMessage(Message).

protected void SendSubscriptionReply(long originalTransactionId, Exception error = null)

Parameters

originalTransactionId long

ID of the original message for which this message is a response.

error Exception

Subscribe or unsubscribe error info. To be set if the answer.

SendSubscriptionResult(ISubscriptionMessage)

Initialize a new message SubscriptionOnlineMessage or SubscriptionFinishedMessage and pass it to the method SendOutMessage(Message).

protected void SendSubscriptionResult(ISubscriptionMessage message)

Parameters

message ISubscriptionMessage

Subscription.

ValidateSecurityId(SecurityId)

Validate the specified security id is supported by the adapter and subscription can be done.

protected virtual bool ValidateSecurityId(SecurityId secId)

Parameters

secId SecurityId

SecurityId.

Returns

bool

Check result.

Events

NewOutMessage

New message event.

public event Action<Message> NewOutMessage

Event Type

Action<Message>