Class MessageConverterHelper
- Namespace
- StockSharp.Algo
- Assembly
- StockSharp.Algo.dll
The auxiliary class for conversion of business-objects (StockSharp.BusinessEntities) into messages (StockSharp.Messages) and vice versa.
public static class MessageConverterHelper
- Inheritance
-
MessageConverterHelper
- Inherited Members
Properties
AllCandleMessageTypes
All registered candle message types.
public static IEnumerable<Type> AllCandleMessageTypes { get; }
Property Value
AllCandleTypes
All registered candle types.
public static IEnumerable<Type> AllCandleTypes { get; }
Property Value
Methods
ApplyChanges(ExchangeBoard, BoardMessage)
To convert the message into board.
public static ExchangeBoard ApplyChanges(this ExchangeBoard board, BoardMessage message)
Parameters
board
ExchangeBoardBoard.
message
BoardMessageMessage.
Returns
- ExchangeBoard
Board.
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
OrderOrder.
securityId
SecurityIdSecurity ID.
transactionId
longThe transaction number.
Returns
- OrderCancelMessage
Message.
CreateCandleMessage(Type)
Create instance of CandleMessage.
public static CandleMessage CreateCandleMessage(this Type messageType)
Parameters
messageType
TypeThe 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
OrderOrder.
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
OrderOld order.
newOrder
OrderNew order.
securityId
SecurityIdSecurity ID.
Returns
- OrderReplaceMessage
Message.
CreateReplaceMessage(Order, Order, SecurityId, Order, Order, SecurityId)
To create the message of replacing pair of old orders to new ones.
public static OrderPairReplaceMessage CreateReplaceMessage(this Order oldOrder1, Order newOrder1, SecurityId security1, Order oldOrder2, Order newOrder2, SecurityId security2)
Parameters
oldOrder1
OrderOld order.
newOrder1
OrderNew order.
security1
SecurityIdSecurity ID.
oldOrder2
OrderOld order.
newOrder2
OrderNew order.
security2
SecurityIdSecurity ID.
Returns
- OrderPairReplaceMessage
Message.
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
SecuritySecurity.
message
TMessageMessage.
Returns
- TMessage
Message.
Type Parameters
TMessage
Message type.
HasExternalId(SecurityId)
To check, if SecurityId contains identifiers of external sources.
public static bool HasExternalId(this SecurityId securityId)
Parameters
securityId
SecurityIdSecurity ID.
Returns
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
TypeCandle type.
messageType
TypeThe 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.
ToBoard(BoardMessage)
To convert the message into board.
public static ExchangeBoard ToBoard(this BoardMessage message)
Parameters
message
BoardMessageMessage.
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
CandleMessageMessage.
series
CandleSeriesSeries.
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
CandleMessageMessage.
security
SecuritySecurity.
Returns
- Candle
Candle.
ToCandleMessageType(Type)
Cast candle type Candle to the message CandleMessage.
public static Type ToCandleMessageType(this Type candleType)
Parameters
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
DataTypeData type info.
security
SecurityThe instrument to be used for candles formation.
Returns
- CandleSeries
Candles series.
ToCandleSeries(MarketDataMessage, CandleSeries, bool)
Cast MarketDataMessage to CandleSeries.
public static void ToCandleSeries(this MarketDataMessage message, CandleSeries series, bool throwIfInvalidType)
Parameters
message
MarketDataMessageMarket-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
series
CandleSeriesCandles series.
throwIfInvalidType
boolThrow an error if DataType2 isn't candle type.
ToCandleSeries(MarketDataMessage, Security, bool)
Cast MarketDataMessage to CandleSeries.
public static CandleSeries ToCandleSeries(this MarketDataMessage message, Security security, bool throwIfInvalidType)
Parameters
message
MarketDataMessageMarket-data message (uses as a subscribe/unsubscribe in outgoing case, confirmation event in incoming case).
security
SecuritySecurity.
throwIfInvalidType
boolThrow 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
TypeThe type of the message CandleMessage.
Returns
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
CandleMessageMessage.
series
CandleSeriesSeries.
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
SecuritySecurity.
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
PortfolioPortfolio.
Returns
- PositionChangeMessage
Message.
ToChangeMessage(Position, long)
To convert the position into message.
public static PositionChangeMessage ToChangeMessage(this Position position, long originalTransactionId = 0)
Parameters
position
PositionPosition.
originalTransactionId
longID 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
CandleSeriesCandles 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
MarketDataMessageMarket-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
SecuritySecurity.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
BoardMessageMessage.
Returns
- Exchange
Exchange.
ToExchange(BoardMessage, Exchange)
To convert the message into exchange.
public static Exchange ToExchange(this BoardMessage message, Exchange exchange)
Parameters
message
BoardMessageMessage.
exchange
ExchangeExchange.
Returns
- Exchange
Exchange.
ToExternalId(SecurityId)
Cast SecurityId to the SecurityExternalId.
public static SecurityExternalId ToExternalId(this SecurityId securityId)
Parameters
securityId
SecurityId
Returns
ToLookupCriteria(Order, decimal?, Sides?)
Convert Order to OrderStatusMessage value.
public static OrderStatusMessage ToLookupCriteria(this Order criteria, decimal? volume, Sides? side)
Parameters
criteria
OrderThe 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)
Convert Portfolio to PortfolioLookupMessage value.
public static PortfolioLookupMessage ToLookupCriteria(this Portfolio criteria)
Parameters
criteria
PortfolioThe 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
SecurityLookupMessageMessage.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
Returns
- Security
Criteria.
ToLookupMessage(Security)
Convert Security criteria to SecurityLookupMessage.
public static SecurityLookupMessage ToLookupMessage(this Security criteria)
Parameters
criteria
SecurityCriteria.
Returns
- SecurityLookupMessage
Message.
ToMarketDataMessage(CandleSeries, bool, DateTimeOffset?, DateTimeOffset?, long?, bool)
Cast CandleSeries to MarketDataMessage.
public static MarketDataMessage ToMarketDataMessage(this CandleSeries series, bool isSubscribe, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, bool throwIfInvalidType = true)
Parameters
series
CandleSeriesCandles series.
isSubscribe
boolThe 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
boolThrow 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)
Cast Level1ChangeMessage to the MarketDepth.
[Obsolete("Use IOrderBookMessage.")]
public static MarketDepth ToMarketDepth(this Level1ChangeMessage message, Security security)
Parameters
message
Level1ChangeMessageMessage.
security
SecuritySecurity.
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
QuoteChangeMessageMessage.
marketDepth
MarketDepthMarket 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
QuoteChangeMessageMessage.
security
SecuritySecurity.
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
CandleCandle.
Returns
- CandleMessage
Message.
ToMessage(ExchangeBoard, long)
To convert the board into message.
public static BoardMessage ToMessage(this ExchangeBoard board, long originalTransactionId = 0)
Parameters
board
ExchangeBoardBoard.
originalTransactionId
longID of original transaction, for which this message is the answer.
Returns
- BoardMessage
Message.
ToMessage(MarketDepth)
Cast MarketDepth to the QuoteChangeMessage.
[Obsolete("Use IOrderBookMessage.")]
public static QuoteChangeMessage ToMessage(this MarketDepth depth)
Parameters
depth
MarketDepth
Returns
ToMessage(MyTrade)
To convert the own trade into message.
public static ExecutionMessage ToMessage(this MyTrade trade)
Parameters
trade
MyTradeOwn trade.
Returns
- ExecutionMessage
Message.
ToMessage(News)
To convert news into message.
public static NewsMessage ToMessage(this News news)
Parameters
news
NewsNews.
Returns
- NewsMessage
Message.
ToMessage(Order)
To convert the order into message.
public static ExecutionMessage ToMessage(this Order order)
Parameters
order
OrderOrder.
Returns
- ExecutionMessage
Message.
ToMessage(OrderFail, long)
To convert the error description into message.
public static ExecutionMessage ToMessage(this OrderFail fail, long originalTransactionId)
Parameters
fail
OrderFailError details.
originalTransactionId
longID 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
OrderLogItemOrder 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
PortfolioPortfolio.
originalTransactionId
longID 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
SecuritySecurity.
securityId
SecurityId?Security ID.
originalTransactionId
longID of original transaction, for which this message is the answer.
copyExtendedId
boolCopy 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
TradeTick 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
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
NewsMessageMessage.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
ExecutionMessageMessage.
order
OrderThe order.
Returns
- Order
Order.
ToOrder(ExecutionMessage, Security)
To convert the message into order.
public static Order ToOrder(this ExecutionMessage message, Security security)
Parameters
message
ExecutionMessageMessage.
security
SecuritySecurity.
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
ExecutionMessageMessage.
item
OrderLogItemOrder 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
ExecutionMessageMessage.
security
SecuritySecurity.
Returns
- OrderLogItem
Order log item.
ToPortfolio(PortfolioMessage, Portfolio, IExchangeInfoProvider)
Cast PortfolioMessage to the Portfolio.
public static Portfolio ToPortfolio(this PortfolioMessage message, Portfolio portfolio, IExchangeInfoProvider exchangeInfoProvider)
Parameters
message
PortfolioMessageMessage.
portfolio
PortfolioPortfolio.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
SecurityMessageMessage.
exchangeInfoProvider
IExchangeInfoProviderExchanges 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
SecuritySecurity.
idGenerator
SecurityIdGeneratorThe instrument identifiers generator Id.
boardIsRequired
boolBoard is required.
copyExtended
boolCopy ExternalId and Type.
Returns
- SecurityId
Security ID.
ToSecurityId(SecurityExternalId, SecurityId)
Cast SecurityExternalId to the SecurityId.
public static SecurityId ToSecurityId(this SecurityExternalId externalId, SecurityId secId)
Parameters
externalId
SecurityExternalIdsecId
SecurityId
Returns
ToSecurityId(SecurityExternalId, string, string)
Cast SecurityExternalId to the SecurityId.
public static SecurityId ToSecurityId(this SecurityExternalId externalId, string securityCode, string boardCode)
Parameters
externalId
SecurityExternalIdsecurityCode
stringSecurity code.
boardCode
stringBoard code.
Returns
ToSubscription(DataType)
Convert DataType to Subscription value.
public static Subscription ToSubscription(this DataType dataType)
Parameters
dataType
DataTypeData type info.
Returns
- Subscription
Subscription.
Update(Candle, CandleMessage)
Update candle from CandleMessage.
[Obsolete("Conversion reduce performance.")]
public static Candle Update(this Candle candle, CandleMessage message)
Parameters
candle
CandleCandle.
message
CandleMessageMessage.
Returns
- Candle
Candle.