Table of Contents

Class Extensions

Namespace
StockSharp.Messages
Assembly
StockSharp.Messages.dll

Extension class.

public static class Extensions
Inheritance
Extensions
Inherited Members

Fields

AllSecurityId

"All securities" id.

public static readonly string AllSecurityId

Field Value

string

AnonymousPortfolioName

Anonymous account.

public const string AnonymousPortfolioName = "Anonymous_SS"

Field Value

string

AnyDepths

Special set mean any depth for SupportedOrderBookDepths option.

public static readonly IEnumerable<int> AnyDepths

Field Value

IEnumerable<int>

LookupAllCriteriaMessage

Lookup all securities predefined criteria.

public static readonly SecurityLookupMessage LookupAllCriteriaMessage

Field Value

SecurityLookupMessage

NewsStockSharpSource

StockSharp news source.

public const string NewsStockSharpSource = "StockSharp"

Field Value

string

SimulatorPortfolioName

Simulator.

public const string SimulatorPortfolioName = "Simulator_SS"

Field Value

string

Today

Constant value for TillDate means Today(=Session).

public static readonly DateTimeOffset Today

Field Value

DateTimeOffset

Properties

AllCandleTypes

All registered candle types.

public static IEnumerable<Type> AllCandleTypes { get; }

Property Value

IEnumerable<Type>

AllSecurity

"All securities" instance.

public static SecurityMessage AllSecurity { get; }

Property Value

SecurityMessage

BestAskFields

Fields related to best ask.

public static CachedSynchronizedSet<Level1Fields> BestAskFields { get; }

Property Value

CachedSynchronizedSet<Level1Fields>

BestBidFields

Fields related to best bid.

public static CachedSynchronizedSet<Level1Fields> BestBidFields { get; }

Property Value

CachedSynchronizedSet<Level1Fields>

LastTradeFields

Fields related to last trade.

public static CachedSynchronizedSet<Level1Fields> LastTradeFields { get; }

Property Value

CachedSynchronizedSet<Level1Fields>

MarketDataMessageTypes

Market-data message types.

public static IEnumerable<MessageTypes> MarketDataMessageTypes { get; }

Property Value

IEnumerable<MessageTypes>

TransactionalMessageTypes

Transactional message types.

public static IEnumerable<MessageTypes> TransactionalMessageTypes { get; }

Property Value

IEnumerable<MessageTypes>

Methods

AddDelta(IOrderBookMessage, IOrderBookMessage)

To add change to the first order book.

public static QuoteChangeMessage AddDelta(this IOrderBookMessage from, IOrderBookMessage delta)

Parameters

from IOrderBookMessage

First order book.

delta IOrderBookMessage

Change.

Returns

QuoteChangeMessage

The changed order book.

AddDelta(IEnumerable<QuoteChange>, IEnumerable<QuoteChange>, bool)

To add change to quote.

public static QuoteChange[] AddDelta(this IEnumerable<QuoteChange> fromQuotes, IEnumerable<QuoteChange> deltaQuotes, bool isBids)

Parameters

fromQuotes IEnumerable<QuoteChange>

Quotes.

deltaQuotes IEnumerable<QuoteChange>

Changes.

isBids bool

The indication of quotes direction.

Returns

QuoteChange[]

Changed quotes.

AddMarketDataSupport(MessageAdapter)

Fill the SupportedInMessages message types related to market-data.

public static void AddMarketDataSupport(this MessageAdapter adapter)

Parameters

adapter MessageAdapter

Adapter.

AddOrSubtractTradingDays(BoardMessage, DateTimeOffset, int, bool)

To get date of day T +/- of N trading days.

public static DateTimeOffset AddOrSubtractTradingDays(this BoardMessage board, DateTimeOffset date, int n, bool checkHolidays = true)

Parameters

board BoardMessage

Board info.

date DateTimeOffset

The start T date, to which are added or subtracted N trading days.

n int

The N size. The number of trading days for the addition or subtraction.

checkHolidays bool

Whether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).

Returns

DateTimeOffset

The end T +/- N date.

AddSupportedMarketDataType(MessageAdapter, DataType)

Add market data type into SupportedMarketDataTypes.

public static void AddSupportedMarketDataType(this MessageAdapter adapter, DataType dataType)

Parameters

adapter MessageAdapter

Adapter.

dataType DataType

Data type info.

AddSupportedMessage(MessageAdapter, MessageTypeInfo)

Add the message type info PossibleSupportedMessages.

public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypeInfo info)

Parameters

adapter MessageAdapter

Adapter.

info MessageTypeInfo

Extended info for MessageTypes.

AddSupportedMessage(MessageAdapter, MessageTypes)

Add the message type info SupportedInMessages.

[Obsolete]
public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypes type)

Parameters

adapter MessageAdapter

Adapter.

type MessageTypes

Message type.

AddSupportedMessage(MessageAdapter, MessageTypes, bool?)

Add the message type info SupportedInMessages.

public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypes type, bool? isMarketData)

Parameters

adapter MessageAdapter

Adapter.

type MessageTypes

Message type.

isMarketData bool?

type is market-data type.

AddSupportedResultMessage(MessageAdapter, MessageTypes)

Add the message type info SupportedResultMessages.

public static void AddSupportedResultMessage(this MessageAdapter adapter, MessageTypes type)

Parameters

adapter MessageAdapter

Adapter.

type MessageTypes

Message type.

AddTransactionalSupport(MessageAdapter)

Fill the SupportedInMessages message types related to transactional.

public static void AddTransactionalSupport(this MessageAdapter adapter)

Parameters

adapter MessageAdapter

Adapter.

Add<TMessage, TChange>(TMessage, TChange, CurrencyTypes)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, CurrencyTypes value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value CurrencyTypes

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, PortfolioStates)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, PortfolioStates value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value PortfolioStates

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, SecurityStates)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, SecurityStates value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value SecurityStates

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, Sides)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, Sides value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value Sides

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, bool)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, bool value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value bool

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, DateTimeOffset)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, DateTimeOffset value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value DateTimeOffset

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, decimal)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, decimal value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value decimal

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, int)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, int value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value int

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, long)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, long value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value long

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

Add<TMessage, TChange>(TMessage, TChange, object)

Add change into collection.

public static TMessage Add<TMessage, TChange>(this TMessage message, TChange type, object value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value object

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

ApplyNewBalance(decimal?, decimal, long, ILogReceiver)

Check the possibility Balance change.

public static decimal ApplyNewBalance(this decimal? currBal, decimal newBal, long transactionId, ILogReceiver logs)

Parameters

currBal decimal?

Current balance.

newBal decimal

New balance.

transactionId long

Transaction id.

logs ILogReceiver

Logs.

Returns

decimal

New balance.

BuildIfNeed(IEnumerable<QuoteChangeMessage>, ILogReceiver)

Try build books by OrderBookIncrementBuilder in case of books is incremental changes.

public static IEnumerable<QuoteChangeMessage> BuildIfNeed(this IEnumerable<QuoteChangeMessage> books, ILogReceiver logs = null)

Parameters

books IEnumerable<QuoteChangeMessage>

Order books.

logs ILogReceiver

Logs.

Returns

IEnumerable<QuoteChangeMessage>

Order books.

ChangeSupported(IMessageAdapter, bool, bool)

public static void ChangeSupported(this IMessageAdapter adapter, bool add, bool isMarketData)

Parameters

adapter IMessageAdapter

Adapter.

add bool

Command.

isMarketData bool

Message types.

CreateAdapter(Type)

Create IMessageAdapter instance.

public static IMessageAdapter CreateAdapter(this Type adapterType)

Parameters

adapterType Type

Adapter type.

Returns

IMessageAdapter

IMessageAdapter instance.

CreateAdapter(Type, IdGenerator)

public static IMessageAdapter CreateAdapter(this Type adapterType, IdGenerator idGenerator)

Parameters

adapterType Type

Adapter type.

idGenerator IdGenerator

Transaction id generator.

Returns

IMessageAdapter

IMessageAdapter instance.

CreateErrorResponse(Message, Exception, ILogReceiver, Func<DataType, long[]>)

Create error response.

public static Message CreateErrorResponse(this Message message, Exception ex, ILogReceiver logs, Func<DataType, long[]> getSubscribers = null)

Parameters

message Message

Original message.

ex Exception

Error.

logs ILogReceiver

Logs.

getSubscribers Func<DataType, long[]>

Subscriber identifiers provider.

Returns

Message

Error response.

CreateNotSupported(long)

Create non supported subscription response.

public static SubscriptionResponseMessage CreateNotSupported(this long id)

Parameters

id long

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

Returns

SubscriptionResponseMessage

Subscription response message.

CreateOrderCondition(IMessageAdapter)

Create condition for order type Conditional, that supports the adapter.

public static OrderCondition CreateOrderCondition(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

OrderCondition

Order condition.

Remarks

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

CreateOrderCondition(Type)

Create condition for order type Conditional, that supports the adapter.

public static OrderCondition CreateOrderCondition(this Type orderConditionType)

Parameters

orderConditionType Type

Type of OrderCondition.

Returns

OrderCondition

Order condition.

CreateOrderLogMarketDepthBuilder(Type, SecurityId)

Create IOrderLogMarketDepthBuilder instance.

public static IOrderLogMarketDepthBuilder CreateOrderLogMarketDepthBuilder(this Type builderType, SecurityId securityId)

Parameters

builderType Type

Builder type.

securityId SecurityId

Security ID.

Returns

IOrderLogMarketDepthBuilder

IOrderLogMarketDepthBuilder instance.

CreateOrderReply(long, DateTimeOffset)

Create order's transaction reply.

public static ExecutionMessage CreateOrderReply(this long transactionId, DateTimeOffset serverTime)

Parameters

transactionId long

Transaction ID.

serverTime DateTimeOffset

Server time.

Returns

ExecutionMessage

The message contains information about the execution.

CreatePortfolioChangeMessage(IMessageAdapter, string)

Initializes a new instance of the PositionChangeMessage.

public static PositionChangeMessage CreatePortfolioChangeMessage(this IMessageAdapter adapter, string pfName)

Parameters

adapter IMessageAdapter

Trading system adapter.

pfName string

Portfolio name.

Returns

PositionChangeMessage

Portfolio change message.

CreatePositionChangeMessage(IMessageAdapter, string, SecurityId, string)

Initializes a new instance of the PositionChangeMessage.

public static PositionChangeMessage CreatePositionChangeMessage(this IMessageAdapter adapter, string pfName, SecurityId securityId, string depoName = null)

Parameters

adapter IMessageAdapter

Trading system adapter.

pfName string

Portfolio name.

securityId SecurityId

Security ID.

depoName string

The depositary where the physical security.

Returns

PositionChangeMessage

Position change message.

CreateReply(OrderMessage, Exception)

public static ExecutionMessage CreateReply(this OrderMessage message, Exception error = null)

Parameters

message OrderMessage

OrderMessage.

error Exception

Error info.

Returns

ExecutionMessage

ExecutionMessage.

CreateResponse(ISubscriptionMessage, Exception)

Create subscription response.

public static SubscriptionResponseMessage CreateResponse(this ISubscriptionMessage message, Exception error = null)

Parameters

message ISubscriptionMessage

Subscription.

error Exception

Error info.

Returns

SubscriptionResponseMessage

Subscription response message.

CreateResult(ISubscriptionMessage)

public static Message CreateResult(this ISubscriptionMessage message)

Parameters

message ISubscriptionMessage

Subscription.

Returns

Message

Message.

CreateSubscriptionResponse(long, Exception)

Create subscription response.

public static SubscriptionResponseMessage CreateSubscriptionResponse(this long id, Exception error = null)

Parameters

id long

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

error Exception

Error info.

Returns

SubscriptionResponseMessage

Subscription response message.

DataTypeArgToString(DataType)

Convert candle parameter into folder name replacing the reserved symbols.

public static string DataTypeArgToString(this DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

string

Directory name.

DataTypeArgToString(Type, object)

Convert candle parameter into folder name replacing the reserved symbols.

public static string DataTypeArgToString(this Type messageType, object arg)

Parameters

messageType Type

The type of candle message.

arg object

Candle arg.

Returns

string

Directory name.

DataTypeToFileName(DataType)

Convert file name to DataType.

public static string DataTypeToFileName(this DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

string

File name.

DecodeToPeriods(string)

Decode from string to Periods.

public static IEnumerable<WorkingTimePeriod> DecodeToPeriods(this string input)

Parameters

input string

Encoded string.

Returns

IEnumerable<WorkingTimePeriod>

Schedule validity periods.

DecodeToSpecialDays(string)

Decode from string to SpecialDays.

public static IDictionary<DateTime, Range<TimeSpan>[]> DecodeToSpecialDays(this string input)

Parameters

input string

Encoded string.

Returns

IDictionary<DateTime, Range<TimeSpan>[]>

Special working days and holidays.

EncodeToString(IDictionary<DateTime, Range<TimeSpan>[]>)

Encode SpecialDays to string.

public static string EncodeToString(this IDictionary<DateTime, Range<TimeSpan>[]> specialDays)

Parameters

specialDays IDictionary<DateTime, Range<TimeSpan>[]>

Special working days and holidays.

Returns

string

Encoded string.

EncodeToString(IEnumerable<WorkingTimePeriod>)

Encode Periods to string.

public static string EncodeToString(this IEnumerable<WorkingTimePeriod> periods)

Parameters

periods IEnumerable<WorkingTimePeriod>

Schedule validity periods.

Returns

string

Encoded string.

EnsureGetGenerator(SecurityIdGenerator)

Returns the specified generator or the default in case of null.

public static SecurityIdGenerator EnsureGetGenerator(this SecurityIdGenerator generator)

Parameters

generator SecurityIdGenerator

SecurityIdGenerator

Returns

SecurityIdGenerator

SecurityIdGenerator

EnsureToday(DateTimeOffset?)

Determines the specified date equals is Today and returns Today.

public static DateTimeOffset? EnsureToday(this DateTimeOffset? date)

Parameters

date DateTimeOffset?

The specified date.

Returns

DateTimeOffset?

Result value.

EnsureToday(DateTimeOffset?, DateTimeOffset?)

Determines the specified date equals is Today and returns todayValue.

public static DateTimeOffset? EnsureToday(this DateTimeOffset? date, DateTimeOffset? todayValue)

Parameters

date DateTimeOffset?

The specified date.

todayValue DateTimeOffset?

Today value.

Returns

DateTimeOffset?

Result value.

FileNameToDataType(string)

Convert DataType to file name.

public static DataType FileNameToDataType(this string fileName)

Parameters

fileName string

File name.

Returns

DataType

Data type info.

FillDefaultCryptoFields(SecurityId)

Fill default CryptoCurrency price and volume step by 0.00000001 value.

public static SecurityMessage FillDefaultCryptoFields(this SecurityId secId)

Parameters

secId SecurityId

Security ID.

Returns

SecurityMessage

A message containing info about the security.

FillDefaultCryptoFields(SecurityMessage)

Fill default CryptoCurrency price and volume step by 0.00000001 value.

public static SecurityMessage FillDefaultCryptoFields(this SecurityMessage message)

Parameters

message SecurityMessage

A message containing info about the security.

Returns

SecurityMessage

A message containing info about the security.

Filter(IEnumerable<BoardMessage>, BoardLookupMessage)

Filter boards by code criteria.

public static IEnumerable<BoardMessage> Filter(this IEnumerable<BoardMessage> boards, BoardLookupMessage criteria)

Parameters

boards IEnumerable<BoardMessage>

All boards.

criteria BoardLookupMessage

Criteria.

Returns

IEnumerable<BoardMessage>

Found boards.

Filter(IEnumerable<SecurityMessage>, SecurityLookupMessage)

To filter instruments by the given criteria.

public static IEnumerable<SecurityMessage> Filter(this IEnumerable<SecurityMessage> securities, SecurityLookupMessage criteria)

Parameters

securities IEnumerable<SecurityMessage>

Securities.

criteria SecurityLookupMessage

Message security lookup for specified criteria.

Returns

IEnumerable<SecurityMessage>

Instruments filtered.

FilterTimeFrames(IEnumerable<DataType>)

Extract time frames from the specified data types set.

public static IEnumerable<TimeSpan> FilterTimeFrames(this IEnumerable<DataType> dataTypes)

Parameters

dataTypes IEnumerable<DataType>

Data types.

Returns

IEnumerable<TimeSpan>

Possible time-frames.

Filter<TMessage>(IEnumerable<TMessage>, DateTimeOffset, DateTimeOffset)

To filter messages for the given time period.

public static IEnumerable<TMessage> Filter<TMessage>(this IEnumerable<TMessage> messages, DateTimeOffset from, DateTimeOffset to) where TMessage : IServerTimeMessage

Parameters

messages IEnumerable<TMessage>

All messages, in which the required shall be searched for.

from DateTimeOffset

The start date for searching.

to DateTimeOffset

The end date for searching.

Returns

IEnumerable<TMessage>

Filtered messages.

Type Parameters

TMessage

FindAdapter<TAdapter>(IMessageAdapter)

Find adapter by the specified type.

public static TAdapter FindAdapter<TAdapter>(this IMessageAdapter adapter) where TAdapter : IMessageAdapter

Parameters

adapter IMessageAdapter

Adapter.

Returns

TAdapter

Found adapter or null.

Type Parameters

TAdapter

The adapter type.

FindAdapter<TAdapter>(IMessageAdapterWrapper)

Find adapter by the specified type.

public static TAdapter FindAdapter<TAdapter>(this IMessageAdapterWrapper wrapper) where TAdapter : IMessageAdapter

Parameters

wrapper IMessageAdapterWrapper

Wrapping based adapter.

Returns

TAdapter

Found adapter or null.

Type Parameters

TAdapter

The adapter type.

FindById(IEnumerable<IMessageAdapter>, Guid)

Get adapter by the specified key.

public static IMessageAdapter FindById(this IEnumerable<IMessageAdapter> adapters, Guid id)

Parameters

adapters IEnumerable<IMessageAdapter>

All available adapters.

id Guid

Adapter identifier.

Returns

IMessageAdapter

Found adapter or null.

FormatToString(DataType)

Convert DataType to string value.

public static (string type, string arg) FormatToString(this DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

(string type, string arg)

string value.

FromMicexCurrencyName(string, Action<Exception>)

To convert the currency name in the MICEX format into Ecng.Common.CurrencyTypes.

public static CurrencyTypes? FromMicexCurrencyName(this string name, Action<Exception> errorHandler = null)

Parameters

name string

The currency name in the MICEX format.

errorHandler Action<Exception>

Error handler.

Returns

CurrencyTypes?

Currency type. If the value is empty, null will be returned.

GetArg(MarketDataMessage)

Get typed argument.

public static object GetArg(this MarketDataMessage mdMsg)

Parameters

mdMsg MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

Returns

object

The additional argument, associated with data. For example, candle argument.

GetArg<TArg>(MarketDataMessage)

Get typed argument.

public static TArg GetArg<TArg>(this MarketDataMessage mdMsg)

Parameters

mdMsg MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

Returns

TArg

The additional argument, associated with data. For example, candle argument.

Type Parameters

TArg

Arg type.

GetBalance(ExecutionMessage)

Get Balance.

public static decimal GetBalance(this ExecutionMessage message)

Parameters

message ExecutionMessage

The message contains information about the execution.

Returns

decimal

Order contracts balance.

GetBasicProperties(Type)

Find properties marked by Ecng.Common.BasicSettingAttribute.

public static IEnumerable<PropertyInfo> GetBasicProperties(this Type adapterType)

Parameters

adapterType Type

Type.

Returns

IEnumerable<PropertyInfo>

Properties marked by Ecng.Common.BasicSettingAttribute.

GetBestAsk(IOrderBookMessage)

Get best ask.

public static QuoteChange? GetBestAsk(this IOrderBookMessage message)

Parameters

message IOrderBookMessage

Market depth.

Returns

QuoteChange?

Best ask, or null, if no asks are empty.

GetBestBid(IOrderBookMessage)

Get best bid.

public static QuoteChange? GetBestBid(this IOrderBookMessage message)

Parameters

message IOrderBookMessage

Market depth.

Returns

QuoteChange?

Best bid, or null, if no bids are empty.

GetBestPair(IOrderBookMessage)

Get best pair.

public static (QuoteChange? bid, QuoteChange? ask) GetBestPair(this IOrderBookMessage book)

Parameters

book IOrderBookMessage

IOrderBookMessage

Returns

(QuoteChange? bid, QuoteChange? ask)

Best pair.

GetCandleArgType(Type)

Get candle arg type.

public static Type GetCandleArgType(this Type candleMessageType)

Parameters

candleMessageType Type

Candle message type.

Returns

Type

Candle arg type.

GetCandleArgs<TArg>(IMessageAdapter, Type, SecurityId, DateTimeOffset?, DateTimeOffset?)

Get possible args for the specified candle type and instrument.

public static IEnumerable<TArg> GetCandleArgs<TArg>(this IMessageAdapter adapter, Type candleType, SecurityId securityId = default, DateTimeOffset? from = null, DateTimeOffset? to = null)

Parameters

adapter IMessageAdapter

Adapter.

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<TArg>

Possible args.

Type Parameters

TArg

Type of Arg.

GetCandleBounds(TimeSpan, DateTimeOffset)

To get candle time frames relatively to the exchange working pattern.

public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime)

Parameters

timeFrame TimeSpan

The time frame for which you need to get time range.

currentTime DateTimeOffset

The current time within the range of time frames.

Returns

Range<DateTimeOffset>

The candle time frames.

GetCandleBounds(TimeSpan, DateTimeOffset, TimeZoneInfo, WorkingTime)

To get candle time frames relatively to the exchange working pattern.

public static Range<DateTimeOffset> GetCandleBounds(this TimeSpan timeFrame, DateTimeOffset currentTime, TimeZoneInfo timeZone, WorkingTime time)

Parameters

timeFrame TimeSpan

The time frame for which you need to get time range.

currentTime DateTimeOffset

The current time within the range of time frames.

timeZone TimeZoneInfo

Information about the time zone where the exchange is located.

time WorkingTime

The information about the exchange working pattern.

Returns

Range<DateTimeOffset>

The candle time frames.

GetDefaultMaxCount(DataType)

Get maximum possible items count per single subscription request.

public static int? GetDefaultMaxCount(this DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

int?

Max items count.

GetDelta(IOrderBookMessage, IOrderBookMessage)

To calculate the change between order books.

public static QuoteChangeMessage GetDelta(this IOrderBookMessage from, IOrderBookMessage to)

Parameters

from IOrderBookMessage

First order book.

to IOrderBookMessage

Second order book.

Returns

QuoteChangeMessage

The order book, storing only increments.

GetHistoryStepSize(IMessageAdapter, SecurityId, DataType, out TimeSpan)

Get maximum size step allowed for historical download.

public static TimeSpan GetHistoryStepSize(this IMessageAdapter adapter, SecurityId securityId, DataType dataType, out TimeSpan iterationInterval)

Parameters

adapter IMessageAdapter

Trading system adapter.

securityId SecurityId

SecurityId

dataType DataType

Data type info.

iterationInterval TimeSpan

Interval between iterations.

Returns

TimeSpan

Step.

GetId<T>(CommandMessage)

Get typed ObjectId.

public static T GetId<T>(this CommandMessage message)

Parameters

message CommandMessage

CommandMessage.

Returns

T

Typed ObjectId.

Type Parameters

T

Type of ObjectId.

GetLastTradePrice(Level1ChangeMessage)

Get last tick trade price.

public static decimal? GetLastTradePrice(this Level1ChangeMessage message)

Parameters

message Level1ChangeMessage

Market depth.

Returns

decimal?

The middle of spread. Is null, if quotes are empty.

GetMatchedVolume(IOrderMessage)

To calculate the implemented part of volume for order.

public static decimal GetMatchedVolume(this IOrderMessage order)

Parameters

order IOrderMessage

The order, for which the implemented part of volume shall be calculated.

Returns

decimal

The implemented part of volume.

GetOrderLogCancelReason(ExecutionMessage)

To get the reason for cancelling order in orders log.

public static OrderLogCancelReasons GetOrderLogCancelReason(this ExecutionMessage item)

Parameters

item ExecutionMessage

Order log item.

Returns

OrderLogCancelReasons

The reason for order cancelling in order log.

GetPair(IOrderBookMessage, int)

To get a pair of quotes (bid + offer) by the depth index.

public static (QuoteChange? bid, QuoteChange? ask) GetPair(this IOrderBookMessage book, int depthIndex)

Parameters

book IOrderBookMessage

IOrderBookMessage

depthIndex int

Depth index. Zero index means the best pair of quotes.

Returns

(QuoteChange? bid, QuoteChange? ask)

The pair of quotes. If the index is larger than book order depth, then the null is returned.

GetPeriod(WorkingTime, DateTime)

Get period for schedule.

public static WorkingTimePeriod GetPeriod(this WorkingTime time, DateTime date)

Parameters

time WorkingTime

Trading schedule.

date DateTime

The date in time for search of appropriate period.

Returns

WorkingTimePeriod

The schedule period. If no period is appropriate, null is returned.

GetPlazaTimeInForce(long)

Extract TimeInForce from bits flag.

public static TimeInForce? GetPlazaTimeInForce(this long status)

Parameters

status long

Bits flag.

Returns

TimeInForce?

TimeInForce.

GetPreferredLanguage(MessageAdapterCategories?)

Get preferred language.

public static string GetPreferredLanguage(this MessageAdapterCategories? categories)

Parameters

categories MessageAdapterCategories?

Message adapter categories.

Returns

string

Language

GetPriceStep(int)

To get the price increment on the basis of accuracy.

public static decimal GetPriceStep(this int decimals)

Parameters

decimals int

Decimals.

Returns

decimal

Price step.

GetSecurityTypes(SecurityLookupMessage)

public static HashSet<SecurityTypes> GetSecurityTypes(this SecurityLookupMessage message)

Parameters

message SecurityLookupMessage

Message security lookup for specified criteria.

Returns

HashSet<SecurityTypes>

Securities types.

GetServerTime(Message)

Get message server time.

public static DateTimeOffset GetServerTime(this Message message)

Parameters

message Message

Message.

Returns

DateTimeOffset

Server time.

GetSpreadMiddle(IOrderBookMessage, decimal?)

Get middle of spread.

public static decimal? GetSpreadMiddle(this IOrderBookMessage message, decimal? priceStep)

Parameters

message IOrderBookMessage

Market depth.

priceStep decimal?

PriceStep

Returns

decimal?

The middle of spread. Is null, if quotes are empty.

GetSpreadMiddle(Level1ChangeMessage, decimal?)

Get middle of spread.

public static decimal? GetSpreadMiddle(this Level1ChangeMessage message, decimal? priceStep)

Parameters

message Level1ChangeMessage

Market depth.

priceStep decimal?

PriceStep

Returns

decimal?

The middle of spread. Is null, if quotes are empty.

GetSpreadMiddle(decimal, decimal, decimal?)

Get middle of spread.

public static decimal GetSpreadMiddle(this decimal bestBidPrice, decimal bestAskPrice, decimal? priceStep)

Parameters

bestBidPrice decimal

Best bid price.

bestAskPrice decimal

Best ask price.

priceStep decimal?

PriceStep

Returns

decimal

The middle of spread. Is null, if quotes are empty.

GetSpreadMiddle(decimal?, decimal?, decimal?)

Get middle of spread.

public static decimal? GetSpreadMiddle(this decimal? bestBidPrice, decimal? bestAskPrice, decimal? priceStep)

Parameters

bestBidPrice decimal?

Best bid price.

bestAskPrice decimal?

Best ask price.

priceStep decimal?

PriceStep

Returns

decimal?

The middle of spread. Is null, if quotes are empty.

GetSubscriptionIds(ISubscriptionIdMessage)

Get subscription identifiers from the specified message.

public static long[] GetSubscriptionIds(this ISubscriptionIdMessage message)

Parameters

message ISubscriptionIdMessage

Message.

Returns

long[]

Identifiers.

GetSupportedDataTypes(IMessageAdapter)

Get supported y adapter data types.

public static IEnumerable<DataType> GetSupportedDataTypes(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

IEnumerable<DataType>

Supported by adapter data types.

GetTimeFrame(DataType)

Get time-frame.

public static TimeSpan GetTimeFrame(this DataType dataType)

Parameters

dataType DataType

DataType.

Returns

TimeSpan

Time-frame.

GetTimeFrame(MarketDataMessage)

Get time-frame from the specified market-data message.

public static TimeSpan GetTimeFrame(this MarketDataMessage mdMsg)

Parameters

mdMsg MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

Returns

TimeSpan

Time-frame.

GetTimeFrameCount(Range<DateTimeOffset>, TimeSpan, WorkingTime, TimeZoneInfo)

To get the number of time frames within the specified time range.

public static long GetTimeFrameCount(this Range<DateTimeOffset> range, TimeSpan timeFrame, WorkingTime workingTime = null, TimeZoneInfo timeZone = null)

Parameters

range Range<DateTimeOffset>

The specified time range for which you need to get the number of time frames.

timeFrame TimeSpan

The time frame size.

workingTime WorkingTime

WorkingTime.

timeZone TimeZoneInfo

Information about the time zone where the exchange is located.

Returns

long

The received number of time frames.

GetTimeFrames(IMessageAdapter, SecurityId, DateTimeOffset?, DateTimeOffset?)

Get possible time-frames for the specified instrument.

public static IEnumerable<TimeSpan> GetTimeFrames(this IMessageAdapter adapter, SecurityId securityId = default, DateTimeOffset? from = null, DateTimeOffset? to = null)

Parameters

adapter IMessageAdapter

Trading system adapter.

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.

GetTopPairs(IOrderBookMessage, int)

To get a pair of quotes for a given book depth.

public static IEnumerable<(QuoteChange? bid, QuoteChange? ask)> GetTopPairs(this IOrderBookMessage book, int depth)

Parameters

book IOrderBookMessage

IOrderBookMessage

depth int

Book depth. The counting is from the best quotes.

Returns

IEnumerable<(QuoteChange? bid, QuoteChange? ask)>

Spread.

GetTopQuotes(IOrderBookMessage, int)

To get quotes for a given book depth.

public static IEnumerable<QuoteChange> GetTopQuotes(this IOrderBookMessage book, int depth)

Parameters

book IOrderBookMessage

IOrderBookMessage

depth int

Book depth. Quotes are in order of price increasing from bids to offers.

Returns

IEnumerable<QuoteChange>

Spread.

GetTradePrice(ExecutionMessage)

public static decimal GetTradePrice(this ExecutionMessage message)

Parameters

message ExecutionMessage

The message contains information about the execution.

Returns

decimal

Trade price.

GetUnderlyingCode(SecurityMessage)

Get underlying asset.

public static string GetUnderlyingCode(this SecurityMessage secMsg)

Parameters

secMsg SecurityMessage

SecurityMessage

Returns

string

Underlying asset.

Group(IOrderBookMessage, Unit)

To group the order book by the price range.

[Obsolete("Use method with decimal priceRange parameter")]
public static QuoteChangeMessage Group(this IOrderBookMessage depth, Unit priceRange)

Parameters

depth IOrderBookMessage

The order book to be grouped.

priceRange Unit

The price range, for which grouping shall be performed.

Returns

QuoteChangeMessage

The grouped order book.

Group(IOrderBookMessage, decimal)

To group the order book by the price range.

public static QuoteChangeMessage Group(this IOrderBookMessage depth, decimal priceRange)

Parameters

depth IOrderBookMessage

The order book to be grouped.

priceRange decimal

The price range, for which grouping shall be performed.

Returns

QuoteChangeMessage

The grouped order book.

Group(QuoteChange[], Sides, Unit)

[Obsolete("Use method with decimal priceRange")]
public static QuoteChange[] Group(this QuoteChange[] quotes, Sides side, Unit priceRange)

Parameters

quotes QuoteChange[]
side Sides
priceRange Unit

Returns

QuoteChange[]

Group(QuoteChange[], Sides, decimal)

To group quotes by the price range.

public static QuoteChange[] Group(this QuoteChange[] quotes, Sides side, decimal priceRange)

Parameters

quotes QuoteChange[]

Quotes to be grouped.

side Sides

Side.

priceRange decimal

The price range, for which grouping shall be performed.

Returns

QuoteChange[]

Grouped quotes.

HasChanges<TMessage, TChange>(BaseChangeMessage<TMessage, TChange>)

Determines the message contains any changes.

public static bool HasChanges<TMessage, TChange>(this BaseChangeMessage<TMessage, TChange> message) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message BaseChangeMessage<TMessage, TChange>

Change message.

Returns

bool

Check result.

Type Parameters

TMessage

Change message type.

TChange

Change type.

HasOrderId(OrderStatusMessage)

Determines the specified message contains single order request.

public static bool HasOrderId(this OrderStatusMessage message)

Parameters

message OrderStatusMessage

Message.

Returns

bool

Check result.

HasOrderInfo(ExecutionMessage)

Determines whether the specified message contains order information.

public static bool HasOrderInfo(this ExecutionMessage message)

Parameters

message ExecutionMessage

The message.

Returns

bool

true if the specified message contains order information, otherwise, false.

HasTradeInfo(ExecutionMessage)

Determines whether the specified message contains trade information.

public static bool HasTradeInfo(this ExecutionMessage message)

Parameters

message ExecutionMessage

The message.

Returns

bool

true if the specified message contains trade information, otherwise, false.

Invert(Sides)

To change the direction to opposite.

public static Sides Invert(this Sides side)

Parameters

side Sides

The initial direction.

Returns

Sides

The opposite direction.

IsAllSecurity(ISecurityIdMessage)

Check if the specified ISecurityIdMessage is IsAllSecurity(SecurityId).

public static bool IsAllSecurity(this ISecurityIdMessage message)

Parameters

message ISecurityIdMessage

ISecurityIdMessage

Returns

bool

true, if the specified ISecurityIdMessage is IsAllSecurity(SecurityId), otherwise, false.

IsAllSecurity(SecurityId)

Check if the specified SecurityId is IsAllSecurity(SecurityId).

public static bool IsAllSecurity(this SecurityId securityId)

Parameters

securityId SecurityId

SecurityId

Returns

bool

true, if the specified SecurityId is IsAllSecurity(SecurityId), otherwise, false.

IsAssociated(SecurityId, string)

Is specified security id associated with the board.

public static bool IsAssociated(this SecurityId securityId, string boardCode)

Parameters

securityId SecurityId

Security ID.

boardCode string

Board code.

Returns

bool

true, if associated, otherwise, false.

IsBack(IMessage)

Determines the specified message is loopback.

public static bool IsBack(this IMessage message)

Parameters

message IMessage

Message.

Returns

bool

Is loopback message.

IsBasket(SecurityMessage)

Is specified security is basket.

public static bool IsBasket(this SecurityMessage security)

Parameters

security SecurityMessage

Security.

Returns

bool

Check result.

IsBestAskField(Level1Fields)

Is the specified Level1Fields is related to best ask.

public static bool IsBestAskField(this Level1Fields field)

Parameters

field Level1Fields

Field.

Returns

bool

Check result.

IsBestBidField(Level1Fields)

Is the specified Level1Fields is related to best bid.

public static bool IsBestBidField(this Level1Fields field)

Parameters

field Level1Fields

Field.

Returns

bool

Check result.

IsCanceled(IOrderMessage)

To check, whether the order was cancelled.

public static bool IsCanceled(this IOrderMessage order)

Parameters

order IOrderMessage

The order to be checked.

Returns

bool

true, if the order is cancelled, otherwise, false.

IsCandle(MessageTypes)

Determine the type is candle data type.

public static bool IsCandle(this MessageTypes type)

Parameters

type MessageTypes

Message type.

Returns

bool

true, if data type is candle, otherwise, false.

IsCandleMessage(Type)

Determines whether the specified message type is derived from CandleMessage.

public static bool IsCandleMessage(this Type messageType)

Parameters

messageType Type

The message type.

Returns

bool

true if the specified message type is derived from CandleMessage, otherwise, false.

IsCandlesSupported(IMessageAdapter, MarketDataMessage)

Determines whether the specified subscription request is supported by the adapter.

public static bool IsCandlesSupported(this IMessageAdapter adapter, MarketDataMessage subscription)

Parameters

adapter IMessageAdapter

Adapter.

subscription MarketDataMessage

Subscription.

Returns

bool

true if the specified subscription request is supported, otherwise, false.

IsContainsCandle(Level1ChangeMessage)

To check, are there CandleTimeFrame in the level1 data.

public static bool IsContainsCandle(this Level1ChangeMessage level1)

Parameters

level1 Level1ChangeMessage

Level1 data.

Returns

bool

The test result.

IsContainsQuotes(Level1ChangeMessage)

To check, are there quotes in the level1.

public static bool IsContainsQuotes(this Level1ChangeMessage level1)

Parameters

level1 Level1ChangeMessage

Level1 data.

Returns

bool

Quotes.

IsContainsTick(Level1ChangeMessage)

To check, are there tick data in the level1 data.

public static bool IsContainsTick(this Level1ChangeMessage level1)

Parameters

level1 Level1ChangeMessage

Level1 data.

Returns

bool

The test result.

IsFinal(OrderStates)

Is the specified state is final (Done or Failed).

public static bool IsFinal(this OrderStates state)

Parameters

state OrderStates

Order state.

Returns

bool

Check result.

IsFullEmpty(IOrderBookMessage)

To determine, is the order book empty.

public static bool IsFullEmpty(this IOrderBookMessage depth)

Parameters

depth IOrderBookMessage

Market depth.

Returns

bool

true, if order book is empty, otherwise, false.

IsHalfEmpty(IOrderBookMessage)

To determine, is the order book half-empty.

public static bool IsHalfEmpty(this IOrderBookMessage depth)

Parameters

depth IOrderBookMessage

Market depth.

Returns

bool

true, if the order book is half-empty, otherwise, false.

IsHistoryOnly(ISubscriptionMessage)

Determines the specified message contains historical request only.

public static bool IsHistoryOnly(this ISubscriptionMessage message)

Parameters

message ISubscriptionMessage

Subscription.

Returns

bool

Check result.

IsIndex(SecurityMessage)

Is specified security is index.

public static bool IsIndex(this SecurityMessage security)

Parameters

security SecurityMessage

Security.

Returns

bool

Check result.

IsIntraday(TimeSpan)

Determines the specified time-frame is intraday.

public static bool IsIntraday(this TimeSpan tf)

Parameters

tf TimeSpan

Time-frame.

Returns

bool

Check result.

IsLastTradeField(Level1Fields)

Is the specified Level1Fields is related to last trade.

public static bool IsLastTradeField(this Level1Fields field)

Parameters

field Level1Fields

Field.

Returns

bool

Check result.

IsLookupAll(SecurityLookupMessage)

Determine the criteria contains lookup all filter.

public static bool IsLookupAll(this SecurityLookupMessage criteria)

Parameters

criteria SecurityLookupMessage

The instrument whose fields will be used as a filter.

Returns

bool

Check result.

IsMarketData(ExecutionMessage)

Determines whether the execMsg contains market-data info.

public static bool IsMarketData(this ExecutionMessage execMsg)

Parameters

execMsg ExecutionMessage

The message contains information about the execution.

Returns

bool

Check result.

IsMarketData(IMessageAdapter)

Is the specified adapter support market-data.

public static bool IsMarketData(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsMarketDataTypeSupported(IMessageAdapter, DataType)

Determines whether the specified market-data type is supported by the adapter.

public static bool IsMarketDataTypeSupported(this IMessageAdapter adapter, DataType type)

Parameters

adapter IMessageAdapter

Adapter.

type DataType

Message type.

Returns

bool

true if the specified message type is supported, otherwise, false.

IsMatch(BoardMessage, BoardLookupMessage)

Determines the specified message is matched lookup criteria.

public static bool IsMatch(this BoardMessage board, BoardLookupMessage criteria)

Parameters

board BoardMessage

Board.

criteria BoardLookupMessage

The message which fields will be used as a filter.

Returns

bool

Check result.

IsMatch(ExecutionMessage, OrderStatusMessage)

Determines the specified message is matched lookup criteria.

public static bool IsMatch(this ExecutionMessage transaction, OrderStatusMessage criteria)

Parameters

transaction ExecutionMessage

Transaction.

criteria OrderStatusMessage

The message which fields will be used as a filter.

Returns

bool

Check result.

IsMatch(ExecutionMessage, OrderStatusMessage, ISet<OrderStates>)

Determines the specified transaction is matched lookup criteria.

public static bool IsMatch(this ExecutionMessage transaction, OrderStatusMessage criteria, ISet<OrderStates> states)

Parameters

transaction ExecutionMessage

Transaction.

criteria OrderStatusMessage

The order which fields will be used as a filter.

states ISet<OrderStates>

Filter order by the specified states.

Returns

bool

Check result.

IsMatch(ISubscriptionIdMessage, MessageTypes, ISubscriptionMessage)

Determines the specified message is matched lookup criteria.

public static bool IsMatch(this ISubscriptionIdMessage message, MessageTypes type, ISubscriptionMessage criteria)

Parameters

message ISubscriptionIdMessage

Message.

type MessageTypes

Type

criteria ISubscriptionMessage

The message which fields will be used as a filter.

Returns

bool

Check result.

IsMatch(PortfolioMessage, PortfolioLookupMessage, bool)

Determines the specified message is matched lookup criteria.

public static bool IsMatch(this PortfolioMessage portfolio, PortfolioLookupMessage criteria, bool compareName)

Parameters

portfolio PortfolioMessage

Portfolio.

criteria PortfolioLookupMessage

The message which fields will be used as a filter.

compareName bool

Fully compare PortfolioName.

Returns

bool

Check result.

IsMatch(PositionChangeMessage, PortfolioLookupMessage, bool)

Determines the specified message is matched lookup criteria.

public static bool IsMatch(this PositionChangeMessage position, PortfolioLookupMessage criteria, bool compareName)

Parameters

position PositionChangeMessage

Position.

criteria PortfolioLookupMessage

The message which fields will be used as a filter.

compareName bool

Fully compare PortfolioName.

Returns

bool

Check result.

IsMatch(SecurityMessage, SecurityLookupMessage)

Determines the specified security is matched lookup criteria.

public static bool IsMatch(this SecurityMessage security, SecurityLookupMessage criteria)

Parameters

security SecurityMessage

Security.

criteria SecurityLookupMessage

Message security lookup for specified criteria.

Returns

bool

Check result.

IsMatch(SecurityMessage, SecurityLookupMessage, HashSet<SecurityTypes>)

Determines the specified security is matched lookup criteria.

public static bool IsMatch(this SecurityMessage security, SecurityLookupMessage criteria, HashSet<SecurityTypes> secTypes)

Parameters

security SecurityMessage

Security.

criteria SecurityLookupMessage

Message security lookup for specified criteria.

secTypes HashSet<SecurityTypes>

Securities types.

Returns

bool

Check result.

IsMatched(IOrderMessage)

To check, is the order matched completely.

public static bool IsMatched(this IOrderMessage order)

Parameters

order IOrderMessage

The order to be checked.

Returns

bool

true, if the order is matched completely, otherwise, false.

IsMatchedEmpty(IOrderMessage)

To check, if no contract in order is implemented.

public static bool IsMatchedEmpty(this IOrderMessage order)

Parameters

order IOrderMessage

The order to be checked.

Returns

bool

true, if no contract is implemented, otherwise, false.

IsMatchedPartially(IOrderMessage)

To check, is a part of volume is implemented in the order.

public static bool IsMatchedPartially(this IOrderMessage order)

Parameters

order IOrderMessage

The order to be checked.

Returns

bool

true, if part of volume is implemented, otherwise, false.

IsMessageSupported(IMessageAdapter, MessageTypes)

Determines whether the specified message type is contained in SupportedInMessages.

public static bool IsMessageSupported(this IMessageAdapter adapter, MessageTypes type)

Parameters

adapter IMessageAdapter

Adapter.

type MessageTypes

Message type.

Returns

bool

true if the specified message type is supported, otherwise, false.

IsMoney(PositionChangeMessage)

Determines the specified message contains Money position.

public static bool IsMoney(this PositionChangeMessage posMsg)

Parameters

posMsg PositionChangeMessage

The message contains information about the position changes.

Returns

bool

Check result.

IsMoney(SecurityId)

Check if the specified id is money id.

public static bool IsMoney(this SecurityId secId)

Parameters

secId SecurityId

The message contains information about the position changes.

Returns

bool

Check result.

IsNotSupported(SubscriptionResponseMessage)

Determines whether the reply contains the error NotSupported.

public static bool IsNotSupported(this SubscriptionResponseMessage message)

Parameters

message SubscriptionResponseMessage

Reply.

Returns

bool

Check result.

IsObsolete(Level1Fields)

Is the specified Level1Fields was obsolete.

public static bool IsObsolete(this Level1Fields field)

Parameters

field Level1Fields

Level1Fields value.

Returns

bool

true, if obsolete, otherwise, not obsolete.

IsObsolete(PositionChangeTypes)

Is the specified PositionChangeTypes was marked by ObsoleteAttribute.

public static bool IsObsolete(this PositionChangeTypes type)

Parameters

type PositionChangeTypes

PositionChangeTypes value.

Returns

bool

true, if obsolete, otherwise, not obsolete.

IsOk(SubscriptionResponseMessage)

Determines whether the reply contains an error Error.

public static bool IsOk(this SubscriptionResponseMessage message)

Parameters

message SubscriptionResponseMessage

Reply.

Returns

bool

Check result.

IsOpened(IMessageChannel)

Is channel opened.

public static bool IsOpened(this IMessageChannel channel)

Parameters

channel IMessageChannel

Message channel.

Returns

bool

Check result.

IsOrderLogCanceled(ExecutionMessage)

To check, does the string contain the cancelled order.

public static bool IsOrderLogCanceled(this ExecutionMessage item)

Parameters

item ExecutionMessage

Order log item.

Returns

bool

true, if the string contain the cancelled order, otherwise, false.

IsOrderLogMatched(ExecutionMessage)

To check, does the string contain the order matching.

public static bool IsOrderLogMatched(this ExecutionMessage item)

Parameters

item ExecutionMessage

Order log item.

Returns

bool

true, if the string contains order matching, otherwise, false.

IsOrderLogRegistered(ExecutionMessage)

To check, does the string contain the order registration.

public static bool IsOrderLogRegistered(this ExecutionMessage item)

Parameters

item ExecutionMessage

Order log item.

Returns

bool

true, if the string contains the order registration, otherwise, false.

IsPlazaSystem(long)

Extract system attribute from the bits flag.

public static bool IsPlazaSystem(this long status)

Parameters

status long

Bits flag.

Returns

bool

true if an order is system, otherwise, false.

IsResultMessageSupported(IMessageAdapter, MessageTypes)

Determines whether the specified message type is contained in SupportedResultMessages..

public static bool IsResultMessageSupported(this IMessageAdapter adapter, MessageTypes type)

Parameters

adapter IMessageAdapter

Adapter.

type MessageTypes

Message type.

Returns

bool

true if the specified message type is supported, otherwise, false.

IsSet(Unit)

Determines the value is set.

public static bool IsSet(this Unit value)

Parameters

value Unit

Unit

Returns

bool

Check result.

IsStub(Type)

Determines the specified adapter type is stub.

public static bool IsStub(this Type adapterType)

Parameters

adapterType Type

IMessageAdapter type.

Returns

bool

Check result.

IsSupportSecuritiesLookupAll(IMessageAdapter)

Support lookup all securities.

public static bool IsSupportSecuritiesLookupAll(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsSupportStopLoss(IMessageAdapter)

Determines whether the adapter support stop-loss orders.

public static bool IsSupportStopLoss(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsSupportSubscriptionByPortfolio(IMessageAdapter)

Support portfolio subscriptions.

public static bool IsSupportSubscriptionByPortfolio(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsSupportTakeProfit(IMessageAdapter)

Determines whether the adapter support take-profit orders.

public static bool IsSupportTakeProfit(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsSupportWithdraw(IMessageAdapter)

Determines whether the adapter support withdraw orders.

public static bool IsSupportWithdraw(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

IsToday(DateTimeOffset)

To check the specified date is today.

public static bool IsToday(this DateTimeOffset date)

Parameters

date DateTimeOffset

The specified date.

Returns

bool

true if the specified date is today, otherwise, false.

IsToday(DateTimeOffset?)

To check the specified date is today.

public static bool IsToday(this DateTimeOffset? date)

Parameters

date DateTimeOffset?

The specified date.

Returns

bool

true if the specified date is today, otherwise, false.

IsTradeDate(BoardMessage, DateTimeOffset, bool)

To check, whether date is traded.

public static bool IsTradeDate(this BoardMessage board, DateTimeOffset date, bool checkHolidays = false)

Parameters

board BoardMessage

Board info.

date DateTimeOffset

The passed date to be checked.

checkHolidays bool

Whether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).

Returns

bool

true, if the date is traded, otherwise, is not traded.

IsTradeDate(WorkingTime, DateTime, bool)

To check, whether date is traded.

public static bool IsTradeDate(this WorkingTime workingTime, DateTime date, bool checkHolidays = false)

Parameters

workingTime WorkingTime

Board working hours.

date DateTime

The passed date to be checked.

checkHolidays bool

Whether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).

Returns

bool

true, if the date is traded, otherwise, is not traded.

IsTradeTime(BoardMessage, DateTimeOffset)

To check, whether the time is traded (has the session started, ended, is there a clearing).

public static bool IsTradeTime(this BoardMessage board, DateTimeOffset time)

Parameters

board BoardMessage

Board info.

time DateTimeOffset

The passed time to be checked.

Returns

bool

true, if time is traded, otherwise, not traded.

IsTradeTime(BoardMessage, DateTimeOffset, out bool?, out WorkingTimePeriod)

To check, whether the time is traded (has the session started, ended, is there a clearing).

public static bool IsTradeTime(this BoardMessage board, DateTimeOffset time, out bool? isWorkingDay, out WorkingTimePeriod period)

Parameters

board BoardMessage

Board info.

time DateTimeOffset

The passed time to be checked.

isWorkingDay bool?

true, if the date is traded, otherwise, is not traded.

period WorkingTimePeriod

Current working time period.

Returns

bool

true, if time is traded, otherwise, not traded.

IsTradeTime(WorkingTime, DateTime, out bool?, out WorkingTimePeriod)

To check, whether the time is traded (has the session started, ended, is there a clearing).

public static bool IsTradeTime(this WorkingTime workingTime, DateTime time, out bool? isWorkingDay, out WorkingTimePeriod period)

Parameters

workingTime WorkingTime

Board working hours.

time DateTime

The passed time to be checked.

isWorkingDay bool?

true, if the date is traded, otherwise, is not traded.

period WorkingTimePeriod

Current working time period.

Returns

bool

true, if time is traded, otherwise, not traded.

IsTransactional(IMessageAdapter)

Is the specified adapter support transactions.

public static bool IsTransactional(this IMessageAdapter adapter)

Parameters

adapter IMessageAdapter

Adapter.

Returns

bool

Check result.

Iso10962(SecurityMessage)

To get the type for the instrument in the ISO 10962 standard.

public static string Iso10962(this SecurityMessage security)

Parameters

security SecurityMessage

Security.

Returns

string

Type in ISO 10962 standard.

Iso10962ToOptionType(string)

To convert the type in the ISO 10962 standard into OptionTypes.

public static OptionTypes? Iso10962ToOptionType(this string cfi)

Parameters

cfi string

Type in ISO 10962 standard.

Returns

OptionTypes?

Option type.

Iso10962ToSecurityType(string)

To convert the type in the ISO 10962 standard into SecurityTypes.

public static SecurityTypes? Iso10962ToSecurityType(this string cfi)

Parameters

cfi string

Type in ISO 10962 standard.

Returns

SecurityTypes?

Security type.

Join(IOrderBookMessage, IOrderBookMessage)

To merge the initial order book and its sparse representation.

public static QuoteChangeMessage Join(this IOrderBookMessage original, IOrderBookMessage rare)

Parameters

original IOrderBookMessage

The initial order book.

rare IOrderBookMessage

The sparse order book.

Returns

QuoteChangeMessage

The merged order book.

LastTradeDay(BoardMessage, DateTimeOffset, bool)

Get last trade date.

public static DateTimeOffset LastTradeDay(this BoardMessage board, DateTimeOffset date, bool checkHolidays = true)

Parameters

board BoardMessage

Board info.

date DateTimeOffset

The date from which to start checking.

checkHolidays bool

Whether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).

Returns

DateTimeOffset

Last trade date.

LookupByCode(ISecurityMessageProvider, string, SecurityTypes?)

To get the instrument by the instrument code.

public static IEnumerable<SecurityMessage> LookupByCode(this ISecurityMessageProvider provider, string code, SecurityTypes? type = null)

Parameters

provider ISecurityMessageProvider

The provider of information about instruments.

code string

Security code.

type SecurityTypes?

Security type.

Returns

IEnumerable<SecurityMessage>

The got instrument. If there is no instrument by given criteria, null is returned.

LoopBack<TMessage>(TMessage, IMessageAdapter, MessageBackModes)

Made the specified message as BackMode.

public static TMessage LoopBack<TMessage>(this TMessage message, IMessageAdapter adapter, MessageBackModes mode = MessageBackModes.Direct) where TMessage : IMessage

Parameters

message TMessage

Message.

adapter IMessageAdapter

Adapter.

mode MessageBackModes

Back mode.

Returns

TMessage

Message.

Type Parameters

TMessage

Message type.

MakeVectorIconUri(string)

get icon uri

public static Uri MakeVectorIconUri(this string key)

Parameters

key string

Returns

Uri

NearestSupportedDepth(IMessageAdapter, int)

Get the nearest supported depth for the specified.

public static int? NearestSupportedDepth(this IMessageAdapter adapter, int depth)

Parameters

adapter IMessageAdapter

Adapter.

depth int

Depth.

Returns

int?

Supported depth.

RegisterCandleType<TArg>(Type, MessageTypes, MarketDataTypes, string, Func<string, TArg>, Func<TArg, string>, Func<TArg, bool>)

Register new candle type.

public static void RegisterCandleType<TArg>(Type messageType, MessageTypes type, MarketDataTypes dataType, string fileName, Func<string, TArg> argParse, Func<TArg, string> argToString, Func<TArg, bool> argValidator)

Parameters

messageType Type

The type of candle message.

type MessageTypes

Message type.

dataType MarketDataTypes

Candles type.

fileName string

File name.

argParse Func<string, TArg>

string to TArg converter.

argToString Func<TArg, string>

TArg to string converter.

argValidator Func<TArg, bool>

Arg validator.

Type Parameters

TArg

RemoveMarketDataSupport(MessageAdapter)

Remove from SupportedInMessages message types related to market-data.

public static void RemoveMarketDataSupport(this MessageAdapter adapter)

Parameters

adapter MessageAdapter

Adapter.

RemoveSupportedAllMarketDataTypes(MessageAdapter)

Remove all market data types from SupportedMarketDataTypes.

public static void RemoveSupportedAllMarketDataTypes(this MessageAdapter adapter)

Parameters

adapter MessageAdapter

Adapter.

RemoveSupportedMarketDataType(MessageAdapter, DataType)

Remove market data type from SupportedMarketDataTypes.

public static void RemoveSupportedMarketDataType(this MessageAdapter adapter, DataType type)

Parameters

adapter MessageAdapter

Adapter.

type DataType

Market data type.

RemoveSupportedMessage(MessageAdapter, MessageTypes)

Remove the message type from PossibleSupportedMessages.

public static void RemoveSupportedMessage(this MessageAdapter adapter, MessageTypes type)

Parameters

adapter MessageAdapter

Adapter.

type MessageTypes

Message type.

RemoveSupportedResultMessage(MessageAdapter, MessageTypes)

Remove the message type from SupportedResultMessages.

public static void RemoveSupportedResultMessage(this MessageAdapter adapter, MessageTypes type)

Parameters

adapter MessageAdapter

Adapter.

type MessageTypes

Message type.

RemoveTransactionalSupport(MessageAdapter)

Remove from SupportedInMessages message types related to transactional.

public static void RemoveTransactionalSupport(this MessageAdapter adapter)

Parameters

adapter MessageAdapter

Adapter.

ReplaceSecurityId(Message, SecurityId)

Replace security id by the specified.

public static void ReplaceSecurityId(this Message message, SecurityId securityId)

Parameters

message Message

Message.

securityId SecurityId

Security ID.

SafeGetOrderId(ExecutionMessage)

To get order identifier, or discard exception, if no information available.

public static long SafeGetOrderId(this ExecutionMessage message)

Parameters

message ExecutionMessage

Operations.

Returns

long

Order ID.

SafeGetVolume(ExecutionMessage)

To get the number of operations, or discard the exception, if no information available.

public static decimal SafeGetVolume(this ExecutionMessage message)

Parameters

message ExecutionMessage

Operations.

Returns

decimal

Quantity.

SetArg<TArg>(MarketDataMessage, TArg)

Set typed argument.

public static MarketDataMessage SetArg<TArg>(this MarketDataMessage mdMsg, TArg arg)

Parameters

mdMsg MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

arg TArg

The additional argument, associated with data. For example, candle argument.

Returns

MarketDataMessage

Market-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).

Type Parameters

TArg

Arg type.

SetId<T>(CommandMessage, T)

Set typed ObjectId.

public static void SetId<T>(this CommandMessage message, T id)

Parameters

message CommandMessage

CommandMessage.

id T

Typed ObjectId.

Type Parameters

T

Type of ObjectId.

SetNativeId(SecurityId, object)

Initialize Native.

public static SecurityId SetNativeId(this SecurityId secId, object nativeId)

Parameters

secId SecurityId

Security ID.

nativeId object

Native (internal) trading system security id.

Returns

SecurityId

Security ID.

SetSecurityCode(SecurityMessage, string)

Initialize SecurityCode.

public static void SetSecurityCode(this SecurityMessage message, string secCode)

Parameters

message SecurityMessage

A message containing info about the security.

secCode string

Security code.

SetSecurityTypes(SecurityLookupMessage, SecurityTypes?, IEnumerable<SecurityTypes>)

Initialize SecurityTypes.

public static void SetSecurityTypes(this SecurityLookupMessage message, SecurityTypes? type, IEnumerable<SecurityTypes> types = null)

Parameters

message SecurityLookupMessage

Message security lookup for specified criteria.

type SecurityTypes?

Security type.

types IEnumerable<SecurityTypes>

Securities types.

SetSubscriptionIds<TMessage>(TMessage, long[], long)

Set subscription identifiers into the specified message.

public static TMessage SetSubscriptionIds<TMessage>(this TMessage message, long[] subscriptionIds = null, long subscriptionId = 0) where TMessage : ISubscriptionIdMessage

Parameters

message TMessage

Message.

subscriptionIds long[]

Identifiers.

subscriptionId long

Identifier.

Returns

TMessage

Message.

Type Parameters

TMessage

Message type.

ShrinkPrice(decimal, decimal?, int?, ShrinkRules)

To cut the price, to make it multiple of minimal step, also to limit number of signs after the comma.

public static decimal ShrinkPrice(this decimal price, decimal? priceStep, int? decimals, ShrinkRules rule = ShrinkRules.Auto)

Parameters

price decimal

The price to be made multiple.

priceStep decimal?

Price step.

decimals int?

Number of digits in price after coma.

rule ShrinkRules

Returns

decimal

The multiple price.

Sparse(IOrderBookMessage, Unit, decimal?)

[Obsolete("Use method with decimal priceRange parameter")]
public static QuoteChangeMessage Sparse(this IOrderBookMessage depth, Unit priceRange, decimal? priceStep)

Parameters

depth IOrderBookMessage
priceRange Unit
priceStep decimal?

Returns

QuoteChangeMessage

Sparse(IOrderBookMessage, decimal, decimal?)

To create from regular order book a sparse one.

public static QuoteChangeMessage Sparse(this IOrderBookMessage depth, decimal priceRange, decimal? priceStep)

Parameters

depth IOrderBookMessage

The regular order book.

priceRange decimal

Minimum price step.

priceStep decimal?

Security price step.

Returns

QuoteChangeMessage

The sparse order book.

Remarks

In sparsed book shown quotes with no active orders. The volume of these quotes is 0.

Sparse(QuoteChange, QuoteChange, Unit, decimal?)

[Obsolete("Use method with decimal priceRange parameter")]
public static (QuoteChange[] bids, QuoteChange[] asks) Sparse(this QuoteChange bid, QuoteChange ask, Unit priceRange, decimal? priceStep)

Parameters

bid QuoteChange
ask QuoteChange
priceRange Unit
priceStep decimal?

Returns

(QuoteChange[] bids, QuoteChange[] asks)

Sparse(QuoteChange, QuoteChange, decimal, decimal?)

To create form pair of quotes a sparse collection of quotes, which will be included into the range between the pair.

public static (QuoteChange[] bids, QuoteChange[] asks) Sparse(this QuoteChange bid, QuoteChange ask, decimal priceRange, decimal? priceStep)

Parameters

bid QuoteChange

Bid.

ask QuoteChange

Ask.

priceRange decimal

Minimum price step.

priceStep decimal?

Security price step.

Returns

(QuoteChange[] bids, QuoteChange[] asks)

The sparse collection of quotes.

Remarks

In sparsed collection shown quotes with no active orders. The volume of these quotes is 0.

Sparse(QuoteChange[], Sides, Unit, decimal?)

To create the sparse collection of quotes from regular quotes.

[Obsolete("Use method with decimal priceRange parameter")]
public static QuoteChange[] Sparse(this QuoteChange[] quotes, Sides side, Unit priceRange, decimal? priceStep)

Parameters

quotes QuoteChange[]

Regular quotes. The collection shall contain quotes of the same direction (only bids or only offers).

side Sides

Side.

priceRange Unit

Minimum price step.

priceStep decimal?

Security price step.

Returns

QuoteChange[]

The sparse collection of quotes.

Remarks

In sparsed collection shown quotes with no active orders. The volume of these quotes is 0.

Sparse(QuoteChange[], Sides, decimal, decimal?)

To create the sparse collection of quotes from regular quotes.

public static QuoteChange[] Sparse(this QuoteChange[] quotes, Sides side, decimal priceRange, decimal? priceStep)

Parameters

quotes QuoteChange[]

Regular quotes. The collection shall contain quotes of the same direction (only bids or only offers).

side Sides

Side.

priceRange decimal

Minimum price step.

priceStep decimal?

Security price step.

Returns

QuoteChange[]

The sparse collection of quotes.

Remarks

In sparsed collection shown quotes with no active orders. The volume of these quotes is 0.

SplitToPair(string)

Split to pair.

public static (string pairFrom, string pairTo) SplitToPair(this string symbol)

Parameters

symbol string

Symbol.

Returns

(string type, string arg)

Pair.

TimeFrame(TimeSpan)

Create data type info for TimeFrameCandleMessage.

public static DataType TimeFrame(this TimeSpan tf)

Parameters

tf TimeSpan

Candle arg.

Returns

DataType

Data type info.

ToCandleMessage(MessageTypes)

Cast candle type MessageTypes to the message CandleMessage.

public static Type ToCandleMessage(this MessageTypes type)

Parameters

type MessageTypes

Candle type.

Returns

Type

Message type CandleMessage.

ToCandleMessageType(MessageTypes)

To convert the type of message MessageTypes into type of candles CandleMessage.

public static Type ToCandleMessageType(this MessageTypes type)

Parameters

type MessageTypes

Message type.

Returns

Type

Candles type.

ToDataType(ExecutionTypes)

Convert ExecutionTypes to DataType value.

public static DataType ToDataType(this ExecutionTypes type)

Parameters

type ExecutionTypes

ExecutionTypes.

Returns

DataType

DataType.

ToDataType(MarketDataTypes, object)

Convert MarketDataTypes to DataType value.

[Obsolete]
public static DataType ToDataType(this MarketDataTypes type, object arg)

Parameters

type MarketDataTypes

Market data type.

arg object

The additional argument, associated with data. For example, candle argument.

Returns

DataType

Data type info.

ToDataType(string, string)

Convert string to DataType value.

public static DataType ToDataType(this string type, string arg)

Parameters

type string

type.

arg string

Arg.

Returns

DataType

Data type info.

ToDataTypeArg(Type, string)

To convert string representation of the candle argument into typified.

public static object ToDataTypeArg(this Type messageType, string str)

Parameters

messageType Type

The type of candle message.

str string

The string representation of the argument.

Returns

object

Argument.

ToErrorMessage(Exception, long)

Convert error info into ErrorMessage.

public static ErrorMessage ToErrorMessage(this Exception error, long originalTransactionId = 0)

Parameters

error Exception

Error info.

originalTransactionId long

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

Returns

ErrorMessage

Error message.

ToErrorMessage(string)

Convert error text message to ErrorMessage instance.

public static ErrorMessage ToErrorMessage(this string description)

Parameters

description string

Error text message.

Returns

ErrorMessage

ErrorMessage instance.

ToExec(OrderRegisterMessage)

public static ExecutionMessage ToExec(this OrderRegisterMessage regMsg)

Parameters

regMsg OrderRegisterMessage

The message containing the information for the order registration.

Returns

ExecutionMessage

The message contains information about the execution.

ToExecutionType(DataType)

Convert DataType to ExecutionTypes value.

public static ExecutionTypes ToExecutionType(this DataType type)

Parameters

type DataType

DataType.

Returns

ExecutionTypes

ExecutionTypes.

ToInfo(MessageTypes, bool?)

Convert MessageTypes to MessageTypeInfo value.

public static MessageTypeInfo ToInfo(this MessageTypes type, bool? isMarketData = null)

Parameters

type MessageTypes

MessageTypes value.

isMarketData bool?

Market data.

Returns

MessageTypeInfo

MessageTypeInfo value.

ToLevel1(CandleMessage)

public static Level1ChangeMessage ToLevel1(this CandleMessage message)

Parameters

message CandleMessage

CandleMessage instance.

Returns

Level1ChangeMessage

Level1ChangeMessage instance.

ToLevel1(ExecutionMessage)

public static Level1ChangeMessage ToLevel1(this ExecutionMessage message)

Parameters

message ExecutionMessage

ExecutionMessage instance.

Returns

Level1ChangeMessage

Level1ChangeMessage instance.

ToLevel1(IOrderBookMessage)

public static Level1ChangeMessage ToLevel1(this IOrderBookMessage message)

Parameters

message IOrderBookMessage

IOrderBookMessage instance.

Returns

Level1ChangeMessage

Level1ChangeMessage instance.

ToLevel1(IEnumerable<ExecutionMessage>, IOrderLogMarketDepthBuilder, TimeSpan)

To build level1 from the orders log.

public static IEnumerable<Level1ChangeMessage> ToLevel1(this IEnumerable<ExecutionMessage> items, IOrderLogMarketDepthBuilder builder, TimeSpan interval = default)

Parameters

items IEnumerable<ExecutionMessage>

Orders log lines.

builder IOrderLogMarketDepthBuilder

Order log to market depth builder.

interval TimeSpan

The interval of the order book generation. The default is Zero, which means order books generation at each new item of orders log.

Returns

IEnumerable<Level1ChangeMessage>

Tick trades.

ToLevel1(IEnumerable<QuoteChangeMessage>)

To build level1 from the order books.

public static IEnumerable<Level1ChangeMessage> ToLevel1(this IEnumerable<QuoteChangeMessage> quotes)

Parameters

quotes IEnumerable<QuoteChangeMessage>

Order books.

Returns

IEnumerable<Level1ChangeMessage>

Level1.

ToMarketDataType(DataType)

Convert DataType to MarketDataTypes value.

[Obsolete]
public static MarketDataTypes ToMarketDataType(this DataType dataType)

Parameters

dataType DataType

Data type info.

Returns

MarketDataTypes

MarketDataTypes value or null if cannot be converted.

ToMessageType(MarketDataTypes, out object)

Convert MarketDataTypes to MessageTypes value.

[Obsolete]
public static MessageTypes ToMessageType(this MarketDataTypes type, out object arg)

Parameters

type MarketDataTypes

Market data type.

arg object

The additional argument, associated with data. For example, candle argument.

Returns

MessageTypes

Message type.

ToMessageType(MessageTypes)

Convert MessageTypes to Type value.

public static Type ToMessageType(this MessageTypes type)

Parameters

type MessageTypes

MessageTypes value.

Returns

Type

Type value.

ToMessageType(Type)

Convert Type to MessageTypes value.

public static MessageTypes ToMessageType(this Type type)

Parameters

type Type

Type value.

Returns

MessageTypes

MessageTypes value.

ToMessageType2(DataType)

Convert DataType to MessageTypes value.

public static MessageTypes ToMessageType2(this DataType type)

Parameters

type DataType

DataType value.

Returns

MessageTypes

Message type.

ToMicexCurrencyName(CurrencyTypes)

To convert the currency type into the name in the MICEX format.

public static string ToMicexCurrencyName(this CurrencyTypes type)

Parameters

type CurrencyTypes

Currency type.

Returns

string

The currency name in the MICEX format.

ToNullableSecurityId(string, SecurityIdGenerator)

Convert string to SecurityId value.

public static SecurityId ToNullableSecurityId(this string id, SecurityIdGenerator generator = null)

Parameters

id string

string value.

generator SecurityIdGenerator

The instrument identifiers generator SecurityId. Can be null.

Returns

SecurityId

SecurityId value.

ToOrderBooks(IEnumerable<ExecutionMessage>, IOrderLogMarketDepthBuilder, TimeSpan, int)

Build market depths from order log.

public static IEnumerable<QuoteChangeMessage> ToOrderBooks(this IEnumerable<ExecutionMessage> items, IOrderLogMarketDepthBuilder builder, TimeSpan interval = default, int maxDepth = 2147483647)

Parameters

items IEnumerable<ExecutionMessage>

Orders log lines.

builder IOrderLogMarketDepthBuilder

Order log to market depth builder.

interval TimeSpan

The interval of the order book generation. The default is Zero, which means order books generation at each new item of orders log.

maxDepth int

The maximal depth of order book. The default is MaxValue, which means endless depth.

Returns

IEnumerable<QuoteChangeMessage>

Market depths.

ToOrderBooks(IEnumerable<Level1ChangeMessage>)

To convert level1 data into order books.

public static IEnumerable<QuoteChangeMessage> ToOrderBooks(this IEnumerable<Level1ChangeMessage> level1)

Parameters

level1 IEnumerable<Level1ChangeMessage>

Level1 data.

Returns

IEnumerable<QuoteChangeMessage>

Market depths.

ToOrderSnapshot(IEnumerable<ExecutionMessage>, long, ILogReceiver)

Convert order changes to final snapshot.

public static ExecutionMessage ToOrderSnapshot(this IEnumerable<ExecutionMessage> diffs, long transactionId, ILogReceiver logs)

Parameters

diffs IEnumerable<ExecutionMessage>

Changes.

transactionId long

Transaction ID.

logs ILogReceiver

Logs.

Returns

ExecutionMessage

Snapshot.

ToReadableString(DataType)

Convert DataType to readable string.

public static string ToReadableString(this DataType dt)

Parameters

dt DataType

DataType instance.

Returns

string

Readable string.

ToReg(ExecutionMessage)

public static OrderRegisterMessage ToReg(this ExecutionMessage execMsg)

Parameters

execMsg ExecutionMessage

The message contains information about the execution.

Returns

OrderRegisterMessage

The message containing the information for the order registration.

ToSecurityId(string, SecurityIdGenerator)

Convert string to SecurityId value.

public static SecurityId ToSecurityId(this string id, SecurityIdGenerator generator = null)

Parameters

id string

string value.

generator SecurityIdGenerator

The instrument identifiers generator SecurityId. Can be null.

Returns

SecurityId

SecurityId value.

ToStringId(SecurityId, SecurityIdGenerator, bool)

Convert SecurityId to SecurityId value.

public static string ToStringId(this SecurityId securityId, SecurityIdGenerator generator = null, bool nullIfEmpty = false)

Parameters

securityId SecurityId

SecurityId value.

generator SecurityIdGenerator

The instrument identifiers generator SecurityId. Can be null.

nullIfEmpty bool

Return null if SecurityId is empty.

Returns

string

SecurityId value.

ToTick(ExecutionMessage)

To tick trade from the order log.

public static ExecutionMessage ToTick(this ExecutionMessage item)

Parameters

item ExecutionMessage

Order log item.

Returns

ExecutionMessage

Tick trade.

ToTick(Level1ChangeMessage)

To convert level1 data into tick data.

public static ExecutionMessage ToTick(this Level1ChangeMessage level1)

Parameters

level1 Level1ChangeMessage

Level1 data.

Returns

ExecutionMessage

Tick data.

ToTicks(IEnumerable<ExecutionMessage>)

To build tick trades from the orders log.

public static IEnumerable<ExecutionMessage> ToTicks(this IEnumerable<ExecutionMessage> items)

Parameters

items IEnumerable<ExecutionMessage>

Orders log lines.

Returns

IEnumerable<ExecutionMessage>

Tick trades.

ToTicks(IEnumerable<Level1ChangeMessage>)

To convert level1 data into tick data.

public static IEnumerable<ExecutionMessage> ToTicks(this IEnumerable<Level1ChangeMessage> level1)

Parameters

level1 IEnumerable<Level1ChangeMessage>

Level1 data.

Returns

IEnumerable<ExecutionMessage>

Tick data.

ToType(Level1Fields)

Convert Level1Fields to Type value.

public static Type ToType(this Level1Fields field)

Parameters

field Level1Fields

Level1Fields value.

Returns

Type

Type value.

ToType(PositionChangeTypes)

Convert PositionChangeTypes to Type value.

public static Type ToType(this PositionChangeTypes type)

Parameters

type PositionChangeTypes

PositionChangeTypes value.

Returns

Type

Type value.

Truncate(IOrderBookMessage, int)

Truncate the specified order book by max depth value.

public static QuoteChangeMessage Truncate(this IOrderBookMessage depth, int maxDepth)

Parameters

depth IOrderBookMessage

Order book.

maxDepth int

The maximum depth of order book.

Returns

QuoteChangeMessage

Truncated order book.

TryAdd<TMessage, TChange>(TMessage, TChange, decimal, bool)

To add a change to the collection, if value is other than 0.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, decimal value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value decimal

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, int, bool)

To add a change to the collection, if value is other than 0.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, int value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value int

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, long, bool)

To add a change to the collection, if value is other than 0.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, long value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value long

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, CurrencyTypes?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, CurrencyTypes? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value CurrencyTypes?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, PortfolioStates?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, PortfolioStates? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value PortfolioStates?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, SecurityStates?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, SecurityStates? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value SecurityStates?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, Sides?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, Sides? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value Sides?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, bool?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, bool? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value bool?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, DateTimeOffset?)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, DateTimeOffset? value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value DateTimeOffset?

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, decimal?, bool)

To add a change to the collection, if value is other than 0 and null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, decimal? value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value decimal?

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, int?, bool)

To add a change to the collection, if value is other than 0 and null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, int? value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value int?

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, long?, bool)

To add a change to the collection, if value is other than 0 and null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, long? value, bool isZeroAcceptable = false) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value long?

Change value.

isZeroAcceptable bool

Is zero value is acceptable values.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryAdd<TMessage, TChange>(TMessage, TChange, string)

To add a change to the collection, if value is other than null.

public static TMessage TryAdd<TMessage, TChange>(this TMessage message, TChange type, string value) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

value string

Change value.

Returns

TMessage

Change message.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryFillUnderlyingId(SecurityMessage, string)

Fill UnderlyingSecurityId property.

public static SecurityMessage TryFillUnderlyingId(this SecurityMessage secMsg, string underlyingCode)

Parameters

secMsg SecurityMessage

SecurityMessage

underlyingCode string

Underlying asset id.

Returns

SecurityMessage

SecurityMessage

TryGet(IDictionary<string, string>, string, string)

public static string TryGet(this IDictionary<string, string> parameters, string name, string defaultValue = null)

Parameters

parameters IDictionary<string, string>
name string
defaultValue string

Returns

string

TryGetDecimal<TMessage, TChange>(TMessage, TChange)

Try get change from message.

public static decimal? TryGetDecimal<TMessage, TChange>(this TMessage message, TChange type) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

Returns

decimal?

Change value.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryGetIconUrl(Type)

public static Uri TryGetIconUrl(this Type type)

Parameters

type Type

Returns

Uri

Icon url.

TryGetSecurityId(Message)

Try get security ID from the specified message.

public static SecurityId? TryGetSecurityId(this Message message)

Parameters

message Message

Message.

Returns

SecurityId?

Security ID or null if message do not provide it.

TryGetServerTime(Message, out DateTimeOffset)

Try get message server time.

public static bool TryGetServerTime(this Message message, out DateTimeOffset serverTime)

Parameters

message Message

Message.

serverTime DateTimeOffset

Server time. If the value is default, the message does not contain the server time.

Returns

bool

Operation result.

TryGetVectorIcon(Type)

Try get Ecng.ComponentModel.VectorIconAttribute.Icon path.

public static Uri TryGetVectorIcon(this Type type)

Parameters

type Type

Component type with applied Ecng.ComponentModel.VectorIconAttribute.

Returns

Uri

Icon url.

TryGet<TMessage, TChange>(TMessage, TChange)

Try get change from message.

public static object TryGet<TMessage, TChange>(this TMessage message, TChange type) where TMessage : BaseChangeMessage<TMessage, TChange>, new()

Parameters

message TMessage

Change message.

type TChange

Change type.

Returns

object

Change value.

Type Parameters

TMessage

Change message type.

TChange

Change type.

TryInitLocalTime(Message, ILogSource)

Try to initialize LocalTime by CurrentTime.

public static void TryInitLocalTime(this Message message, ILogSource source)

Parameters

message Message

Message.

source ILogSource

Source.

TryLimitByCount<T>(IEnumerable<T>, SecurityLookupMessage)

public static IEnumerable<T> TryLimitByCount<T>(this IEnumerable<T> set, SecurityLookupMessage msg)

Parameters

set IEnumerable<T>
msg SecurityLookupMessage

Returns

IEnumerable<T>

Type Parameters

T

TryRemoveWrapper<TAdapter>(IMessageAdapter)

Remove adapter by the specified type.

public static TAdapter TryRemoveWrapper<TAdapter>(this IMessageAdapter adapter) where TAdapter : IMessageAdapterWrapper

Parameters

adapter IMessageAdapter

Adapter.

Returns

TAdapter

Removed adapter or null.

Type Parameters

TAdapter

The adapter type.

UnGroup(IOrderBookMessage)

To de-group the order book, grouped using the method Group(IOrderBookMessage, decimal).

public static QuoteChangeMessage UnGroup(this IOrderBookMessage depth)

Parameters

depth IOrderBookMessage

The grouped order book.

Returns

QuoteChangeMessage

The de-grouped order book.

UndoBack<TMessage>(TMessage)

public static TMessage UndoBack<TMessage>(this TMessage message) where TMessage : IMessage

Parameters

message TMessage

Message.

Returns

TMessage

Message.

Type Parameters

TMessage

Message type.

ValidateBounds(MarketDataMessage)

Validate From and To values.

public static MarketDataMessage ValidateBounds(this MarketDataMessage message)

Parameters

message MarketDataMessage

Message.

Returns

MarketDataMessage

Message.

ValidateCandleArg(Type, object)

Validate candle arg.

public static bool ValidateCandleArg(this Type candleMessageType, object value)

Parameters

candleMessageType Type

Candle message type.

value object

Candle arg.

Returns

bool

Check result.

ValidateChannelState(ChannelStates, ChannelStates)

Validate state change.

public static bool ValidateChannelState(this ChannelStates currState, ChannelStates newState)

Parameters

currState ChannelStates

Current state.

newState ChannelStates

New state.

Returns

bool

Verify(IOrderBookMessage)

To determine whether the order book is in the right state.

public static bool Verify(this IOrderBookMessage book)

Parameters

book IOrderBookMessage

Order book.

Returns

bool

true, if the order book contains correct data, otherwise false.

Remarks

It is used in cases when the trading system by mistake sends the wrong quotes.

VerifyOrderState(OrderStates?, OrderStates, long, ILogReceiver)

Check the possibility OrderStates change.

public static bool VerifyOrderState(this OrderStates? currState, OrderStates newState, long transactionId, ILogReceiver logs)

Parameters

currState OrderStates?

Current order's state.

newState OrderStates

New state.

transactionId long

Transaction id.

logs ILogReceiver

Logs.

Returns

bool

Check result.