Table of Contents

Class BaseFixDialect

Namespace
StockSharp.Fix.Dialects
Assembly
StockSharp.Fix.Core.dll

Base class describing the dialect of the FIX protocol.

public abstract class BaseFixDialect : BaseLogReceiver, IFixDialect, IMessageAdapter, IMessageChannel, ICloneable<IMessageChannel>, ICloneable, IPersistable, ILogReceiver, ILogSource, IDisposable, IDemoAdapter
Inheritance
BaseFixDialect
Implements
ICloneable<IMessageChannel>
IPersistable
Derived
Inherited Members
Extension Methods

Constructors

BaseFixDialect(IdGenerator, Encoding, string, FixFormats)

Initialize BaseFixDialect.

protected BaseFixDialect(IdGenerator transactionIdGenerator, Encoding encoding, string version = "FIX.4.4", FixFormats format = FixFormats.Text)

Parameters

transactionIdGenerator IdGenerator

Transaction id generator.

encoding Encoding

Encoding.

version string

FIX version.

format FixFormats

FIX protocol format.

Properties

Accounts

Accounts associated with FIX login.

public string Accounts { get; set; }

Property Value

string

Address

Server address.

protected EndPoint Address { get; }

Property Value

EndPoint

AssociatedBoards

The adapter can process subscription only with instruments associated with the specified board.

public string[] AssociatedBoards { get; }

Property Value

string[]

CancelOnDisconnect

Cancel On Disconnect.

public virtual bool CancelOnDisconnect { get; set; }

Property Value

bool

CandlesBuildFrom

Possible options for candles building.

public virtual IEnumerable<Level1Fields> CandlesBuildFrom { get; }

Property Value

IEnumerable<Level1Fields>

Categories

Message adapter categories.

public virtual MessageAdapterCategories Categories { get; }

Property Value

MessageAdapterCategories

CheckTimeFrameByRequest

Check possible time-frame by request.

public virtual bool CheckTimeFrameByRequest { get; }

Property Value

bool

ClientCode

Client code assigned by the broker.

public string ClientCode { get; set; }

Property Value

string

ClientVersion

Client app version.

public string ClientVersion { get; set; }

Property Value

string

CurrentCounter

Counter.

public virtual long CurrentCounter { get; set; }

Property Value

long

DateParser

Date parser.

public FastDateTimeParser DateParser { get; set; }

Property Value

FastDateTimeParser

DoNotSendAccount

Do not send Account.

public bool DoNotSendAccount { get; set; }

Property Value

bool

Encoding

Encoding.

public Encoding Encoding { get; set; }

Property Value

Encoding

EnqueueSubscriptions

Enqueue subscriptions.

public virtual bool EnqueueSubscriptions { get; set; }

Property Value

bool

Remarks

Do not send new request before received confirmation for previous.

ExchangeBoard

Board, where securities are traded.

public string ExchangeBoard { get; set; }

Property Value

string

ExtraSetup

The adapter requires extra setup.

public virtual bool ExtraSetup { get; }

Property Value

bool

FeatureName

Feature name.

public virtual string FeatureName { get; }

Property Value

string

Format

FIX protocol format.

public FixFormats Format { get; }

Property Value

FixFormats

GenerateOrderBookFromLevel1

public virtual bool GenerateOrderBookFromLevel1 { get; set; }

Property Value

bool

HeartbeatBeforConnect

Start sending TimeMessage before connection established.

public virtual bool HeartbeatBeforConnect { get; }

Property Value

bool

HeartbeatInterval

Server check interval for track the connection alive. The value is Zero turned off tracking.

public TimeSpan HeartbeatInterval { get; set; }

Property Value

TimeSpan

Icon

Icon.

public virtual Uri Icon { get; }

Property Value

Uri

IsAutoReplyOnTransactonalUnsubscription

Send auto response for OrderStatusMessage and PortfolioLookupMessage unsubscribes.

public virtual bool IsAutoReplyOnTransactonalUnsubscription { get; }

Property Value

bool

IsDemo

Connect to demo trading instead of real trading server.

public bool IsDemo { get; set; }

Property Value

bool

IsFullCandlesOnly

Translates CandleMessage as only fully filled.

public virtual bool IsFullCandlesOnly { get; }

Property Value

bool

IsNativeIdentifiers

Identify security in messages by native identifier Native.

public virtual bool IsNativeIdentifiers { get; }

Property Value

bool

IsNativeIdentifiersPersistable

Native identifier can be stored.

public virtual bool IsNativeIdentifiersPersistable { get; }

Property Value

bool

IsPositionsEmulationRequired

Adapter required emulation PositionChangeMessage.

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.

public virtual bool IsReplaceCommandEditCurrent { get; }

Property Value

bool

IsResetCounter

Should the sequence counter be reset.

public bool IsResetCounter { get; set; }

Property Value

bool

IsSecurityNewsOnly

Adapter provides news related with specified security.

public virtual bool IsSecurityNewsOnly { get; }

Property Value

bool

IsSupportExecutionsPnL

Adapter fills PnL.

public virtual bool IsSupportExecutionsPnL { get; }

Property Value

bool

IsSupportMarketDataResponse

Support market-data response.

protected virtual bool IsSupportMarketDataResponse { get; }

Property Value

bool

IsSupportOrderBookIncrements

Adapter translates incremental order books.

public virtual bool IsSupportOrderBookIncrements { get; }

Property Value

bool

IsSupportPartialDownloading

Support partial downloading.

public virtual bool IsSupportPartialDownloading { get; }

Property Value

bool

IsSupportSubscriptions

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

public virtual bool IsSupportSubscriptions { get; }

Property Value

bool

IsSupportTransactionLog

Adapter translates orders changes on reply of OrderStatusMessage.

public virtual bool IsSupportTransactionLog { get; }

Property Value

bool

IterationInterval

Interval between iterations.

public virtual TimeSpan IterationInterval { get; }

Property Value

TimeSpan

LastResendRequest

protected long LastResendRequest { get; }

Property Value

long

Login

Login.

public string Login { get; set; }

Property Value

string

LoginAsPortfolioName

Use Login as portfolio name.

protected virtual bool LoginAsPortfolioName { get; }

Property Value

bool

LookupTimeout

Lookup timeout.

public virtual TimeSpan? LookupTimeout { get; }

Property Value

TimeSpan?

NewOrderSingleErrorsAsReject

Reply errors for messages of type NewOrderSingle transfers via Reject.

protected virtual bool NewOrderSingleErrorsAsReject { get; }

Property Value

bool

OrderConditionType

Type of OrderCondition.

public virtual Type OrderConditionType { get; }

Property Value

Type

Remarks

If the connection does not support the order type Conditional, it will be returned null.

OverrideExecIdByNative

Override ExecId by native identifier (if present in FIX message).

public bool OverrideExecIdByNative { get; set; }

Property Value

bool

Password

Password.

public SecureString Password { get; set; }

Property Value

SecureString

PossibleSupportedMessages

Possible supported by adapter message types.

public virtual IEnumerable<MessageTypeInfo> PossibleSupportedMessages { get; }

Property Value

IEnumerable<MessageTypeInfo>

QuotesAsLevel1

Translate quote data as Level1ChangeMessage or QuoteChangeMessage.

public bool QuotesAsLevel1 { get; set; }

Property Value

bool

ReConnectionSettings

Connection tracking settings IMessageAdapter with a server.

public ReConnectionSettings ReConnectionSettings { get; }

Property Value

ReConnectionSettings

SecurityExtendedFields

Names of extended security fields in SecurityMessage.

public virtual IEnumerable<Tuple<string, Type>> SecurityExtendedFields { get; }

Property Value

IEnumerable<Tuple<string, Type>>

SenderCompId

Sender ID.

public string SenderCompId { get; set; }

Property Value

string

State

State.

public virtual ChannelStates State { get; }

Property Value

ChannelStates

StorageName

The storage name, associated with the adapter.

public virtual string StorageName { get; }

Property Value

string

SupportLicensing

Support of licensing features.

public virtual bool SupportLicensing { get; }

Property Value

bool

SupportUnknownExecutions

Support executions processing, generated by third-party software.

public virtual bool SupportUnknownExecutions { get; set; }

Property Value

bool

SupportedInMessages

Supported by adapter message types.

public virtual IEnumerable<MessageTypes> SupportedInMessages { get; set; }

Property Value

IEnumerable<MessageTypes>

SupportedMarketDataTypes

Supported by adapter market data types.

public virtual IEnumerable<DataType> SupportedMarketDataTypes { get; set; }

Property Value

IEnumerable<DataType>

SupportedOrderBookDepths

Available options for MaxDepth.

public virtual IEnumerable<int> SupportedOrderBookDepths { get; }

Property Value

IEnumerable<int>

SupportedResultMessages

Supported by adapter result message types.

public virtual IEnumerable<MessageTypes> SupportedResultMessages { get; set; }

Property Value

IEnumerable<MessageTypes>

TargetCompId

Target ID.

public string TargetCompId { get; set; }

Property Value

string

TickAsLevel1

Translate tick data as Level1ChangeMessage or ExecutionMessage.

public bool TickAsLevel1 { get; set; }

Property Value

bool

TimeFrames

Possible time-frames.

protected virtual IEnumerable<TimeSpan> TimeFrames { get; }

Property Value

IEnumerable<TimeSpan>

TimeParser

Time parser.

public FastTimeSpanParser TimeParser { get; set; }

Property Value

FastTimeSpanParser

TimeStampParser

Time stamp parser.

public FastDateTimeParser TimeStampParser { get; set; }

Property Value

FastDateTimeParser

TimeZone

Information about the time zone where the exchange is located.

public TimeZoneInfo TimeZone { get; set; }

Property Value

TimeZoneInfo

TransactionIdGenerator

Transaction id generator.

public virtual IdGenerator TransactionIdGenerator { get; }

Property Value

IdGenerator

UseChannels

Use channels for in and out messages.

public virtual bool UseChannels { get; }

Property Value

bool

Version

FIX version.

public string Version { get; }

Property Value

string

YearMonthParser

Year and month parser.

public FastDateTimeParser YearMonthParser { get; set; }

Property Value

FastDateTimeParser

Methods

ApplyTimeInForce(ExecutionReport, ExecutionMessage, bool)

Apply time in force.

protected virtual bool ApplyTimeInForce(ExecutionReport report, ExecutionMessage msg, bool throwInvalid = true)

Parameters

report ExecutionReport
msg ExecutionMessage
throwInvalid bool

Returns

bool

CheckState()

Check state before connect.

protected virtual void CheckState()

Clone()

public virtual IMessageChannel Clone()

Returns

IMessageChannel

Close()

Close channel.

public virtual void Close()

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.

FromSecurityTradingStatus(int?)

protected virtual SecurityStates? FromSecurityTradingStatus(int? status)

Parameters

status int?

SecurityTradingStatus value.

Returns

SecurityStates?

SecurityStates value.

GetBoardCode(string, string, string)

Get board code.

protected virtual string GetBoardCode(string destination, string exchange, string tradingSession)

Parameters

destination string

ExDestination.

exchange string

SecurityGroup.

tradingSession string

TradingSessionID.

Returns

string

Board code.

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

Get possible args for the specified candle type and instrument.

public 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.

GetExecutionTime(ExecutionReport)

Get execution time.

protected virtual DateTimeOffset GetExecutionTime(ExecutionReport report)

Parameters

report ExecutionReport

Returns

DateTimeOffset

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.

GetOrderState(ExecutionReport)

Convert OrdStatus to OrderStates value.

protected virtual OrderStates? GetOrderState(ExecutionReport report)

Parameters

report ExecutionReport

ExecutionReport value.

Returns

OrderStates?

OrderStates value.

GetOrderStringId(string)

protected virtual string GetOrderStringId(string orderId)

Parameters

orderId string

OrderStringId value.

Returns

string

OrderStringId value.

GetOrderType(ExecutionReport, out OrderCondition)

Get order type.

protected virtual OrderTypes GetOrderType(ExecutionReport report, out OrderCondition condition)

Parameters

report ExecutionReport

Execution report.

condition OrderCondition

Base order condition (for example, for stop order algo orders).

Returns

OrderTypes

Order type.

GetSecurityType(string)

Convert string to SecurityTypes value.

protected virtual SecurityTypes? GetSecurityType(string type)

Parameters

type string

string value.

Returns

SecurityTypes?

SecurityTypes value.

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.

GetSyntheticPortfolioName()

Get synthetic portfolio name for LoginAsPortfolioName mode.

protected string GetSyntheticPortfolioName()

Returns

string

Portfolio code name.

InitSecId(SecurityMessage, string, string, string, string)

Init security id information.

protected virtual void InitSecId(SecurityMessage message, string symbol, string securityExchange, string idSource, string idValue)

Parameters

message SecurityMessage

A message containing info about the security.

symbol string

Symbol.

securityExchange string

Security exchange.

idSource string

Id source.

idValue string

Id value.

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.

IsLogoutError(string)

Check Logout contains error message.

protected virtual bool IsLogoutError(string text)

Parameters

text string

Text message.

Returns

bool

true if the specified text contains error message, otherwise, false.

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.

IsSyntheticPortfolioName(string)

Is the specified portfolio name generated by GetSyntheticPortfolioName().

protected bool IsSyntheticPortfolioName(string portfolioName)

Parameters

portfolioName string

Portfolio code name.

Returns

bool

Check result.

OnRead(IFixReader, string, Action<Message>)

Read next message from FIX protocol.

protected virtual bool? OnRead(IFixReader reader, string msgType, Action<Message> messageHandler)

Parameters

reader IFixReader

The reader of data recorded in the FIX protocol format.

msgType string

Message type.

messageHandler Action<Message>

Message handler.

Returns

bool?

true, if the messages was read successfully, false to skip unknown message, null to break connection.

OnReset()

Reset state.

protected virtual void OnReset()

OnWrite(IFixWriter, Message)

Write the specified message into FIX protocol.

protected virtual string OnWrite(IFixWriter writer, Message message)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

message Message

The message.

Returns

string

FixMessages value.

Open()

Open channel.

public virtual void Open()

ProcessExecutionReport(ExecutionReport, Action<Message>, ExecutionMessage)

Process ExecutionReport instance.

protected virtual void ProcessExecutionReport(ExecutionReport report, Action<Message> messageHandler, ExecutionMessage message)

Parameters

report ExecutionReport

ExecutionReport instance.

messageHandler Action<Message>

Message handler.

message ExecutionMessage

The message contains information about the execution.

ProcessExecutionReport(ExecutionReport, Action<Message>, Action<ExecutionReport, Action<Message>, ExecutionMessage>)

Process ExecutionReport instance.

protected virtual void ProcessExecutionReport(ExecutionReport report, Action<Message> messageHandler, Action<ExecutionReport, Action<Message>, ExecutionMessage> processExecMsg)

Parameters

report ExecutionReport

ExecutionReport instance.

messageHandler Action<Message>

Message handler.

processExecMsg Action<ExecutionReport, Action<Message>, ExecutionMessage>

Post handle an ExecutionMessage instance.

ProcessExecutionReportExtraTag(FixTags, IFixReader, ExecutionReport)

Process extra tags for ExecutionReport.

protected virtual bool ProcessExecutionReportExtraTag(FixTags tag, IFixReader reader, ExecutionReport report)

Parameters

tag FixTags

Tag.

reader IFixReader

The reader of data recorded in the FIX protocol format.

report ExecutionReport

Execution report.

Returns

bool

Result.

ProcessParties(ExecutionReport)

Process Parties.

protected virtual void ProcessParties(ExecutionReport report)

Parameters

report ExecutionReport

Execution report.

ProcessSecurityDefinition(FixTags, IFixReader, SecurityMessage)

Process SecurityDefinition message.

protected virtual bool ProcessSecurityDefinition(FixTags tag, IFixReader reader, SecurityMessage message)

Parameters

tag FixTags

Tag.

reader IFixReader

The reader of data recorded in the FIX protocol format.

message SecurityMessage

A message containing info about the security.

Returns

bool

Processing result.

ProcessSequenceResetExtraTag(FixTags, IFixReader, FixSeqResetMessage)

Process extra tags for FixSeqResetMessage.

protected virtual bool ProcessSequenceResetExtraTag(FixTags tag, IFixReader reader, FixSeqResetMessage message)

Parameters

tag FixTags

Tag.

reader IFixReader

The reader of data recorded in the FIX protocol format.

message FixSeqResetMessage

Sequence reset message.

Returns

bool

Result.

RaiseNewOutMessage(Message)

protected void RaiseNewOutMessage(Message message)

Parameters

message Message

Message.

ReadExecutionReport(IFixReader, ExecutionReport, FastDateTimeParser, Func<FixTags, IFixReader, ExecutionReport, bool>)

Read the ExecutionReport message.

protected virtual bool? ReadExecutionReport(IFixReader reader, ExecutionReport report, FastDateTimeParser transactTimeParser, Func<FixTags, IFixReader, ExecutionReport, bool> extraTagProcess)

Parameters

reader IFixReader

The reader of data recorded in the FIX protocol format.

report ExecutionReport

ExecutionReport instance.

transactTimeParser FastDateTimeParser

Parser for TransactTime field.

extraTagProcess Func<FixTags, IFixReader, ExecutionReport, bool>

Returns

bool?

true, if the messages was read successfully, false to skip unknown message, null to break connection.

SendInMessage(Message)

Send message.

public virtual bool SendInMessage(Message message)

Parameters

message Message

Message.

Returns

bool

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

ToString()

public override string ToString()

Returns

string

TryParseNextMsqSeqNum(string)

Try extract expected MsgSeqNum from the specified error message.

public virtual long? TryParseNextMsqSeqNum(string errorMessage)

Parameters

errorMessage string

Error message.

Returns

long?

MsgSeqNum or null.

WriteAccount(IFixWriter, IPortfolioNameMessage)

Write Account value.

protected void WriteAccount(IFixWriter writer, IPortfolioNameMessage message)

Parameters

writer IFixWriter

Writer.

message IPortfolioNameMessage

Message.

WriteClOrdId(IFixWriter, long)

Write ClOrdID.

protected void WriteClOrdId(IFixWriter writer, long transactionId)

Parameters

writer IFixWriter

Writer.

transactionId long

Transaction ID.

WriteLogonRequest(IFixWriter, ConnectMessage, Action<IFixWriter>)

To record the Logon message (request).

protected string WriteLogonRequest(IFixWriter writer, ConnectMessage message, Action<IFixWriter> extra = null)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

message ConnectMessage

ConnectMessage.

extra Action<IFixWriter>

Write extra parameters for Logon message.

Returns

string

FixMessages value.

WriteLogoutRequest(IFixWriter, string)

To record the Logout message (request).

protected static string WriteLogoutRequest(IFixWriter writer, string text = null)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

text string

The text of reason.

Returns

string

FixMessages value.

WriteResendRequest(IFixWriter, long, long)

To record the ResendRequest message.

protected static string WriteResendRequest(IFixWriter writer, long beginSeqNo, long endSeqNo)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

beginSeqNo long

The original message identifier.

endSeqNo long

The last message identifier.

Returns

string

FixMessages value.

WriteSequenceReset(IFixWriter, bool, long)

To record the SequenceReset message (request).

protected string WriteSequenceReset(IFixWriter writer, bool gapFill, long newSeqNo)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

gapFill bool

Gap fill.

newSeqNo long

New sequence number.

Returns

string

FixMessages value.

WriteTimeMessage(IFixWriter, TimeMessage)

To record the Heartbeat or TestRequest message.

protected static string WriteTimeMessage(IFixWriter writer, TimeMessage timeMsg)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

timeMsg TimeMessage

Heartbeat message.

Returns

string

FixMessages value.

WriteUserRequestChangePassword(IFixWriter, ChangePasswordMessage, string, string)

To record the UserRequest message.

protected string WriteUserRequestChangePassword(IFixWriter writer, ChangePasswordMessage message, string userName = null, string password = null)

Parameters

writer IFixWriter

The recorder of data in the FIX protocol format.

message ChangePasswordMessage

Password change message.

userName string

Current user name.

password string

Current password.

Returns

string

FixMessages value.