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
AnonymousPortfolioName
Anonymous account.
public const string AnonymousPortfolioName = "Anonymous_SS"
Field Value
AnyDepths
Special set mean any depth for SupportedOrderBookDepths option.
public static readonly IEnumerable<int> AnyDepths
Field Value
LookupAllCriteriaMessage
Lookup all securities predefined criteria.
public static readonly SecurityLookupMessage LookupAllCriteriaMessage
Field Value
NewsStockSharpSource
StockSharp news source.
public const string NewsStockSharpSource = "StockSharp"
Field Value
SimulatorPortfolioName
Simulator.
public const string SimulatorPortfolioName = "Simulator_SS"
Field Value
Today
Constant value for TillDate means Today(=Session).
public static readonly DateTimeOffset Today
Field Value
Properties
AllCandleTypes
All registered candle types.
public static IEnumerable<Type> AllCandleTypes { get; }
Property Value
AllSecurity
"All securities" instance.
public static SecurityMessage AllSecurity { get; }
Property Value
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
TransactionalMessageTypes
Transactional message types.
public static IEnumerable<MessageTypes> TransactionalMessageTypes { get; }
Property Value
Methods
AddDelta(IOrderBookMessage, IOrderBookMessage)
To add change to the first order book.
public static QuoteChangeMessage AddDelta(this IOrderBookMessage from, IOrderBookMessage delta)
Parameters
from
IOrderBookMessageFirst order book.
delta
IOrderBookMessageChange.
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
boolThe 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
MessageAdapterAdapter.
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
BoardMessageBoard info.
date
DateTimeOffsetThe start T date, to which are added or subtracted N trading days.
n
intThe N size. The number of trading days for the addition or subtraction.
checkHolidays
boolWhether 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
MessageAdapterAdapter.
dataType
DataTypeData type info.
AddSupportedMessage(MessageAdapter, MessageTypeInfo)
Add the message type info PossibleSupportedMessages.
public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypeInfo info)
Parameters
adapter
MessageAdapterAdapter.
info
MessageTypeInfoExtended info for MessageTypes.
AddSupportedMessage(MessageAdapter, MessageTypes)
Add the message type info SupportedInMessages.
[Obsolete]
public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypes type)
Parameters
adapter
MessageAdapterAdapter.
type
MessageTypesMessage type.
AddSupportedMessage(MessageAdapter, MessageTypes, bool?)
Add the message type info SupportedInMessages.
public static void AddSupportedMessage(this MessageAdapter adapter, MessageTypes type, bool? isMarketData)
Parameters
adapter
MessageAdapterAdapter.
type
MessageTypesMessage 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
MessageAdapterAdapter.
type
MessageTypesMessage type.
AddTransactionalSupport(MessageAdapter)
Fill the SupportedInMessages message types related to transactional.
public static void AddTransactionalSupport(this MessageAdapter adapter)
Parameters
adapter
MessageAdapterAdapter.
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
TMessageChange message.
type
TChangeChange type.
value
CurrencyTypesChange 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
TMessageChange message.
type
TChangeChange type.
value
PortfolioStatesChange 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
TMessageChange message.
type
TChangeChange type.
value
SecurityStatesChange 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
TMessageChange message.
type
TChangeChange type.
value
SidesChange 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
TMessageChange message.
type
TChangeChange type.
value
boolChange 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
TMessageChange message.
type
TChangeChange type.
value
DateTimeOffsetChange 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
TMessageChange message.
type
TChangeChange type.
value
decimalChange 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
TMessageChange message.
type
TChangeChange type.
value
intChange 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
TMessageChange message.
type
TChangeChange type.
value
longChange 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
TMessageChange message.
type
TChangeChange type.
value
objectChange 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
decimalNew balance.
transactionId
longTransaction id.
logs
ILogReceiverLogs.
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
ILogReceiverLogs.
Returns
- IEnumerable<QuoteChangeMessage>
Order books.
ChangeSupported(IMessageAdapter, bool, bool)
Change SupportedInMessages.
public static void ChangeSupported(this IMessageAdapter adapter, bool add, bool isMarketData)
Parameters
adapter
IMessageAdapterAdapter.
add
boolCommand.
isMarketData
boolMessage types.
CreateAdapter(Type)
Create IMessageAdapter instance.
public static IMessageAdapter CreateAdapter(this Type adapterType)
Parameters
adapterType
TypeAdapter type.
Returns
- IMessageAdapter
IMessageAdapter instance.
CreateAdapter(Type, IdGenerator)
Create IMessageAdapter.
public static IMessageAdapter CreateAdapter(this Type adapterType, IdGenerator idGenerator)
Parameters
adapterType
TypeAdapter type.
idGenerator
IdGeneratorTransaction 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
MessageOriginal message.
ex
ExceptionError.
logs
ILogReceiverLogs.
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
longID 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
IMessageAdapterAdapter.
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
TypeType of OrderCondition.
Returns
- OrderCondition
Order condition.
CreateOrderLogMarketDepthBuilder(Type, SecurityId)
Create IOrderLogMarketDepthBuilder instance.
public static IOrderLogMarketDepthBuilder CreateOrderLogMarketDepthBuilder(this Type builderType, SecurityId securityId)
Parameters
builderType
TypeBuilder type.
securityId
SecurityIdSecurity ID.
Returns
CreateOrderReply(long, DateTimeOffset)
Create order's transaction reply.
public static ExecutionMessage CreateOrderReply(this long transactionId, DateTimeOffset serverTime)
Parameters
transactionId
longTransaction ID.
serverTime
DateTimeOffsetServer 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
IMessageAdapterTrading system adapter.
pfName
stringPortfolio 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
IMessageAdapterTrading system adapter.
pfName
stringPortfolio name.
securityId
SecurityIdSecurity ID.
depoName
stringThe depositary where the physical security.
Returns
- PositionChangeMessage
Position change message.
CreateReply(OrderMessage, Exception)
Cast OrderMessage to the ExecutionMessage.
public static ExecutionMessage CreateReply(this OrderMessage message, Exception error = null)
Parameters
message
OrderMessageerror
ExceptionError info.
Returns
CreateResponse(ISubscriptionMessage, Exception)
Create subscription response.
public static SubscriptionResponseMessage CreateResponse(this ISubscriptionMessage message, Exception error = null)
Parameters
message
ISubscriptionMessageSubscription.
error
ExceptionError info.
Returns
- SubscriptionResponseMessage
Subscription response message.
CreateResult(ISubscriptionMessage)
Create SubscriptionOnlineMessage or SubscriptionFinishedMessage depends of To.
public static Message CreateResult(this ISubscriptionMessage message)
Parameters
message
ISubscriptionMessageSubscription.
Returns
- Message
Message.
CreateSubscriptionResponse(long, Exception)
Create subscription response.
public static SubscriptionResponseMessage CreateSubscriptionResponse(this long id, Exception error = null)
Parameters
id
longID of the original message for which this message is a response.
error
ExceptionError 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
DataTypeData 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
Returns
- string
Directory name.
DataTypeToFileName(DataType)
Convert file name to DataType.
public static string DataTypeToFileName(this DataType dataType)
Parameters
dataType
DataTypeData type info.
Returns
- string
File name.
DecodeToPeriods(string)
Decode from string to Periods.
public static IEnumerable<WorkingTimePeriod> DecodeToPeriods(this string input)
Parameters
input
stringEncoded 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
stringEncoded 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
Returns
EnsureToday(DateTimeOffset?)
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
stringFile 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
SecurityIdSecurity 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
SecurityMessageA 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
BoardLookupMessageCriteria.
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
SecurityLookupMessageMessage 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
DateTimeOffsetThe start date for searching.
to
DateTimeOffsetThe 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
IMessageAdapterAdapter.
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
IMessageAdapterWrapperWrapping 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
GuidAdapter identifier.
Returns
- IMessageAdapter
Found adapter or null.
FormatToString(DataType)
public static (string type, string arg) FormatToString(this DataType dataType)
Parameters
dataType
DataTypeData type info.
Returns
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
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
MarketDataMessageMarket-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
MarketDataMessageMarket-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
ExecutionMessageThe 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
TypeType.
Returns
- IEnumerable<PropertyInfo>
Properties marked by Ecng.Common.BasicSettingAttribute.
GetBestAsk(IOrderBookMessage)
Get best ask.
public static QuoteChange? GetBestAsk(this IOrderBookMessage message)
Parameters
message
IOrderBookMessageMarket 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
IOrderBookMessageMarket 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
Returns
- (QuoteChange? bid, QuoteChange? ask)
Best pair.
GetCandleArgType(Type)
Get candle arg type.
public static Type GetCandleArgType(this Type candleMessageType)
Parameters
candleMessageType
TypeCandle 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
IMessageAdapterAdapter.
candleType
TypeThe type of the message CandleMessage.
securityId
SecurityIdSecurity 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
TimeSpanThe time frame for which you need to get time range.
currentTime
DateTimeOffsetThe 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
TimeSpanThe time frame for which you need to get time range.
currentTime
DateTimeOffsetThe current time within the range of time frames.
timeZone
TimeZoneInfoInformation about the time zone where the exchange is located.
time
WorkingTimeThe 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
DataTypeData 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
IOrderBookMessageFirst order book.
to
IOrderBookMessageSecond 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
IMessageAdapterTrading system adapter.
securityId
SecurityIddataType
DataTypeData type info.
iterationInterval
TimeSpanInterval between iterations.
Returns
- TimeSpan
Step.
GetId<T>(CommandMessage)
Get typed ObjectId.
public static T GetId<T>(this CommandMessage message)
Parameters
message
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
Level1ChangeMessageMarket depth.
Returns
GetMatchedVolume(IOrderMessage)
To calculate the implemented part of volume for order.
public static decimal GetMatchedVolume(this IOrderMessage order)
Parameters
order
IOrderMessageThe 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
ExecutionMessageOrder 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
IOrderBookMessagedepthIndex
intDepth 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
WorkingTimeTrading schedule.
date
DateTimeThe 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
longBits flag.
Returns
GetPreferredLanguage(MessageAdapterCategories?)
Get preferred language.
public static string GetPreferredLanguage(this MessageAdapterCategories? categories)
Parameters
categories
MessageAdapterCategories?Message adapter categories.
Returns
- string
Language
GetPrice(IOrderBookMessage, Sides?)
Get price by side.
public static decimal? GetPrice(this IOrderBookMessage message, Sides? side)
Parameters
message
IOrderBookMessageside
Sides?
Returns
- decimal?
Price.
GetPriceStep(int)
To get the price increment on the basis of accuracy.
public static decimal GetPriceStep(this int decimals)
Parameters
decimals
intDecimals.
Returns
- decimal
Price step.
GetSecurityTypes(SecurityLookupMessage)
Get SecurityTypes.
public static HashSet<SecurityTypes> GetSecurityTypes(this SecurityLookupMessage message)
Parameters
message
SecurityLookupMessageMessage 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
MessageMessage.
Returns
- DateTimeOffset
Server time.
GetSpreadMiddle(IOrderBookMessage, decimal?)
Get middle of spread.
public static decimal? GetSpreadMiddle(this IOrderBookMessage message, decimal? priceStep)
Parameters
message
IOrderBookMessageMarket depth.
priceStep
decimal?
Returns
GetSpreadMiddle(Level1ChangeMessage, decimal?)
Get middle of spread.
public static decimal? GetSpreadMiddle(this Level1ChangeMessage message, decimal? priceStep)
Parameters
message
Level1ChangeMessageMarket depth.
priceStep
decimal?
Returns
GetSpreadMiddle(decimal, decimal, decimal?)
Get middle of spread.
public static decimal GetSpreadMiddle(this decimal bestBidPrice, decimal bestAskPrice, decimal? priceStep)
Parameters
Returns
GetSpreadMiddle(decimal?, decimal?, decimal?)
Get middle of spread.
public static decimal? GetSpreadMiddle(this decimal? bestBidPrice, decimal? bestAskPrice, decimal? priceStep)
Parameters
Returns
GetSubscriptionIds(ISubscriptionIdMessage)
Get subscription identifiers from the specified message.
public static long[] GetSubscriptionIds(this ISubscriptionIdMessage message)
Parameters
message
ISubscriptionIdMessageMessage.
Returns
- long[]
Identifiers.
GetSupportedDataTypes(IMessageAdapter)
Get supported y adapter data types.
public static IEnumerable<DataType> GetSupportedDataTypes(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- IEnumerable<DataType>
Supported by adapter data types.
GetTimeFrame(DataType)
Get time-frame.
public static TimeSpan GetTimeFrame(this DataType dataType)
Parameters
Returns
- TimeSpan
Time-frame.
GetTimeFrame(MarketDataMessage)
Get time-frame from the specified market-data message.
public static TimeSpan GetTimeFrame(this MarketDataMessage mdMsg)
Parameters
mdMsg
MarketDataMessageMarket-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
TimeSpanThe time frame size.
workingTime
WorkingTimetimeZone
TimeZoneInfoInformation 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
IMessageAdapterTrading system adapter.
securityId
SecurityIdSecurity 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
IOrderBookMessagedepth
intBook 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
IOrderBookMessagedepth
intBook depth. Quotes are in order of price increasing from bids to offers.
Returns
- IEnumerable<QuoteChange>
Spread.
GetTradePrice(ExecutionMessage)
Get TradePrice.
public static decimal GetTradePrice(this ExecutionMessage message)
Parameters
message
ExecutionMessageThe 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
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
IOrderBookMessageThe order book to be grouped.
priceRange
UnitThe 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
IOrderBookMessageThe order book to be grouped.
priceRange
decimalThe 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
SidespriceRange
Unit
Returns
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
SidesSide.
priceRange
decimalThe 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
OrderStatusMessageMessage.
Returns
- bool
Check result.
HasOrderInfo(ExecutionMessage)
Determines whether the specified message contains order information.
public static bool HasOrderInfo(this ExecutionMessage message)
Parameters
message
ExecutionMessageThe message.
Returns
HasTradeInfo(ExecutionMessage)
Determines whether the specified message contains trade information.
public static bool HasTradeInfo(this ExecutionMessage message)
Parameters
message
ExecutionMessageThe message.
Returns
Invert(Sides)
To change the direction to opposite.
public static Sides Invert(this Sides side)
Parameters
side
SidesThe 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
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
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
SecurityIdSecurity ID.
boardCode
stringBoard code.
Returns
IsBack(IMessage)
Determines the specified message is loopback.
public static bool IsBack(this IMessage message)
Parameters
message
IMessageMessage.
Returns
- bool
Is loopback message.
IsBasket(SecurityMessage)
Is specified security is basket.
public static bool IsBasket(this SecurityMessage security)
Parameters
security
SecurityMessageSecurity.
Returns
- bool
Check result.
IsBestAskField(Level1Fields)
Is the specified Level1Fields is related to best ask.
public static bool IsBestAskField(this Level1Fields field)
Parameters
field
Level1FieldsField.
Returns
- bool
Check result.
IsBestBidField(Level1Fields)
Is the specified Level1Fields is related to best bid.
public static bool IsBestBidField(this Level1Fields field)
Parameters
field
Level1FieldsField.
Returns
- bool
Check result.
IsCanceled(IOrderMessage)
To check, whether the order was cancelled.
public static bool IsCanceled(this IOrderMessage order)
Parameters
order
IOrderMessageThe order to be checked.
Returns
IsCandle(MessageTypes)
Determine the type
is candle data type.
public static bool IsCandle(this MessageTypes type)
Parameters
type
MessageTypesMessage type.
Returns
IsCandleMessage(Type)
Determines whether the specified message type is derived from CandleMessage.
public static bool IsCandleMessage(this Type messageType)
Parameters
messageType
TypeThe 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
IMessageAdapterAdapter.
subscription
MarketDataMessageSubscription.
Returns
IsContainsCandle(Level1ChangeMessage)
To check, are there CandleTimeFrame in the level1 data.
public static bool IsContainsCandle(this Level1ChangeMessage level1)
Parameters
level1
Level1ChangeMessageLevel1 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
Level1ChangeMessageLevel1 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
Level1ChangeMessageLevel1 data.
Returns
- bool
The test result.
IsFinal(OrderStates)
public static bool IsFinal(this OrderStates state)
Parameters
state
OrderStatesOrder state.
Returns
- bool
Check result.
IsFullEmpty(IOrderBookMessage)
To determine, is the order book empty.
public static bool IsFullEmpty(this IOrderBookMessage depth)
Parameters
depth
IOrderBookMessageMarket depth.
Returns
IsHalfEmpty(IOrderBookMessage)
To determine, is the order book half-empty.
public static bool IsHalfEmpty(this IOrderBookMessage depth)
Parameters
depth
IOrderBookMessageMarket depth.
Returns
IsHistoryOnly(ISubscriptionMessage)
Determines the specified message contains historical request only.
public static bool IsHistoryOnly(this ISubscriptionMessage message)
Parameters
message
ISubscriptionMessageSubscription.
Returns
- bool
Check result.
IsIndex(SecurityMessage)
Is specified security is index.
public static bool IsIndex(this SecurityMessage security)
Parameters
security
SecurityMessageSecurity.
Returns
- bool
Check result.
IsIntraday(TimeSpan)
Determines the specified time-frame is intraday.
public static bool IsIntraday(this TimeSpan tf)
Parameters
tf
TimeSpanTime-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
Level1FieldsField.
Returns
- bool
Check result.
IsLookupAll(SecurityLookupMessage)
Determine the criteria
contains lookup all filter.
public static bool IsLookupAll(this SecurityLookupMessage criteria)
Parameters
criteria
SecurityLookupMessageThe 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
ExecutionMessageThe 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
IMessageAdapterAdapter.
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
IMessageAdapterAdapter.
type
DataTypeMessage type.
Returns
IsMatch(BoardMessage, BoardLookupMessage)
Determines the specified message is matched lookup criteria.
public static bool IsMatch(this BoardMessage board, BoardLookupMessage criteria)
Parameters
board
BoardMessageBoard.
criteria
BoardLookupMessageThe 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
ExecutionMessageTransaction.
criteria
OrderStatusMessageThe 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
ExecutionMessageTransaction.
criteria
OrderStatusMessageThe 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
ISubscriptionIdMessageMessage.
type
MessageTypescriteria
ISubscriptionMessageThe 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
PortfolioMessagePortfolio.
criteria
PortfolioLookupMessageThe message which fields will be used as a filter.
compareName
boolFully 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
PositionChangeMessagePosition.
criteria
PortfolioLookupMessageThe message which fields will be used as a filter.
compareName
boolFully 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
SecurityMessageSecurity.
criteria
SecurityLookupMessageMessage 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
SecurityMessageSecurity.
criteria
SecurityLookupMessageMessage 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
IOrderMessageThe order to be checked.
Returns
IsMatchedEmpty(IOrderMessage)
To check, if no contract in order is implemented.
public static bool IsMatchedEmpty(this IOrderMessage order)
Parameters
order
IOrderMessageThe order to be checked.
Returns
IsMatchedPartially(IOrderMessage)
To check, is a part of volume is implemented in the order.
public static bool IsMatchedPartially(this IOrderMessage order)
Parameters
order
IOrderMessageThe order to be checked.
Returns
IsMessageSupported(IMessageAdapter, MessageTypes)
Determines whether the specified message type is contained in SupportedInMessages.
public static bool IsMessageSupported(this IMessageAdapter adapter, MessageTypes type)
Parameters
adapter
IMessageAdapterAdapter.
type
MessageTypesMessage type.
Returns
IsMoney(PositionChangeMessage)
Determines the specified message contains Money position.
public static bool IsMoney(this PositionChangeMessage posMsg)
Parameters
posMsg
PositionChangeMessageThe 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
SecurityIdThe 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
SubscriptionResponseMessageReply.
Returns
- bool
Check result.
IsObsolete(Level1Fields)
Is the specified Level1Fields was obsolete.
public static bool IsObsolete(this Level1Fields field)
Parameters
field
Level1FieldsLevel1Fields value.
Returns
IsObsolete(PositionChangeTypes)
Is the specified PositionChangeTypes was marked by ObsoleteAttribute.
public static bool IsObsolete(this PositionChangeTypes type)
Parameters
type
PositionChangeTypesPositionChangeTypes value.
Returns
IsOk(SubscriptionResponseMessage)
Determines whether the reply contains an error Error.
public static bool IsOk(this SubscriptionResponseMessage message)
Parameters
message
SubscriptionResponseMessageReply.
Returns
- bool
Check result.
IsOpened(IMessageChannel)
Is channel opened.
public static bool IsOpened(this IMessageChannel channel)
Parameters
channel
IMessageChannelMessage 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
ExecutionMessageOrder log item.
Returns
IsOrderLogMatched(ExecutionMessage)
To check, does the string contain the order matching.
public static bool IsOrderLogMatched(this ExecutionMessage item)
Parameters
item
ExecutionMessageOrder log item.
Returns
IsOrderLogRegistered(ExecutionMessage)
To check, does the string contain the order registration.
public static bool IsOrderLogRegistered(this ExecutionMessage item)
Parameters
item
ExecutionMessageOrder log item.
Returns
IsPlazaSystem(long)
Extract system attribute from the bits flag.
public static bool IsPlazaSystem(this long status)
Parameters
status
longBits flag.
Returns
IsResultMessageSupported(IMessageAdapter, MessageTypes)
Determines whether the specified message type is contained in SupportedResultMessages..
public static bool IsResultMessageSupported(this IMessageAdapter adapter, MessageTypes type)
Parameters
adapter
IMessageAdapterAdapter.
type
MessageTypesMessage type.
Returns
IsSet(Unit)
Determines the value is set.
public static bool IsSet(this Unit value)
Parameters
Returns
- bool
Check result.
IsStorageSupported(DataType)
Determines whether the specified data type is supported by the storage.
public static bool IsStorageSupported(this DataType dataType)
Parameters
Returns
- bool
Check result.
IsSupportSecuritiesLookupAll(IMessageAdapter)
Support lookup all securities.
public static bool IsSupportSecuritiesLookupAll(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- bool
Check result.
IsSupportStopLoss(IMessageAdapter)
Determines whether the adapter support stop-loss orders.
public static bool IsSupportStopLoss(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- bool
Check result.
IsSupportSubscriptionByPortfolio(IMessageAdapter)
Support portfolio subscriptions.
public static bool IsSupportSubscriptionByPortfolio(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- bool
Check result.
IsSupportTakeProfit(IMessageAdapter)
Determines whether the adapter support take-profit orders.
public static bool IsSupportTakeProfit(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- bool
Check result.
IsSupportWithdraw(IMessageAdapter)
Determines whether the adapter support withdraw orders.
public static bool IsSupportWithdraw(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
Returns
- bool
Check result.
IsToday(DateTimeOffset)
To check the specified date is today.
public static bool IsToday(this DateTimeOffset date)
Parameters
date
DateTimeOffsetThe specified date.
Returns
IsToday(DateTimeOffset?)
To check the specified date is today.
public static bool IsToday(this DateTimeOffset? date)
Parameters
date
DateTimeOffset?The specified date.
Returns
IsTradeDate(BoardMessage, DateTimeOffset, bool)
To check, whether date is traded.
public static bool IsTradeDate(this BoardMessage board, DateTimeOffset date, bool checkHolidays = false)
Parameters
board
BoardMessageBoard info.
date
DateTimeOffsetThe passed date to be checked.
checkHolidays
boolWhether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).
Returns
IsTradeDate(WorkingTime, DateTime, bool)
To check, whether date is traded.
public static bool IsTradeDate(this WorkingTime workingTime, DateTime date, bool checkHolidays = false)
Parameters
workingTime
WorkingTimeBoard working hours.
date
DateTimeThe passed date to be checked.
checkHolidays
boolWhether to check the passed date for a weekday (Saturday and Sunday are days off, returned value for them is false).
Returns
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
BoardMessageBoard info.
time
DateTimeOffsetThe passed time to be checked.
Returns
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
BoardMessageBoard info.
time
DateTimeOffsetThe passed time to be checked.
isWorkingDay
bool?true, if the date is traded, otherwise, is not traded.
period
WorkingTimePeriodCurrent working time period.
Returns
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
WorkingTimeBoard working hours.
time
DateTimeThe passed time to be checked.
isWorkingDay
bool?true, if the date is traded, otherwise, is not traded.
period
WorkingTimePeriodCurrent working time period.
Returns
IsTransactional(IMessageAdapter)
Is the specified adapter support transactions.
public static bool IsTransactional(this IMessageAdapter adapter)
Parameters
adapter
IMessageAdapterAdapter.
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
SecurityMessageSecurity.
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
stringType 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
stringType 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
IOrderBookMessageThe initial order book.
rare
IOrderBookMessageThe 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
BoardMessageBoard info.
date
DateTimeOffsetThe date from which to start checking.
checkHolidays
boolWhether 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
ISecurityMessageProviderThe provider of information about instruments.
code
stringSecurity 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
TMessageMessage.
adapter
IMessageAdapterAdapter.
mode
MessageBackModesBack 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
NearestSupportedDepth(IMessageAdapter, int)
Get the nearest supported depth for the specified.
public static int? NearestSupportedDepth(this IMessageAdapter adapter, int depth)
Parameters
adapter
IMessageAdapterAdapter.
depth
intDepth.
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
TypeThe type of candle message.
type
MessageTypesMessage type.
dataType
MarketDataTypesCandles type.
fileName
stringFile 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
MessageAdapterAdapter.
RemoveSupportedAllMarketDataTypes(MessageAdapter)
Remove all market data types from SupportedMarketDataTypes.
public static void RemoveSupportedAllMarketDataTypes(this MessageAdapter adapter)
Parameters
adapter
MessageAdapterAdapter.
RemoveSupportedMarketDataType(MessageAdapter, DataType)
Remove market data type from SupportedMarketDataTypes.
public static void RemoveSupportedMarketDataType(this MessageAdapter adapter, DataType type)
Parameters
adapter
MessageAdapterAdapter.
type
DataTypeMarket data type.
RemoveSupportedMessage(MessageAdapter, MessageTypes)
Remove the message type from PossibleSupportedMessages.
public static void RemoveSupportedMessage(this MessageAdapter adapter, MessageTypes type)
Parameters
adapter
MessageAdapterAdapter.
type
MessageTypesMessage type.
RemoveSupportedResultMessage(MessageAdapter, MessageTypes)
Remove the message type from SupportedResultMessages.
public static void RemoveSupportedResultMessage(this MessageAdapter adapter, MessageTypes type)
Parameters
adapter
MessageAdapterAdapter.
type
MessageTypesMessage type.
RemoveTransactionalSupport(MessageAdapter)
Remove from SupportedInMessages message types related to transactional.
public static void RemoveTransactionalSupport(this MessageAdapter adapter)
Parameters
adapter
MessageAdapterAdapter.
ReplaceSecurityId(Message, SecurityId)
Replace security id by the specified.
public static Message ReplaceSecurityId(this Message message, SecurityId securityId)
Parameters
message
MessageMessage.
securityId
SecurityIdSecurity ID.
Returns
- Message
Message.
SafeGetOrderId(ExecutionMessage)
To get order identifier, or discard exception, if no information available.
public static long SafeGetOrderId(this ExecutionMessage message)
Parameters
message
ExecutionMessageOperations.
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
ExecutionMessageOperations.
Returns
- decimal
Quantity.
SetArg<TArg>(MarketDataMessage, TArg)
Set typed argument.
public static MarketDataMessage SetArg<TArg>(this MarketDataMessage mdMsg, TArg arg)
Parameters
mdMsg
MarketDataMessageMarket-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
arg
TArgThe 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
CommandMessageid
TTyped ObjectId.
Type Parameters
T
Type of ObjectId.
SetNativeId(SecurityId, object)
Initialize Native.
public static SecurityId SetNativeId(this SecurityId secId, object nativeId)
Parameters
secId
SecurityIdSecurity ID.
nativeId
objectNative (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
SecurityMessageA message containing info about the security.
secCode
stringSecurity code.
SetSecurityTypes(SecurityLookupMessage, SecurityTypes?, IEnumerable<SecurityTypes>)
Initialize SecurityTypes.
public static void SetSecurityTypes(this SecurityLookupMessage message, SecurityTypes? type, IEnumerable<SecurityTypes> types = null)
Parameters
message
SecurityLookupMessageMessage 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
Returns
- TMessage
Message.
Type Parameters
TMessage
Message type.
ShrinkPrice(decimal, SecurityMessage, 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, SecurityMessage secMsg, ShrinkRules rule = ShrinkRules.Auto)
Parameters
price
decimalThe price to be made multiple.
secMsg
SecurityMessagerule
ShrinkRules
Returns
- decimal
The multiple price.
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
decimalThe 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
IOrderBookMessagepriceRange
UnitpriceStep
decimal?
Returns
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
IOrderBookMessageThe regular order book.
priceRange
decimalMinimum 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
QuoteChangeask
QuoteChangepriceRange
UnitpriceStep
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
QuoteChangeBid.
ask
QuoteChangeAsk.
priceRange
decimalMinimum 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
SidesSide.
priceRange
UnitMinimum 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
SidesSide.
priceRange
decimalMinimum 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
stringSymbol.
Returns
TimeFrame(TimeSpan)
Create data type info for TimeFrameCandleMessage.
public static DataType TimeFrame(this TimeSpan tf)
Parameters
tf
TimeSpanCandle 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
MessageTypesCandle 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
MessageTypesMessage type.
Returns
- Type
Candles type.
ToDataType(ExecutionTypes)
Convert ExecutionTypes to DataType value.
public static DataType ToDataType(this ExecutionTypes type)
Parameters
type
ExecutionTypes
Returns
ToDataType(MarketDataTypes, object)
Convert MarketDataTypes to DataType value.
[Obsolete]
public static DataType ToDataType(this MarketDataTypes type, object arg)
Parameters
type
MarketDataTypesMarket data type.
arg
objectThe additional argument, associated with data. For example, candle argument.
Returns
- DataType
Data type info.
ToDataType(string, string)
public static DataType ToDataType(this string type, string arg)
Parameters
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
Returns
- object
Argument.
ToErrorMessage(Exception, long)
Convert error info into ErrorMessage.
public static ErrorMessage ToErrorMessage(this Exception error, long originalTransactionId = 0)
Parameters
error
ExceptionError info.
originalTransactionId
longID 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
stringError text message.
Returns
- ErrorMessage
ErrorMessage instance.
ToExec(OrderRegisterMessage)
Convert OrderRegisterMessage to ExecutionMessage.
public static ExecutionMessage ToExec(this OrderRegisterMessage regMsg)
Parameters
regMsg
OrderRegisterMessageThe 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
Returns
ToInfo(MessageTypes, bool?)
Convert MessageTypes to MessageTypeInfo value.
public static MessageTypeInfo ToInfo(this MessageTypes type, bool? isMarketData = null)
Parameters
type
MessageTypesMessageTypes value.
isMarketData
bool?Market data.
Returns
- MessageTypeInfo
MessageTypeInfo value.
ToLevel1(CandleMessage)
Convert CandleMessage to Level1ChangeMessage value.
public static Level1ChangeMessage ToLevel1(this CandleMessage message)
Parameters
message
CandleMessageCandleMessage instance.
Returns
- Level1ChangeMessage
Level1ChangeMessage instance.
ToLevel1(ExecutionMessage)
Convert ExecutionMessage to Level1ChangeMessage value.
public static Level1ChangeMessage ToLevel1(this ExecutionMessage message)
Parameters
message
ExecutionMessageExecutionMessage instance.
Returns
- Level1ChangeMessage
Level1ChangeMessage instance.
ToLevel1(IOrderBookMessage)
Convert IOrderBookMessage to Level1ChangeMessage value.
public static Level1ChangeMessage ToLevel1(this IOrderBookMessage message)
Parameters
message
IOrderBookMessageIOrderBookMessage 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
IOrderLogMarketDepthBuilderOrder log to market depth builder.
interval
TimeSpanThe 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
DataTypeData 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
MarketDataTypesMarket data type.
arg
objectThe 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
MessageTypesMessageTypes value.
Returns
ToMessageType(Type)
Convert Type to MessageTypes value.
public static MessageTypes ToMessageType(this Type type)
Parameters
Returns
- MessageTypes
MessageTypes value.
ToMessageType2(DataType)
Convert DataType to MessageTypes value.
public static MessageTypes ToMessageType2(this DataType type)
Parameters
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
CurrencyTypesCurrency 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
stringstring value.
generator
SecurityIdGeneratorThe 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
IOrderLogMarketDepthBuilderOrder log to market depth builder.
interval
TimeSpanThe interval of the order book generation. The default is Zero, which means order books generation at each new item of orders log.
maxDepth
intThe 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
longTransaction ID.
logs
ILogReceiverLogs.
Returns
- ExecutionMessage
Snapshot.
ToReadableString(DataType)
Convert DataType to readable string.
public static string ToReadableString(this DataType dt)
Parameters
Returns
- string
Readable string.
ToReg(ExecutionMessage)
Convert ExecutionMessage to OrderRegisterMessage.
public static OrderRegisterMessage ToReg(this ExecutionMessage execMsg)
Parameters
execMsg
ExecutionMessageThe 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
stringstring value.
generator
SecurityIdGeneratorThe 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
SecurityIdSecurityId value.
generator
SecurityIdGeneratorThe instrument identifiers generator SecurityId. Can be null.
nullIfEmpty
boolReturn 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
ExecutionMessageOrder log item.
Returns
- ExecutionMessage
Tick trade.
ToTick(Level1ChangeMessage)
To convert level1 data into tick data.
public static ExecutionMessage ToTick(this Level1ChangeMessage level1)
Parameters
level1
Level1ChangeMessageLevel1 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
Level1FieldsLevel1Fields value.
Returns
ToType(PositionChangeTypes)
Convert PositionChangeTypes to Type value.
public static Type ToType(this PositionChangeTypes type)
Parameters
type
PositionChangeTypesPositionChangeTypes value.
Returns
Truncate(IOrderBookMessage, int)
Truncate the specified order book by max depth value.
public static QuoteChangeMessage Truncate(this IOrderBookMessage depth, int maxDepth)
Parameters
depth
IOrderBookMessageOrder book.
maxDepth
intThe 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
TMessageChange message.
type
TChangeChange type.
value
decimalChange value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange type.
value
intChange value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange type.
value
longChange value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange 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
TMessageChange message.
type
TChangeChange type.
value
decimal?Change value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange type.
value
int?Change value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange type.
value
long?Change value.
isZeroAcceptable
boolIs 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
TMessageChange message.
type
TChangeChange type.
value
stringChange 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
SecurityMessageunderlyingCode
stringUnderlying asset id.
Returns
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
stringdefaultValue
string
Returns
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
TMessageChange message.
type
TChangeChange 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
MessageMessage.
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
MessageMessage.
serverTime
DateTimeOffsetServer 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
TypeComponent 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
TMessageChange message.
type
TChangeChange 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
MessageMessage.
source
ILogSourceSource.
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
IMessageAdapterAdapter.
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
IOrderBookMessageThe grouped order book.
Returns
- QuoteChangeMessage
The de-grouped order book.
UndoBack<TMessage>(TMessage)
Undo operation made via LoopBack<TMessage>(TMessage, IMessageAdapter, MessageBackModes).
public static TMessage UndoBack<TMessage>(this TMessage message) where TMessage : IMessage
Parameters
message
TMessageMessage.
Returns
- TMessage
Message.
Type Parameters
TMessage
Message type.
ValidateBounds(MarketDataMessage)
public static MarketDataMessage ValidateBounds(this MarketDataMessage message)
Parameters
message
MarketDataMessageMessage.
Returns
- MarketDataMessage
Message.
ValidateCandleArg(Type, object)
Validate candle arg.
public static bool ValidateCandleArg(this Type candleMessageType, object value)
Parameters
Returns
- bool
Check result.
ValidateChannelState(ChannelStates, ChannelStates)
Validate state change.
public static bool ValidateChannelState(this ChannelStates currState, ChannelStates newState)
Parameters
currState
ChannelStatesCurrent state.
newState
ChannelStatesNew state.
Returns
Verify(IOrderBookMessage)
To determine whether the order book is in the right state.
public static bool Verify(this IOrderBookMessage book)
Parameters
book
IOrderBookMessageOrder book.
Returns
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
OrderStatesNew state.
transactionId
longTransaction id.
logs
ILogReceiverLogs.
Returns
- bool
Check result.