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
MoneySecurity
"Money" security instance.
public static readonly Security MoneySecurity
Field Value
NewsSecurity
"News" security instance.
public static readonly Security NewsSecurity
Field Value
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
AllSecurity
"All securities" instance.
public static Security AllSecurity { get; }
Property Value
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
ExchangeBoardBoard 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.
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.
ApplyChanges(Portfolio, PositionChangeMessage, IExchangeInfoProvider)
Apply changes to the portfolio object.
public static void ApplyChanges(this Portfolio portfolio, PositionChangeMessage message, IExchangeInfoProvider exchangeInfoProvider)
Parameters
portfolio
PortfolioPortfolio.
message
PositionChangeMessagePortfolio change message.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
ApplyChanges(Position, PositionChangeMessage)
Apply changes to the position object.
public static void ApplyChanges(this Position position, PositionChangeMessage message)
Parameters
position
PositionPosition.
message
PositionChangeMessagePosition change message.
ApplyChanges(Security, Level1ChangeMessage)
Apply change to the security object.
public static void ApplyChanges(this Security security, Level1ChangeMessage message)
Parameters
security
SecuritySecurity.
message
Level1ChangeMessageChanges.
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
SecuritySecurity.
message
SecurityMessageMeta info.
exchangeInfoProvider
IExchangeInfoProviderExchanges and trading boards provider.
isOverride
boolOverride 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
SecuritySecurity.
changes
IEnumerable<KeyValuePair<Level1Fields, object>>Changes.
serverTime
DateTimeOffsetChange server time.
localTime
DateTimeOffsetLocal 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
OrderOrder.
state
OrderStatesCurrent order's state.
logs
ILogReceiverLogs.
Convert(Unit, UnitTypes, Security)
Cast the value to another type.
public static Unit Convert(this Unit unit, UnitTypes destinationType, Security security)
Parameters
unit
UnitSource unit.
destinationType
UnitTypesDestination value type.
security
SecurityInformation 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
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.
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
SecuritySecurity.
message
TMessageMessage.
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
BoardLookupMessageCriteria.
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
OrderThe 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
PortfolioThe 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
PortfolioThe 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
OrderStatesOrder 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
SidesOrder 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
PortfolioLookupMessageCriteria.
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
PortfolioThe 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
PortfolioLookupMessageCriteria.
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
ExchangeBoardTrading 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
SecurityThe 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
SecurityLookupMessageMessage 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
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
IExchangeInfoProviderExchanges and trading boards provider.
code
stringBoard code.
isNew
boolIs 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
IExchangeInfoProviderExchanges and trading boards provider.
code
stringBoard 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
PortfolioPortfolio.
Returns
- string
Portfolio identifier.
HasExternalId(SecurityId)
To check, if SecurityId contains identifiers of external sources.
public static bool HasExternalId(this SecurityId securityId)
Parameters
securityId
SecurityIdSecurity ID.
Returns
IsAllSecurity(Security)
Check if the specified security is AllSecurity.
public static bool IsAllSecurity(this Security security)
Parameters
security
SecuritySecurity.
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
TypeThe candle type.
Returns
IsLookupAll(Security)
Determine the criteria
contains lookup all filter.
public static bool IsLookupAll(this Security criteria)
Parameters
criteria
SecurityThe 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
Returns
- bool
Check result.
LookupBoards(IExchangeInfoProvider, BoardLookupMessage)
Filter boards by code criteria.
public static IEnumerable<ExchangeBoard> LookupBoards(this IExchangeInfoProvider provider, BoardLookupMessage criteria)
Parameters
provider
IExchangeInfoProviderThe exchange boards provider.
criteria
BoardLookupMessageCriteria.
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
IExchangeInfoProviderThe exchange boards provider.
criteria
BoardLookupMessageCriteria.
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
ISecurityProviderThe provider of information about instruments.
id
stringSecurity ID.
Returns
Pips(decimal, Security)
To create from decimal the pips values.
public static Unit Pips(this decimal value, Security security)
Parameters
value
decimaldecimal value.
security
SecurityThe 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
doubledouble value.
security
SecurityThe 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
intint value.
security
SecurityThe 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
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
decimaldecimal value.
security
SecurityThe 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
doubledouble value.
security
SecurityThe 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
intint value.
security
SecurityThe 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
SecuritySecurity.
arg
UnitThe 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
OrderThe 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
ITransactionProviderThe transactional provider.
oldOrder
OrderChanging order.
price
decimalPrice of the new order.
volume
decimalVolume 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
ITransactionProviderThe transactional provider.
order
OrderOrder.
clone
OrderChanges.
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.
Renko(Security, Unit)
To create CandleSeries for RenkoCandle candles.
public static CandleSeries Renko(this Security security, Unit arg)
Parameters
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
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
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
SecuritySecurity.
arg
intThe 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
Returns
- CandleSeries
Candles series.
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
ToTrade(ExecutionMessage, Security)
To convert the message into tick trade.
[Obsolete("Use ITickTradeMessage.")]
public static Trade ToTrade(this ExecutionMessage message, Security security)
Parameters
message
ExecutionMessageMessage.
security
SecuritySecurity.
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
ExecutionMessageMessage.
trade
TradeTick 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
stringString value of Unit.
throwIfNull
boolThrow ArgumentNullException if the specified string is empty.
security
SecurityInformation about the instrument. Required when using Point и Step.
Returns
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.
Volume(Security, decimal)
To create CandleSeries for VolumeCandle candles.
public static CandleSeries Volume(this Security security, decimal arg)
Parameters
Returns
- CandleSeries
Candles series.