Table of Contents

Class EntitiesExtensions

Namespace
StockSharp.BusinessEntities
Assembly
StockSharp.BusinessEntities.dll

Extension class for StockSharp.BusinessEntities.

public static class EntitiesExtensions
Inheritance
EntitiesExtensions
Inherited Members

Fields

LookupAllCriteria

Lookup all securities predefined criteria.

public static readonly Security LookupAllCriteria

Field Value

Security

MoneySecurity

"Money" security instance.

public static readonly Security MoneySecurity

Field Value

Security

NewsSecurity

"News" security instance.

public static readonly Security NewsSecurity

Field Value

Security

Properties

AllCandleMessageTypes

All registered candle message types.

public static IEnumerable<Type> AllCandleMessageTypes { get; }

Property Value

IEnumerable<Type>

AllCandleTypes

All registered candle types.

public static IEnumerable<Type> AllCandleTypes { get; }

Property Value

IEnumerable<Type>

AllSecurity

"All securities" instance.

public static Security AllSecurity { get; }

Property Value

Security

Methods

AddOrSubtractTradingDays(ExchangeBoard, DateTimeOffset, int, bool)

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

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

Parameters

board ExchangeBoard

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.

ApplyChanges(ExchangeBoard, BoardMessage)

To convert the message into board.

public static ExchangeBoard ApplyChanges(this ExchangeBoard board, BoardMessage message)

Parameters

board ExchangeBoard

Board.

message BoardMessage

Message.

Returns

ExchangeBoard

Board.

ApplyChanges(Portfolio, PositionChangeMessage, IExchangeInfoProvider)

Apply changes to the portfolio object.

public static void ApplyChanges(this Portfolio portfolio, PositionChangeMessage message, IExchangeInfoProvider exchangeInfoProvider)

Parameters

portfolio Portfolio

Portfolio.

message PositionChangeMessage

Portfolio change message.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

ApplyChanges(Position, PositionChangeMessage)

Apply changes to the position object.

public static void ApplyChanges(this Position position, PositionChangeMessage message)

Parameters

position Position

Position.

message PositionChangeMessage

Position change message.

ApplyChanges(Security, Level1ChangeMessage)

Apply change to the security object.

public static void ApplyChanges(this Security security, Level1ChangeMessage message)

Parameters

security Security

Security.

message Level1ChangeMessage

Changes.

ApplyChanges(Security, SecurityMessage, IExchangeInfoProvider, bool)

Apply change to the security object.

public static void ApplyChanges(this Security security, SecurityMessage message, IExchangeInfoProvider exchangeInfoProvider, bool isOverride = true)

Parameters

security Security

Security.

message SecurityMessage

Meta info.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

isOverride bool

Override previous security data by new values.

ApplyChanges(Security, IEnumerable<KeyValuePair<Level1Fields, object>>, DateTimeOffset, DateTimeOffset, Action<Security, Level1Fields, object>)

Apply change to the security object.

public static void ApplyChanges(this Security security, IEnumerable<KeyValuePair<Level1Fields, object>> changes, DateTimeOffset serverTime, DateTimeOffset localTime, Action<Security, Level1Fields, object> defaultHandler = null)

Parameters

security Security

Security.

changes IEnumerable<KeyValuePair<Level1Fields, object>>

Changes.

serverTime DateTimeOffset

Change server time.

localTime DateTimeOffset

Local timestamp when a message was received/created.

defaultHandler Action<Security, Level1Fields, object>

Default handler.

ApplyNewState(Order, OrderStates, ILogReceiver)

Check the possibility order's state change.

public static void ApplyNewState(this Order order, OrderStates state, ILogReceiver logs = null)

Parameters

order Order

Order.

state OrderStates

Current order's state.

logs ILogReceiver

Logs.

Convert(Unit, UnitTypes, Security)

Cast the value to another type.

public static Unit Convert(this Unit unit, UnitTypes destinationType, Security security)

Parameters

unit Unit

Source unit.

destinationType UnitTypes

Destination value type.

security Security

Information about the instrument. Required when using Point и Step.

Returns

Unit

Converted value.

CreateCancelMessage(Order, SecurityId, long)

To create the message of cancelling old order.

public static OrderCancelMessage CreateCancelMessage(this Order order, SecurityId securityId, long transactionId)

Parameters

order Order

Order.

securityId SecurityId

Security ID.

transactionId long

The transaction number.

Returns

OrderCancelMessage

Message.

CreateCandleMessage(Type)

Create instance of CandleMessage.

public static CandleMessage CreateCandleMessage(this Type messageType)

Parameters

messageType Type

The type of candle message.

Returns

CandleMessage

Instance of CandleMessage.

CreateRegisterMessage(Order, SecurityId?)

To create the message of new order registration.

public static OrderRegisterMessage CreateRegisterMessage(this Order order, SecurityId? securityId = null)

Parameters

order Order

Order.

securityId SecurityId?

Security ID.

Returns

OrderRegisterMessage

Message.

CreateReplaceMessage(Order, Order, SecurityId)

To create the message of replacing old order with new one.

public static OrderReplaceMessage CreateReplaceMessage(this Order oldOrder, Order newOrder, SecurityId securityId)

Parameters

oldOrder Order

Old order.

newOrder Order

New order.

securityId SecurityId

Security ID.

Returns

OrderReplaceMessage

Message.

EnumerateExchangeBoards()

To get a list of boards.

public static IEnumerable<ExchangeBoard> EnumerateExchangeBoards()

Returns

IEnumerable<ExchangeBoard>

Boards.

EnumerateExchanges()

To get a list of exchanges.

public static IEnumerable<Exchange> EnumerateExchanges()

Returns

IEnumerable<Exchange>

Exchanges.

FillMessage<TMessage>(Security, TMessage)

To convert the instrument into message.

public static TMessage FillMessage<TMessage>(this Security security, TMessage message) where TMessage : SecurityMessage

Parameters

security Security

Security.

message TMessage

Message.

Returns

TMessage

Message.

Type Parameters

TMessage

Message type.

Filter(IEnumerable<ExchangeBoard>, BoardLookupMessage)

Filter boards by code criteria.

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

Parameters

boards IEnumerable<ExchangeBoard>

All boards.

criteria BoardLookupMessage

Criteria.

Returns

IEnumerable<ExchangeBoard>

Found boards.

Filter(IEnumerable<MyTrade>, Order)

To filter own trades for the given order.

public static IEnumerable<MyTrade> Filter(this IEnumerable<MyTrade> myTrades, Order order)

Parameters

myTrades IEnumerable<MyTrade>

All own trades, in which the required shall be looked for.

order Order

The order, for which trades shall be filtered.

Returns

IEnumerable<MyTrade>

Filtered orders.

Filter(IEnumerable<MyTrade>, Portfolio)

To filter own trades for the given portfolio.

public static IEnumerable<MyTrade> Filter(this IEnumerable<MyTrade> myTrades, Portfolio portfolio)

Parameters

myTrades IEnumerable<MyTrade>

All own trades, in which the required shall be looked for.

portfolio Portfolio

The portfolio, for which the trades shall be filtered.

Returns

IEnumerable<MyTrade>

Filtered trades.

Filter(IEnumerable<Order>, Portfolio)

To filter orders for the given portfolio.

public static IEnumerable<Order> Filter(this IEnumerable<Order> orders, Portfolio portfolio)

Parameters

orders IEnumerable<Order>

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

portfolio Portfolio

The portfolio, for which the orders shall be filtered.

Returns

IEnumerable<Order>

Filtered orders.

Filter(IEnumerable<Order>, OrderStates)

To filter orders for the given condition.

public static IEnumerable<Order> Filter(this IEnumerable<Order> orders, OrderStates state)

Parameters

orders IEnumerable<Order>

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

state OrderStates

Order state.

Returns

IEnumerable<Order>

Filtered orders.

Filter(IEnumerable<Order>, Sides)

To filter orders for the given direction.

public static IEnumerable<Order> Filter(this IEnumerable<Order> orders, Sides side)

Parameters

orders IEnumerable<Order>

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

side Sides

Order side.

Returns

IEnumerable<Order>

Filtered orders.

Filter(IEnumerable<Portfolio>, PortfolioLookupMessage)

Filter portfolios by the specified criteria.

public static IEnumerable<Portfolio> Filter(this IEnumerable<Portfolio> portfolios, PortfolioLookupMessage criteria)

Parameters

portfolios IEnumerable<Portfolio>

All portfolios.

criteria PortfolioLookupMessage

Criteria.

Returns

IEnumerable<Portfolio>

Found portfolios.

Filter(IEnumerable<Position>, Portfolio)

To filter positions for the given portfolio.

public static IEnumerable<Position> Filter(this IEnumerable<Position> positions, Portfolio portfolio)

Parameters

positions IEnumerable<Position>

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

portfolio Portfolio

The portfolio, for which positions shall be filtered.

Returns

IEnumerable<Position>

Filtered positions.

Filter(IEnumerable<Position>, PortfolioLookupMessage)

Filter positions the specified criteria.

public static IEnumerable<Position> Filter(this IEnumerable<Position> positions, PortfolioLookupMessage criteria)

Parameters

positions IEnumerable<Position>

All positions.

criteria PortfolioLookupMessage

Criteria.

Returns

IEnumerable<Position>

Found positions.

Filter(IEnumerable<Security>, ExchangeBoard)

To filter instruments by the trading board.

public static IEnumerable<Security> Filter(this IEnumerable<Security> securities, ExchangeBoard board)

Parameters

securities IEnumerable<Security>

Securities.

board ExchangeBoard

Trading board.

Returns

IEnumerable<Security>

Instruments filtered.

Filter(IEnumerable<Security>, Security)

To filter instruments by the given criteria.

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

Parameters

securities IEnumerable<Security>

Securities.

criteria Security

The instrument whose fields will be used as a filter.

Returns

IEnumerable<Security>

Instruments filtered.

Filter(IEnumerable<Security>, SecurityLookupMessage)

To filter instruments by the given criteria.

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

Parameters

securities IEnumerable<Security>

Securities.

criteria SecurityLookupMessage

Message security lookup for specified criteria.

Returns

IEnumerable<Security>

Instruments filtered.

GetExpiryDates(DateTime, DateTime)

To get the expiration date for Forts.

public static IEnumerable<DateTimeOffset> GetExpiryDates(this DateTime from, DateTime to)

Parameters

from DateTime

The start of the expiration range.

to DateTime

The end of the expiration range.

Returns

IEnumerable<DateTimeOffset>

Expiration dates.

GetOrCreateBoard(IExchangeInfoProvider, string, out bool, Func<string, ExchangeBoard>)

To get a board by its code. If board with the passed name does not exist, then it will be created.

public static ExchangeBoard GetOrCreateBoard(this IExchangeInfoProvider exchangeInfoProvider, string code, out bool isNew, Func<string, ExchangeBoard> createBoard = null)

Parameters

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

code string

Board code.

isNew bool

Is newly created.

createBoard Func<string, ExchangeBoard>

The handler creating a board, if it is not found. If the value is null, then the board is created by default initialization.

Returns

ExchangeBoard

Exchange board.

GetOrCreateBoard(IExchangeInfoProvider, string, Func<string, ExchangeBoard>)

To get a board by its code. If board with the passed name does not exist, then it will be created.

public static ExchangeBoard GetOrCreateBoard(this IExchangeInfoProvider exchangeInfoProvider, string code, Func<string, ExchangeBoard> createBoard = null)

Parameters

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

code string

Board code.

createBoard Func<string, ExchangeBoard>

The handler creating a board, if it is not found. If the value is null, then the board is created by default initialization.

Returns

ExchangeBoard

Exchange board.

GetUniqueId(Portfolio)

Get portfolio identifier.

[Obsolete("Use Portfolio.Name property.")]
public static string GetUniqueId(this Portfolio portfolio)

Parameters

portfolio Portfolio

Portfolio.

Returns

string

Portfolio identifier.

HasExternalId(SecurityId)

To check, if SecurityId contains identifiers of external sources.

public static bool HasExternalId(this SecurityId securityId)

Parameters

securityId SecurityId

Security ID.

Returns

bool

true, if there are identifiers of external sources, otherwise, false.

IsAllSecurity(Security)

Check if the specified security is AllSecurity.

public static bool IsAllSecurity(this Security security)

Parameters

security Security

Security.

Returns

bool

true, if the specified security is AllSecurity, otherwise, false.

IsCandle(Type)

Determines whether the specified type is derived from Candle.

[Obsolete("Use ICandleMessage.")]
public static bool IsCandle(this Type candleType)

Parameters

candleType Type

The candle type.

Returns

bool

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

IsLookupAll(Security)

Determine the criteria contains lookup all filter.

public static bool IsLookupAll(this Security criteria)

Parameters

criteria Security

The instrument whose fields will be used as a filter.

Returns

bool

Check result.

IsTimeFrame(CandleSeries)

Determines the specified candle series if time frame based.

public static bool IsTimeFrame(this CandleSeries series)

Parameters

series CandleSeries

CandleSeries

Returns

bool

Check result.

LookupBoards(IExchangeInfoProvider, BoardLookupMessage)

Filter boards by code criteria.

public static IEnumerable<ExchangeBoard> LookupBoards(this IExchangeInfoProvider provider, BoardLookupMessage criteria)

Parameters

provider IExchangeInfoProvider

The exchange boards provider.

criteria BoardLookupMessage

Criteria.

Returns

IEnumerable<ExchangeBoard>

Found boards.

LookupBoards2(IExchangeInfoProvider, BoardLookupMessage)

Filter boards by code criteria.

public static IEnumerable<BoardMessage> LookupBoards2(this IExchangeInfoProvider provider, BoardLookupMessage criteria)

Parameters

provider IExchangeInfoProvider

The exchange boards provider.

criteria BoardLookupMessage

Criteria.

Returns

IEnumerable<BoardMessage>

Found boards.

LookupById(ISecurityProvider, string)

To get the instrument by the identifier.

public static Security LookupById(this ISecurityProvider provider, string id)

Parameters

provider ISecurityProvider

The provider of information about instruments.

id string

Security ID.

Returns

Security

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

Pips(decimal, Security)

To create from decimal the pips values.

public static Unit Pips(this decimal value, Security security)

Parameters

value decimal

decimal value.

security Security

The instrument from which information about the price increment is taken.

Returns

Unit

Pips.

Pips(double, Security)

To create from double the pips values.

public static Unit Pips(this double value, Security security)

Parameters

value double

double value.

security Security

The instrument from which information about the price increment is taken.

Returns

Unit

Pips.

Pips(int, Security)

To create from int the pips values.

public static Unit Pips(this int value, Security security)

Parameters

value int

int value.

security Security

The instrument from which information about the price increment is taken.

Returns

Unit

Pips.

PnF(Security, PnFArg)

To create CandleSeries for PnFCandle candles.

public static CandleSeries PnF(this Security security, PnFArg arg)

Parameters

security Security

Security.

arg PnFArg

The value of PnFArg.

Returns

CandleSeries

Candles series.

Points(decimal, Security)

To create from decimal the points values.

public static Unit Points(this decimal value, Security security)

Parameters

value decimal

decimal value.

security Security

The instrument from which information about the price increment cost is taken.

Returns

Unit

Points.

Points(double, Security)

To create from double the points values.

public static Unit Points(this double value, Security security)

Parameters

value double

double value.

security Security

The instrument from which information about the price increment cost is taken.

Returns

Unit

Points.

Points(int, Security)

To create from int the points values.

public static Unit Points(this int value, Security security)

Parameters

value int

int value.

security Security

The instrument from which information about the price increment cost is taken.

Returns

Unit

Points.

Range(Security, Unit)

To create CandleSeries for RangeCandle candles.

public static CandleSeries Range(this Security security, Unit arg)

Parameters

security Security

Security.

arg Unit

The value of PriceRange.

Returns

CandleSeries

Candles series.

ReRegisterClone(Order, decimal?, decimal?)

To create copy of the order for re-registration.

public static Order ReRegisterClone(this Order oldOrder, decimal? newPrice = null, decimal? newVolume = null)

Parameters

oldOrder Order

The original order.

newPrice decimal?

Price of the new order.

newVolume decimal?

Volume of the new order.

Returns

Order

New order.

ReRegisterOrder(ITransactionProvider, Order, decimal, decimal)

Reregister the order.

public static Order ReRegisterOrder(this ITransactionProvider provider, Order oldOrder, decimal price, decimal volume)

Parameters

provider ITransactionProvider

The transactional provider.

oldOrder Order

Changing order.

price decimal

Price of the new order.

volume decimal

Volume of the new order.

Returns

Order

New order.

ReRegisterOrderEx(ITransactionProvider, Order, Order)

Reregister the order.

public static void ReRegisterOrderEx(this ITransactionProvider provider, Order order, Order clone)

Parameters

provider ITransactionProvider

The transactional provider.

order Order

Order.

clone Order

Changes.

RegisterCandle(Type, Type, Func<Candle>, Func<CandleMessage>)

Register new candle type.

[Obsolete("Conversion reduce performance.")]
public static void RegisterCandle(Type candleType, Type messageType, Func<Candle> candleCreator, Func<CandleMessage> candleMessageCreator)

Parameters

candleType Type

Candle type.

messageType Type

The type of candle message.

candleCreator Func<Candle>

Candle instance creator.

candleMessageCreator Func<CandleMessage>

CandleMessage instance creator.

RegisterCandle<TCandle, TMessage>(Func<TCandle>, Func<TMessage>)

Register new candle type.

[Obsolete("Conversion reduce performance.")]
public static void RegisterCandle<TCandle, TMessage>(Func<TCandle> candleCreator, Func<TMessage> candleMessageCreator) where TCandle : Candle where TMessage : CandleMessage

Parameters

candleCreator Func<TCandle>

Candle instance creator.

candleMessageCreator Func<TMessage>

CandleMessage instance creator.

Type Parameters

TCandle

Candle type.

TMessage

The type of candle message.

Renko(Security, Unit)

To create CandleSeries for RenkoCandle candles.

public static CandleSeries Renko(this Security security, Unit arg)

Parameters

security Security

Security.

arg Unit

The value of BoxSize.

Returns

CandleSeries

Candles series.

SetSecurity(Unit, Security)

To set the GetTypeValue property for the value.

public static Unit SetSecurity(this Unit unit, Security security)

Parameters

unit Unit

Unit.

security Security

Security.

Returns

Unit

Unit.

ShrinkPrice(Security, decimal)

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 Security security, decimal price)

Parameters

security Security

Security

price decimal

The price to be made multiple.

Returns

decimal

The multiple price.

Tick(Security, int)

To create CandleSeries for TickCandle candles.

public static CandleSeries Tick(this Security security, int arg)

Parameters

security Security

Security.

arg int

The value of MaxTradeCount.

Returns

CandleSeries

Candles series.

TimeFrame(Security, TimeSpan)

To create CandleSeries for TimeFrameCandle candles.

public static CandleSeries TimeFrame(this Security security, TimeSpan arg)

Parameters

security Security

Security.

arg TimeSpan

The value of TimeFrame.

Returns

CandleSeries

Candles series.

ToBoard(BoardMessage)

To convert the message into board.

public static ExchangeBoard ToBoard(this BoardMessage message)

Parameters

message BoardMessage

Message.

Returns

ExchangeBoard

Board.

ToCandle(CandleMessage, CandleSeries)

To convert CandleMessage into candle.

[Obsolete("Conversion reduce performance.")]
public static Candle ToCandle(this CandleMessage message, CandleSeries series)

Parameters

message CandleMessage

Message.

series CandleSeries

Series.

Returns

Candle

Candle.

ToCandle(CandleMessage, Security)

To convert CandleMessage into candle.

[Obsolete("Conversion reduce performance.")]
public static Candle ToCandle(this CandleMessage message, Security security)

Parameters

message CandleMessage

Message.

security Security

Security.

Returns

Candle

Candle.

ToCandleMessageType(Type)

Cast candle type Candle to the message CandleMessage.

public static Type ToCandleMessageType(this Type candleType)

Parameters

candleType Type

The type of the candle Candle.

Returns

Type

The type of the message CandleMessage.

ToCandleSeries(DataType, Security)

Convert DataType to CandleSeries value.

public static CandleSeries ToCandleSeries(this DataType dataType, Security security)

Parameters

dataType DataType

Data type info.

security Security

The instrument to be used for candles formation.

Returns

CandleSeries

Candles series.

ToCandleSeries(MarketDataMessage, CandleSeries, bool)

public static void ToCandleSeries(this MarketDataMessage message, CandleSeries series, bool throwIfInvalidType)

Parameters

message MarketDataMessage

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

series CandleSeries

Candles series.

throwIfInvalidType bool

Throw an error if DataType2 isn't candle type.

ToCandleSeries(MarketDataMessage, Security, bool)

public static CandleSeries ToCandleSeries(this MarketDataMessage message, Security security, bool throwIfInvalidType)

Parameters

message MarketDataMessage

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

security Security

Security.

throwIfInvalidType bool

Throw an error if DataType2 isn't candle type.

Returns

CandleSeries

Candles series.

ToCandleType(Type)

Cast message type CandleMessage to the candle type Candle.

public static Type ToCandleType(this Type messageType)

Parameters

messageType Type

The type of the message CandleMessage.

Returns

Type

The type of the candle Candle.

ToCandle<TCandle>(CandleMessage, CandleSeries)

To convert CandleMessage into candle.

[Obsolete("Conversion reduce performance.")]
public static TCandle ToCandle<TCandle>(this CandleMessage message, CandleSeries series) where TCandle : Candle, new()

Parameters

message CandleMessage

Message.

series CandleSeries

Series.

Returns

TCandle

Candle.

Type Parameters

TCandle

The candle type.

ToCandles<TCandle>(IEnumerable<CandleMessage>, Security)

To convert messages into trading objects.

[Obsolete("Conversion reduce performance.")]
public static IEnumerable<TCandle> ToCandles<TCandle>(this IEnumerable<CandleMessage> messages, Security security)

Parameters

messages IEnumerable<CandleMessage>

Messages.

security Security

Security.

Returns

IEnumerable<TCandle>

Trading objects.

Type Parameters

TCandle

The candle type.

ToChangeMessage(Portfolio)

To convert the portfolio into message.

public static PositionChangeMessage ToChangeMessage(this Portfolio portfolio)

Parameters

portfolio Portfolio

Portfolio.

Returns

PositionChangeMessage

Message.

ToChangeMessage(Position, long)

To convert the position into message.

public static PositionChangeMessage ToChangeMessage(this Position position, long originalTransactionId = 0)

Parameters

position Position

Position.

originalTransactionId long

ID of original transaction, for which this message is the answer.

Returns

PositionChangeMessage

Message.

ToDataType(CandleSeries)

Convert DataType to CandleSeries value.

public static DataType ToDataType(this CandleSeries series)

Parameters

series CandleSeries

Candles series.

Returns

DataType

Data type info.

ToDataTypeString(MarketDataMessage)

Format data type into into human-readable string.

public static string ToDataTypeString(this MarketDataMessage message)

Parameters

message MarketDataMessage

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

Returns

string

String.

ToEntities<TMessage, TEntity>(IEnumerable<TMessage>, Security, IExchangeInfoProvider)

To convert messages into trading objects.

[Obsolete("Conversion reduce performance.")]
public static IEnumerable<TEntity> ToEntities<TMessage, TEntity>(this IEnumerable<TMessage> messages, Security security, IExchangeInfoProvider exchangeInfoProvider = null) where TMessage : Message

Parameters

messages IEnumerable<TMessage>

Messages.

security Security

Security.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

IEnumerable<TEntity>

Trading objects.

Type Parameters

TMessage

Message type.

TEntity

The type of trading object.

ToExchange(BoardMessage)

To convert the message into exchange.

public static Exchange ToExchange(this BoardMessage message)

Parameters

message BoardMessage

Message.

Returns

Exchange

Exchange.

ToExchange(BoardMessage, Exchange)

To convert the message into exchange.

public static Exchange ToExchange(this BoardMessage message, Exchange exchange)

Parameters

message BoardMessage

Message.

exchange Exchange

Exchange.

Returns

Exchange

Exchange.

ToExternalId(SecurityId)

public static SecurityExternalId ToExternalId(this SecurityId securityId)

Parameters

securityId SecurityId

SecurityId.

Returns

SecurityExternalId

SecurityExternalId.

ToLookupCriteria(Order, decimal?, Sides?)

Convert Order to OrderStatusMessage value.

public static OrderStatusMessage ToLookupCriteria(this Order criteria, decimal? volume, Sides? side)

Parameters

criteria Order

The criterion which fields will be used as a filter.

volume decimal?

Volume.

side Sides?

Order side.

Returns

OrderStatusMessage

A message requesting current registered orders and trades.

ToLookupCriteria(Portfolio)

public static PortfolioLookupMessage ToLookupCriteria(this Portfolio criteria)

Parameters

criteria Portfolio

The criterion which fields will be used as a filter.

Returns

PortfolioLookupMessage

Message portfolio lookup for specified criteria.

ToLookupCriteria(SecurityLookupMessage, IExchangeInfoProvider)

Convert SecurityLookupMessage message to Security criteria.

public static Security ToLookupCriteria(this SecurityLookupMessage message, IExchangeInfoProvider exchangeInfoProvider)

Parameters

message SecurityLookupMessage

Message.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

Security

Criteria.

ToLookupMessage(Security)

Convert Security criteria to SecurityLookupMessage.

public static SecurityLookupMessage ToLookupMessage(this Security criteria)

Parameters

criteria Security

Criteria.

Returns

SecurityLookupMessage

Message.

ToMarketDataMessage(CandleSeries, bool, DateTimeOffset?, DateTimeOffset?, long?, bool)

public static MarketDataMessage ToMarketDataMessage(this CandleSeries series, bool isSubscribe, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, bool throwIfInvalidType = true)

Parameters

series CandleSeries

Candles series.

isSubscribe bool

The message is subscription.

from DateTimeOffset?

The initial date from which you need to get data.

to DateTimeOffset?

The final date by which you need to get data.

count long?

Candles count.

throwIfInvalidType bool

Throw an error if DataType2 isn't candle type.

Returns

MarketDataMessage

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

ToMarketDepth(Level1ChangeMessage, Security)

[Obsolete("Use IOrderBookMessage.")]
public static MarketDepth ToMarketDepth(this Level1ChangeMessage message, Security security)

Parameters

message Level1ChangeMessage

Message.

security Security

Security.

Returns

MarketDepth

Market depth.

ToMarketDepth(QuoteChangeMessage, MarketDepth)

To convert the message into order book.

[Obsolete("Use IOrderBookMessage.")]
public static MarketDepth ToMarketDepth(this QuoteChangeMessage message, MarketDepth marketDepth)

Parameters

message QuoteChangeMessage

Message.

marketDepth MarketDepth

Market depth.

Returns

MarketDepth

Market depth.

ToMarketDepth(QuoteChangeMessage, Security)

To convert the message into order book.

[Obsolete("Use IOrderBookMessage.")]
public static MarketDepth ToMarketDepth(this QuoteChangeMessage message, Security security)

Parameters

message QuoteChangeMessage

Message.

security Security

Security.

Returns

MarketDepth

Market depth.

ToMessage(Candle)

To convert the candle into message.

[Obsolete("Conversion reduce performance.")]
public static CandleMessage ToMessage(this Candle candle)

Parameters

candle Candle

Candle.

Returns

CandleMessage

Message.

ToMessage(ExchangeBoard, long)

To convert the board into message.

public static BoardMessage ToMessage(this ExchangeBoard board, long originalTransactionId = 0)

Parameters

board ExchangeBoard

Board.

originalTransactionId long

ID of original transaction, for which this message is the answer.

Returns

BoardMessage

Message.

ToMessage(MarketDepth)

[Obsolete("Use IOrderBookMessage.")]
public static QuoteChangeMessage ToMessage(this MarketDepth depth)

Parameters

depth MarketDepth

MarketDepth.

Returns

QuoteChangeMessage

QuoteChangeMessage.

ToMessage(MyTrade)

To convert the own trade into message.

public static ExecutionMessage ToMessage(this MyTrade trade)

Parameters

trade MyTrade

Own trade.

Returns

ExecutionMessage

Message.

ToMessage(News)

To convert news into message.

public static NewsMessage ToMessage(this News news)

Parameters

news News

News.

Returns

NewsMessage

Message.

ToMessage(Order)

To convert the order into message.

public static ExecutionMessage ToMessage(this Order order)

Parameters

order Order

Order.

Returns

ExecutionMessage

Message.

ToMessage(OrderFail, long)

To convert the error description into message.

public static ExecutionMessage ToMessage(this OrderFail fail, long originalTransactionId)

Parameters

fail OrderFail

Error details.

originalTransactionId long

ID of original transaction, for which this message is the answer.

Returns

ExecutionMessage

Message.

ToMessage(OrderLogItem)

To convert the string of orders log onto message.

[Obsolete("Use OrderLogMessage.")]
public static ExecutionMessage ToMessage(this OrderLogItem item)

Parameters

item OrderLogItem

Order log item.

Returns

ExecutionMessage

Message.

ToMessage(Portfolio, long)

To convert the portfolio into message.

public static PortfolioMessage ToMessage(this Portfolio portfolio, long originalTransactionId = 0)

Parameters

portfolio Portfolio

Portfolio.

originalTransactionId long

ID of original transaction, for which this message is the answer.

Returns

PortfolioMessage

Message.

ToMessage(Security, SecurityId?, long, bool)

To convert the instrument into message.

public static SecurityMessage ToMessage(this Security security, SecurityId? securityId = null, long originalTransactionId = 0, bool copyExtendedId = false)

Parameters

security Security

Security.

securityId SecurityId?

Security ID.

originalTransactionId long

ID of original transaction, for which this message is the answer.

copyExtendedId bool

Copy ExternalId and Type.

Returns

SecurityMessage

Message.

ToMessage(Trade)

To convert the tick trade into message.

[Obsolete("Use ITickTradeMessage.")]
public static ExecutionMessage ToMessage(this Trade trade)

Parameters

trade Trade

Tick trade.

Returns

ExecutionMessage

Message.

ToMessageType(Type, ref object)

To convert the type of business object into type of message.

[Obsolete("Conversion reduce performance.")]
public static Type ToMessageType(this Type dataType, ref object arg)

Parameters

dataType Type

The type of business object.

arg object

The data parameter.

Returns

Type

Message type.

ToMessages<TEntity, TMessage>(IEnumerable<TEntity>)

To convert trading objects into messages.

[Obsolete("Conversion reduce performance.")]
public static IEnumerable<TMessage> ToMessages<TEntity, TMessage>(this IEnumerable<TEntity> entities)

Parameters

entities IEnumerable<TEntity>

Trading objects.

Returns

IEnumerable<TMessage>

Messages.

Type Parameters

TEntity

The type of trading object.

TMessage

Message type.

ToNews(NewsMessage, IExchangeInfoProvider)

Cast NewsMessage to the News.

public static News ToNews(this NewsMessage message, IExchangeInfoProvider exchangeInfoProvider)

Parameters

message NewsMessage

Message.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

News

News.

ToOrder(ExecutionMessage, Order)

To convert the message into order.

public static Order ToOrder(this ExecutionMessage message, Order order)

Parameters

message ExecutionMessage

Message.

order Order

The order.

Returns

Order

Order.

ToOrder(ExecutionMessage, Security)

To convert the message into order.

public static Order ToOrder(this ExecutionMessage message, Security security)

Parameters

message ExecutionMessage

Message.

security Security

Security.

Returns

Order

Order.

ToOrderLog(ExecutionMessage, OrderLogItem)

To convert the message into orders log string.

[Obsolete("Use IOrderLogMessage.")]
public static OrderLogItem ToOrderLog(this ExecutionMessage message, OrderLogItem item)

Parameters

message ExecutionMessage

Message.

item OrderLogItem

Order log item.

Returns

OrderLogItem

Order log item.

ToOrderLog(ExecutionMessage, Security)

To convert the message into orders log string.

[Obsolete("Use IOrderLogMessage.")]
public static OrderLogItem ToOrderLog(this ExecutionMessage message, Security security)

Parameters

message ExecutionMessage

Message.

security Security

Security.

Returns

OrderLogItem

Order log item.

ToPortfolio(PortfolioMessage, Portfolio, IExchangeInfoProvider)

public static Portfolio ToPortfolio(this PortfolioMessage message, Portfolio portfolio, IExchangeInfoProvider exchangeInfoProvider)

Parameters

message PortfolioMessage

Message.

portfolio Portfolio

Portfolio.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

Portfolio

Portfolio.

ToSecurity(SecurityMessage, IExchangeInfoProvider)

To convert the message into instrument.

public static Security ToSecurity(this SecurityMessage message, IExchangeInfoProvider exchangeInfoProvider)

Parameters

message SecurityMessage

Message.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

Security

Security.

ToSecurityId(Security, SecurityIdGenerator, bool, bool)

To convert the instrument into SecurityId.

public static SecurityId ToSecurityId(this Security security, SecurityIdGenerator idGenerator = null, bool boardIsRequired = true, bool copyExtended = false)

Parameters

security Security

Security.

idGenerator SecurityIdGenerator

The instrument identifiers generator Id.

boardIsRequired bool

Board is required.

copyExtended bool

Copy ExternalId and Type.

Returns

SecurityId

Security ID.

ToSecurityId(SecurityExternalId, SecurityId)

public static SecurityId ToSecurityId(this SecurityExternalId externalId, SecurityId secId)

Parameters

externalId SecurityExternalId

SecurityExternalId.

secId SecurityId

SecurityId.

Returns

SecurityId

SecurityId.

ToSecurityId(SecurityExternalId, string, string)

public static SecurityId ToSecurityId(this SecurityExternalId externalId, string securityCode, string boardCode)

Parameters

externalId SecurityExternalId

SecurityExternalId.

securityCode string

Security code.

boardCode string

Board code.

Returns

SecurityId

SecurityId.

ToTrade(ExecutionMessage, Security)

To convert the message into tick trade.

[Obsolete("Use ITickTradeMessage.")]
public static Trade ToTrade(this ExecutionMessage message, Security security)

Parameters

message ExecutionMessage

Message.

security Security

Security.

Returns

Trade

Tick trade.

ToTrade(ExecutionMessage, Trade)

To convert the message into tick trade.

[Obsolete("Use ITickTradeMessage.")]
public static Trade ToTrade(this ExecutionMessage message, Trade trade)

Parameters

message ExecutionMessage

Message.

trade Trade

Tick trade.

Returns

Trade

Tick trade.

ToUnit2(string, bool, Security)

Convert string to Unit.

public static Unit ToUnit2(this string str, bool throwIfNull = true, Security security = null)

Parameters

str string

String value of Unit.

throwIfNull bool

Throw ArgumentNullException if the specified string is empty.

security Security

Information about the instrument. Required when using Point и Step.

Returns

Unit

Object Unit.

Update(Candle, CandleMessage)

Update candle from CandleMessage.

[Obsolete("Conversion reduce performance.")]
public static Candle Update(this Candle candle, CandleMessage message)

Parameters

candle Candle

Candle.

message CandleMessage

Message.

Returns

Candle

Candle.

Volume(Security, decimal)

To create CandleSeries for VolumeCandle candles.

public static CandleSeries Volume(this Security security, decimal arg)

Parameters

security Security

Security.

arg decimal

The value of Volume.

Returns

CandleSeries

Candles series.