Table of Contents

Class TraderHelper

Namespace
StockSharp.Algo
Assembly
StockSharp.Algo.dll

The auxiliary class for provision of various algorithmic functionalities.

public static class TraderHelper
Inheritance
TraderHelper
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

AllSecurity

"All securities" instance.

public static Security AllSecurity { get; }

Property Value

Security

IndicatorValue

Indicator value.

public static DataType IndicatorValue { get; }

Property Value

DataType

UsdRateMinAvailableTime

The earliest date for which there is an indicative rate of US dollar to the Russian ruble. It is 2 November 2009.

[Obsolete]
public static DateTime UsdRateMinAvailableTime { get; }

Property Value

DateTime

Methods

AddAdapter(Connector, Type, Action<IMessageAdapter>)

public static IMessageAdapter AddAdapter(this Connector connector, Type adapterType, Action<IMessageAdapter> init)

Parameters

connector Connector

The class to create connections to trading systems.

adapterType Type

Adapter type.

init Action<IMessageAdapter>

Initialize adapter.

Returns

IMessageAdapter

The class to create connections to trading systems.

AddAdapter<TAdapter>(Connector, Action<TAdapter>)

public static TAdapter AddAdapter<TAdapter>(this Connector connector, Action<TAdapter> init) where TAdapter : IMessageAdapter

Parameters

connector Connector

The class to create connections to trading systems.

init Action<TAdapter>

Initialize adapter.

Returns

TAdapter

The class to create connections to trading systems.

Type Parameters

TAdapter

Adapter type.

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.

AddOrderErrorLog(ILogReceiver, Order, string, Func<string>)

Write order error to the log.

public static void AddOrderErrorLog(this ILogReceiver receiver, Order order, string operation, Func<string> getAdditionalInfo = null)

Parameters

receiver ILogReceiver

Logs receiver.

order Order

Order.

operation string

Order action name.

getAdditionalInfo Func<string>

Extended order info.

AddOrderInfoLog(ILogReceiver, Order, string, Func<string>)

Write order info to the log.

public static void AddOrderInfoLog(this ILogReceiver receiver, Order order, string operation, Func<string> getAdditionalInfo = null)

Parameters

receiver ILogReceiver

Logs receiver.

order Order

Order.

operation string

Order action name.

getAdditionalInfo Func<string>

Extended order info.

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.

ApplyOffset(Unit, Sides, Unit, Security)

To use shifting for price, depending on direction side.

public static decimal ApplyOffset(this Unit price, Sides side, Unit offset, Security security)

Parameters

price Unit

Price.

side Sides

The order direction, used as shift direction (for buy the shift is added, for sell - subtracted).

offset Unit

Price shift.

security Security

Security.

Returns

decimal

New price.

CancelOrders(IConnector, IEnumerable<Order>, bool?, Portfolio, Sides?, ExchangeBoard, Security, SecurityTypes?)

Cancel orders by filter.

public static void CancelOrders(this IConnector connector, IEnumerable<Order> orders, bool? isStopOrder = null, Portfolio portfolio = null, Sides? side = null, ExchangeBoard board = null, Security security = null, SecurityTypes? securityType = null)

Parameters

connector IConnector

The connection of interaction with trade systems.

orders IEnumerable<Order>

The group of orders, from which the required orders shall be found and cancelled.

isStopOrder bool?

true, if cancel only a stop orders, false - if regular orders, null - both.

portfolio Portfolio

Portfolio. If the value is equal to null, then the portfolio does not match the orders cancel filter.

side Sides?

Order side. If the value is null, the direction does not use.

board ExchangeBoard

Trading board. If the value is equal to null, then the board does not match the orders cancel filter.

security Security

Instrument. If the value is equal to null, then the instrument does not match the orders cancel filter.

securityType SecurityTypes?

Security type. If the value is null, the type does not use.

Compile(string, AssemblyLoadContextTracker)

Compile mathematical formula.

public static ExpressionFormula<decimal> Compile(this string expression, AssemblyLoadContextTracker tracker)

Parameters

expression string

Text expression.

tracker AssemblyLoadContextTracker

Ecng.Compilation.AssemblyLoadContextTracker

Returns

ExpressionFormula<decimal>

Compiled mathematical formula.

Compile<TResult>(string, AssemblyLoadContextTracker)

Compile mathematical formula.

public static ExpressionFormula<TResult> Compile<TResult>(this string expression, AssemblyLoadContextTracker tracker)

Parameters

expression string

Text expression.

tracker AssemblyLoadContextTracker

Ecng.Compilation.AssemblyLoadContextTracker

Returns

ExpressionFormula<TResult>

Compiled mathematical formula.

Type Parameters

TResult

Result type.

Contains(BasketSecurity, ISecurityProvider, Security)

To check whether specified instrument is used now.

public static bool Contains(this BasketSecurity basketSecurity, ISecurityProvider securityProvider, Security security)

Parameters

basketSecurity BasketSecurity

Instruments basket.

securityProvider ISecurityProvider

The provider of information about instruments.

security Security

The instrument that should be checked.

Returns

bool

true, if specified instrument is used now, otherwise false.

CreateProcessor(IBasketSecurityProcessorProvider, Security)

Create market data processor for basket securities.

public static IBasketSecurityProcessor CreateProcessor(this IBasketSecurityProcessorProvider processorProvider, Security security)

Parameters

processorProvider IBasketSecurityProcessorProvider

Basket security processors provider.

security Security

Basket security.

Returns

IBasketSecurityProcessor

Market data processor for basket securities.

DeleteAll(ISecurityStorage)

To delete all instruments.

public static void DeleteAll(this ISecurityStorage storage)

Parameters

storage ISecurityStorage

Securities meta info storage.

Download<TResult>(IMessageAdapter, Message, out byte[])

Download data.

public static IEnumerable<TResult> Download<TResult>(this IMessageAdapter adapter, Message request, out byte[] archive) where TResult : Message

Parameters

adapter IMessageAdapter

Adapter.

request Message

Request.

archive byte[]

Result data was sent as archive.

Returns

IEnumerable<TResult>

Downloaded data.

Type Parameters

TResult

Result message.

EmulateTrades(MarketDepth, IEnumerable<ExecutionMessage>)

To delete in order book levels, which shall disappear in case of trades occurrence trades.

[Obsolete]
public static void EmulateTrades(this MarketDepth depth, IEnumerable<ExecutionMessage> trades)

Parameters

depth MarketDepth

The order book to be cleared.

trades IEnumerable<ExecutionMessage>

Trades.

FillFortsJumps(ExpirationContinuousSecurity, ISecurityProvider, string, DateTime, DateTime)

To fill transitions ExpirationJumps.

public static void FillFortsJumps(this ExpirationContinuousSecurity continuousSecurity, ISecurityProvider provider, string baseCode, DateTime from, DateTime to)

Parameters

continuousSecurity ExpirationContinuousSecurity

Continuous security.

provider ISecurityProvider

The provider of information about instruments.

baseCode string

The base part of the instrument code.

from DateTime

The start of the expiration range.

to DateTime

The end of the expiration range.

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<MyTrade>, Security)

To filter own trades for the given instrument.

public static IEnumerable<MyTrade> Filter(this IEnumerable<MyTrade> myTrades, Security security)

Parameters

myTrades IEnumerable<MyTrade>

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

security Security

The instrument, on which the trades shall be found.

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>, Security)

To filter orders for the given instrument.

public static IEnumerable<Order> Filter(this IEnumerable<Order> orders, Security security)

Parameters

orders IEnumerable<Order>

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

security Security

The instrument, 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>, Security)

To filter positions for the given instrument.

public static IEnumerable<Position> Filter(this IEnumerable<Position> positions, Security security)

Parameters

positions IEnumerable<Position>

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

security Security

The instrument, 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.

Filter(IEnumerable<Trade>, Security)

To filter orders for the given instrument.

[Obsolete("Use ITickTradeMessage.")]
public static IEnumerable<Trade> Filter(this IEnumerable<Trade> trades, Security security)

Parameters

trades IEnumerable<Trade>

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

security Security

The instrument, for which the trades shall be filtered.

Returns

IEnumerable<Trade>

Filtered trades.

GenerateId(SecurityIdGenerator, string, ExchangeBoard)

Generate SecurityId security.

public static string GenerateId(this SecurityIdGenerator generator, string secCode, ExchangeBoard board)

Parameters

generator SecurityIdGenerator

SecurityIdGenerator

secCode string

Security code.

board ExchangeBoard

Security board.

Returns

string

Id security.

GetAllSecurity(ISecurityProvider)

Find AllSecurity instance in the specified provider.

public static Security GetAllSecurity(this ISecurityProvider provider)

Parameters

provider ISecurityProvider

The provider of information about instruments.

Returns

Security

Found instance.

GetAveragePrice(Order, IConnector)

To get weighted mean price of order matching.

[Obsolete]
public static decimal GetAveragePrice(this Order order, IConnector connector)

Parameters

order Order

The order, for which the weighted mean matching price shall be got.

connector IConnector

The connection of interaction with trade systems.

Returns

decimal

The weighted mean price. If no order exists no trades, 0 is returned.

GetAveragePrice(IEnumerable<MyTrade>)

To get the weighted mean price of matching by own trades.

[Obsolete]
public static decimal GetAveragePrice(this IEnumerable<MyTrade> trades)

Parameters

trades IEnumerable<MyTrade>

Trades, for which the weighted mean price of matching shall be got.

Returns

decimal

The weighted mean price. If no trades, 0 is returned.

GetCandles(IMessageAdapter, SecurityId, TimeSpan, DateTimeOffset, DateTimeOffset, long?, Level1Fields?, SecurityTypes?)

To download candles.

public static IEnumerable<TimeFrameCandleMessage> GetCandles(this IMessageAdapter adapter, SecurityId securityId, TimeSpan timeFrame, DateTimeOffset from, DateTimeOffset to, long? count = null, Level1Fields? buildField = null, SecurityTypes? secType = null)

Parameters

adapter IMessageAdapter

Adapter.

securityId SecurityId

Security ID.

timeFrame TimeSpan

Time-frame.

from DateTimeOffset

Begin period.

to DateTimeOffset

End period.

count long?

Candles count.

buildField Level1Fields?

Extra info for the BuildFrom.

secType SecurityTypes?

SecurityType.

Returns

IEnumerable<TimeFrameCandleMessage>

Downloaded candles.

GetCurrentPrice(MarketDepthPair, Sides, decimal?, MarketPriceTypes)

To calculate the current price based on the best pair of quotes, depending on the order direction.

public static Unit GetCurrentPrice(this MarketDepthPair bestPair, Sides side, decimal? priceStep, MarketPriceTypes priceType = MarketPriceTypes.Following)

Parameters

bestPair MarketDepthPair

The best pair of quotes, used for the current price calculation.

side Sides

The order direction. If it is a buy, Ask value is used, otherwise Bid.

priceStep decimal?

PriceStep

priceType MarketPriceTypes

The type of current price.

Returns

Unit

The current price. If information in order book is insufficient, then null will be returned.

Remarks

For correct operation of the method the order book export shall be launched.

GetCurrentPrice(Security, IMarketDataProvider, Sides?)

To calculate the current price by the instrument depending on the order direction.

public static Unit GetCurrentPrice(this Security security, IMarketDataProvider provider, Sides? direction = null)

Parameters

security Security

The instrument used for the current price calculation.

provider IMarketDataProvider

The market data provider.

direction Sides?

Order side.

Returns

Unit

The current price. If information in order book is insufficient, then null will be returned.

GetCurrentPrice(IOrderBookMessage, Sides, decimal?, MarketPriceTypes, IEnumerable<Order>)

To calculate the current price by the order book depending on the order direction.

public static Unit GetCurrentPrice(this IOrderBookMessage depth, Sides side, decimal? priceStep, MarketPriceTypes priceType = MarketPriceTypes.Following, IEnumerable<Order> orders = null)

Parameters

depth IOrderBookMessage

The order book for the current price calculation.

side Sides

The order direction. If it is a buy, BestAsk2 value is used, otherwise BestBid2.

priceStep decimal?

PriceStep

priceType MarketPriceTypes

The type of current price.

orders IEnumerable<Order>

Orders to be ignored.

Returns

Unit

The current price. If information in order book is insufficient, then null will be returned.

Remarks

For correct operation of the method the order book export shall be launched.

GetDirection(Position)

To get the order direction for the position.

public static Sides? GetDirection(this Position position)

Parameters

position Position

The position value.

Returns

Sides?

Order side.

Remarks

A positive value equals Buy, a negative - Sell, zero - null.

GetDirection(decimal)

To get the order direction for the position.

public static Sides? GetDirection(this decimal position)

Parameters

position decimal

The position value.

Returns

Sides?

Order side.

Remarks

A positive value equals Buy, a negative - Sell, zero - null.

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.

GetFortsEndOfDay(string, DateTime, DateTime)

It returns a list of the data at the end of day (EOD, End-Of-Day) by the selected instrument for the specified period.

[Obsolete]
public static IEnumerable<Level1ChangeMessage> GetFortsEndOfDay(this string securityName, DateTime fromDate, DateTime toDate)

Parameters

securityName string

Security name.

fromDate DateTime

Begin period.

toDate DateTime

End period.

Returns

IEnumerable<Level1ChangeMessage>

Historical market-data.

GetFortsJumps(ExpirationContinuousSecurity, ISecurityProvider, string, DateTime, DateTime, bool)

To get real expiration instruments for the continuous instrument.

public static IEnumerable<Security> GetFortsJumps(this ExpirationContinuousSecurity continuousSecurity, ISecurityProvider provider, string baseCode, DateTime from, DateTime to, bool throwIfNotExists = true)

Parameters

continuousSecurity ExpirationContinuousSecurity

Continuous security.

provider ISecurityProvider

The provider of information about instruments.

baseCode string

The base part of the instrument code.

from DateTime

The start of the expiration range.

to DateTime

The end of the expiration range.

throwIfNotExists bool

To generate exception, if some of instruments for passed continuousSecurity are not available.

Returns

IEnumerable<Security>

Expiration instruments.

GetFortsJumps(string, DateTime, DateTime, Func<string, Security>, bool)

To get real expiration instruments for base part of the code.

public static IEnumerable<Security> GetFortsJumps(this string baseCode, DateTime from, DateTime to, Func<string, Security> getSecurity, bool throwIfNotExists = true)

Parameters

baseCode string

The base part of the instrument code.

from DateTime

The start of the expiration range.

to DateTime

The end of the expiration range.

getSecurity Func<string, Security>

The function to get instrument by the code.

throwIfNotExists bool

To generate exception, if some of instruments are not available.

Returns

IEnumerable<Security>

Expiration instruments.

GetFortsRate(SecurityId, DateTime, DateTime)

To get an indicative exchange rate of a currency pair.

[Obsolete]
public static IDictionary<DateTimeOffset, decimal> GetFortsRate(this SecurityId securityId, DateTime fromDate, DateTime toDate)

Parameters

securityId SecurityId

Security ID.

fromDate DateTime

Begin period.

toDate DateTime

End period.

Returns

IDictionary<DateTimeOffset, decimal>

The indicative rate of US dollar to the Russian ruble.

GetFortsYesterdayEndOfDay(string)

It returns yesterday's data at the end of day (EOD, End-Of-Day) by the selected instrument.

[Obsolete]
public static Level1ChangeMessage GetFortsYesterdayEndOfDay(this string securityName)

Parameters

securityName string

Security name.

Returns

Level1ChangeMessage

Yesterday's market-data.

Remarks

Date is determined by the system time.

GetInnerSecurities(BasketSecurity, ISecurityProvider)

Find inner security instances.

public static IEnumerable<Security> GetInnerSecurities(this BasketSecurity security, ISecurityProvider securityProvider)

Parameters

security BasketSecurity

Instruments basket.

securityProvider ISecurityProvider

The provider of information about instruments.

Returns

IEnumerable<Security>

Instruments, from which this basket is created.

GetLevel1(IMessageAdapter, SecurityId, DateTime, DateTime, int?, IEnumerable<Level1Fields>, SecurityTypes?)

To get level1 market data.

public static IEnumerable<Level1ChangeMessage> GetLevel1(this IMessageAdapter adapter, SecurityId securityId, DateTime beginDate, DateTime endDate, int? maxCount = null, IEnumerable<Level1Fields> fields = null, SecurityTypes? secType = null)

Parameters

adapter IMessageAdapter

Adapter.

securityId SecurityId

Security ID.

beginDate DateTime

Start date.

endDate DateTime

End date.

maxCount int?

Count

fields IEnumerable<Level1Fields>

Market data fields.

secType SecurityTypes?

SecurityType.

Returns

IEnumerable<Level1ChangeMessage>

Level1 market data.

GetMatchedVolume(Order, IConnector)

To calculate the implemented part of volume for order.

[Obsolete]
public static decimal GetMatchedVolume(this Order order, IConnector connector)

Parameters

order Order

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

connector IConnector

The connection of interaction with trade systems.

Returns

decimal

The implemented part of volume.

GetOrCreate(ISecurityStorage, SecurityId, Func<string, Security>, out bool)

Get or create (if not exist).

public static Security GetOrCreate(this ISecurityStorage storage, SecurityId id, Func<string, Security> creator, out bool isNew)

Parameters

storage ISecurityStorage

Securities meta info storage.

id SecurityId

Security ID.

creator Func<string, Security>

Creator.

isNew bool

Is newly created.

Returns

Security

Security.

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.

GetOrCreatePortfolio(IPositionStorage, string, Func<string, Portfolio>, out bool)

Get or create (if not exist).

public static Portfolio GetOrCreatePortfolio(this IPositionStorage storage, string portfolioName, Func<string, Portfolio> creator, out bool isNew)

Parameters

storage IPositionStorage

Storage.

portfolioName string

Portfolio code name.

creator Func<string, Portfolio>

Creator.

isNew bool

Is newly created.

Returns

Portfolio

Portfolio.

GetOrCreatePosition(IPositionStorage, Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Func<Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Position>, out bool)

Get or create (if not exist).

public static Position GetOrCreatePosition(this IPositionStorage storage, Portfolio portfolio, Security security, string strategyId, Sides? side, string clientCode, string depoName, TPlusLimits? limitType, Func<Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Position> creator, out bool isNew)

Parameters

storage IPositionStorage

Storage.

portfolio Portfolio

Portfolio.

security Security

Security.

strategyId string

Strategy ID.

side Sides?

Side.

clientCode string

Client code.

depoName string

Depo name.

limitType TPlusLimits?

Limit type.

creator Func<Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Position>

Creator.

isNew bool

Is newly created.

Returns

Position

Position.

GetOrderLog(IMessageAdapter, SecurityId, DateTime, DateTime, int?, SecurityTypes?)

To get order log.

public static IEnumerable<ExecutionMessage> GetOrderLog(this IMessageAdapter adapter, SecurityId securityId, DateTime beginDate, DateTime endDate, int? maxCount = null, SecurityTypes? secType = null)

Parameters

adapter IMessageAdapter

Adapter.

securityId SecurityId

Security ID.

beginDate DateTime

Start date.

endDate DateTime

End date.

maxCount int?

Count

secType SecurityTypes?

SecurityType.

Returns

IEnumerable<ExecutionMessage>

Order log.

GetPnL(Portfolio)

To calculate profit-loss based on the portfolio.

public static decimal? GetPnL(this Portfolio portfolio)

Parameters

portfolio Portfolio

The portfolio, for which the profit-loss shall be calculated.

Returns

decimal?

Profit-loss.

GetPosition(MyTrade)

To get the position on own trade.

public static decimal GetPosition(this MyTrade trade)

Parameters

trade MyTrade

Own trade, used for position calculation. At buy the trade volume Volume is taken with positive sign, at sell - with negative.

Returns

decimal

Position.

GetPosition(ExecutionMessage, bool)

To get the position on own trade.

[Obsolete]
public static decimal? GetPosition(this ExecutionMessage message, bool byOrder)

Parameters

message ExecutionMessage

Own trade, used for position calculation. At buy the trade volume TradeVolume is taken with positive sign, at sell - with negative.

byOrder bool

To check implemented volume by order balance (Balance) or by received trades. The default is checked by the order.

Returns

decimal?

Position.

GetSecurities(IMessageAdapter, SecurityLookupMessage)

Download all securities.

public static IEnumerable<SecurityMessage> GetSecurities(this IMessageAdapter adapter, SecurityLookupMessage lookupMsg)

Parameters

adapter IMessageAdapter

Adapter.

lookupMsg SecurityLookupMessage

Message security lookup for specified criteria.

Returns

IEnumerable<SecurityMessage>

All securities.

GetSecurityCriteria(Connector, SecurityLookupMessage, IExchangeInfoProvider)

To create the search criteria Security from SecurityLookupMessage.

public static Security GetSecurityCriteria(this Connector connector, SecurityLookupMessage criteria, IExchangeInfoProvider exchangeInfoProvider)

Parameters

connector Connector

Connection to the trading system.

criteria SecurityLookupMessage

The criterion which fields will be used as a filter.

exchangeInfoProvider IExchangeInfoProvider

Exchanges and trading boards provider.

Returns

Security

Search criterion.

GetSecurityValue<T>(IMarketDataProvider, Security, Level1Fields)

To get the value of market data for the instrument.

public static T GetSecurityValue<T>(this IMarketDataProvider provider, Security security, Level1Fields field)

Parameters

provider IMarketDataProvider

The market data provider.

security Security

Security.

field Level1Fields

Market-data field.

Returns

T

The field value. If no data, the null will be returned.

Type Parameters

T

The type of the market data field value.

GetSecurityValues(IMarketDataProvider, Security)

To get all market data values for the instrument.

public static IDictionary<Level1Fields, object> GetSecurityValues(this IMarketDataProvider provider, Security security)

Parameters

provider IMarketDataProvider

The market data provider.

security Security

Security.

Returns

IDictionary<Level1Fields, object>

Filed values. If there is no data, null is returned.

GetTheoreticalTrades(MarketDepth, Order)

To get probable trades for order book for the given order.

[Obsolete]
public static IEnumerable<MyTrade> GetTheoreticalTrades(this MarketDepth depth, Order order)

Parameters

depth MarketDepth

The order book, reflecting situation on market at the moment of function call.

order Order

The order, for which probable trades shall be calculated.

Returns

IEnumerable<MyTrade>

Probable trades.

GetTheoreticalTrades(MarketDepth, Sides, decimal)

To get probable trades by the order book for the market price and given volume.

[Obsolete]
public static IEnumerable<MyTrade> GetTheoreticalTrades(this MarketDepth depth, Sides orderDirection, decimal volume)

Parameters

depth MarketDepth

The order book, reflecting situation on market at the moment of function call.

orderDirection Sides

Order side.

volume decimal

The volume, supposed to be implemented.

Returns

IEnumerable<MyTrade>

Probable trades.

GetTheoreticalTrades(MarketDepth, Sides, decimal, decimal)

To get probable trades by order book for given price and volume.

[Obsolete]
public static IEnumerable<MyTrade> GetTheoreticalTrades(this MarketDepth depth, Sides side, decimal volume, decimal price)

Parameters

depth MarketDepth

The order book, reflecting situation on market at the moment of function call.

side Sides

Order side.

volume decimal

The volume, supposed to be implemented.

price decimal

The price, based on which the order is supposed to be forwarded. If it equals 0, option of market order will be considered.

Returns

IEnumerable<MyTrade>

Probable trades.

GetTicks(IMessageAdapter, SecurityId, DateTime, DateTime, int?, SecurityTypes?)

To get tick data.

public static IEnumerable<ExecutionMessage> GetTicks(this IMessageAdapter adapter, SecurityId securityId, DateTime beginDate, DateTime endDate, int? maxCount = null, SecurityTypes? secType = null)

Parameters

adapter IMessageAdapter

Adapter.

securityId SecurityId

Security ID.

beginDate DateTime

Start date.

endDate DateTime

End date.

maxCount int?

Count

secType SecurityTypes?

SecurityType.

Returns

IEnumerable<ExecutionMessage>

Tick data.

GetTrades(Order, IConnector)

To get order trades.

[Obsolete]
public static IEnumerable<MyTrade> GetTrades(this Order order, IConnector connector)

Parameters

order Order

Orders.

connector IConnector

The connection of interaction with trade systems.

Returns

IEnumerable<MyTrade>

Trades.

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.

IsAssociated(SecurityId, ExchangeBoard)

Is specified security id associated with the board.

public static bool IsAssociated(this SecurityId securityId, ExchangeBoard board)

Parameters

securityId SecurityId

Security ID.

board ExchangeBoard

Board info.

Returns

bool

true, if associated, otherwise, false.

IsBasket(Security)

Is specified security is basket.

public static bool IsBasket(this Security security)

Parameters

security Security

Security.

Returns

bool

Check result.

IsContinuous(Security)

Is specified security is continuous.

public static bool IsContinuous(this Security security)

Parameters

security Security

Security.

Returns

bool

Check result.

IsContinuous(SecurityMessage)

Is specified security is continuous.

public static bool IsContinuous(this SecurityMessage security)

Parameters

security SecurityMessage

Security.

Returns

bool

Check result.

IsIndex(Security)

Is specified security is index.

public static bool IsIndex(this Security security)

Parameters

security Security

Security.

Returns

bool

Check result.

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.

IsMicex(ExchangeBoard)

Is MICEX board.

public static bool IsMicex(this ExchangeBoard board)

Parameters

board ExchangeBoard

Board to check.

Returns

bool

Check result.

IsRequiredType(Type, Type)

Is type compatible.

public static bool IsRequiredType(this Type type, Type required)

Parameters

type Type

Type.

required Type

Required type.

Returns

bool

Check result.

IsRequiredType<T>(Type)

Is type compatible.

public static bool IsRequiredType<T>(this Type type)

Parameters

type Type

Type.

Returns

bool

Check result.

Type Parameters

T

Required type.

IsSame(Portfolio, string)

Determines the specified portfolio is required.

public static bool IsSame(this Portfolio portfolio, string uniqueId)

Parameters

portfolio Portfolio

Portfolio.

uniqueId string

Portfolio identifier.

Returns

bool

Check result.

IsStockSharp(News)

Determines whether the specified news related with StockSharp.

public static bool IsStockSharp(this News news)

Parameters

news News

News.

Returns

bool

Check result.

IsTradeTime(ExchangeBoard, DateTimeOffset)

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

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

Parameters

board ExchangeBoard

Board info.

time DateTimeOffset

The passed time to be checked.

Returns

bool

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

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

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

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

Parameters

board ExchangeBoard

Board info.

time DateTimeOffset

The passed time to be checked.

isWorkingDay bool?

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

period WorkingTimePeriod

Current working time period.

Returns

bool

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

IsUxStock(ExchangeBoard)

Is the UX exchange stock market board.

public static bool IsUxStock(this ExchangeBoard board)

Parameters

board ExchangeBoard

Board to check.

Returns

bool

Check result.

Lookup(ISecurityProvider, Security)

Lookup securities by criteria criteria.

public static IEnumerable<Security> Lookup(this ISecurityProvider provider, Security criteria)

Parameters

provider ISecurityProvider

The provider of information about instruments.

criteria Security

The instrument whose fields will be used as a filter.

Returns

IEnumerable<Security>

Found instruments.

LookupAll(Connector)

Lookup securities, portfolios and orders.

public static void LookupAll(this Connector connector)

Parameters

connector Connector

The connection of interaction with trade systems.

LookupAll(ISecurityProvider)

Get all available instruments.

public static IEnumerable<Security> LookupAll(this ISecurityProvider provider)

Parameters

provider ISecurityProvider

The provider of information about instruments.

Returns

IEnumerable<Security>

All available instruments.

LookupBoards(ISubscriptionProvider, ExchangeBoard, IMessageAdapter, MessageOfflineModes)

To find boards that match the filter criteria. Found boards will be passed through the event LookupBoardsResult.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupBoards(this ISubscriptionProvider provider, ExchangeBoard criteria, IMessageAdapter adapter = null, MessageOfflineModes offlineMode = MessageOfflineModes.None)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria ExchangeBoard

The criterion which fields will be used as a filter.

adapter IMessageAdapter

Target adapter. Can be null.

offlineMode MessageOfflineModes

Offline mode handling message.

Returns

Subscription

Subscription.

LookupBoards(ISubscriptionProvider, BoardLookupMessage)

To find boards that match the filter criteria. Found boards will be passed through the event LookupBoardsResult.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupBoards(this ISubscriptionProvider provider, BoardLookupMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria BoardLookupMessage

The criterion which fields will be used as a filter.

Returns

Subscription

Subscription.

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.

LookupByCode(ISecurityProvider, string, SecurityTypes?)

To get the instrument by the instrument code.

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

Parameters

provider ISecurityProvider

The provider of information about instruments.

code string

Security code.

type SecurityTypes?

Security type.

Returns

IEnumerable<Security>

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

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.

LookupByNativeId(ISecurityProvider, INativeIdStorage, string, object)

To get the instrument by the system identifier.

public static Security LookupByNativeId(this ISecurityProvider provider, INativeIdStorage nativeIdStorage, string storageName, object nativeId)

Parameters

provider ISecurityProvider

The provider of information about instruments.

nativeIdStorage INativeIdStorage

Security native identifier storage.

storageName string

Storage name.

nativeId object

Native (internal) trading system security id.

Returns

Security

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

LookupOrders(ISubscriptionProvider, Order, IMessageAdapter, MessageOfflineModes)

To find orders that match the filter criteria. Found orders will be passed through the event NewOrder.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupOrders(this ISubscriptionProvider provider, Order criteria, IMessageAdapter adapter = null, MessageOfflineModes offlineMode = MessageOfflineModes.None)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria Order

The order which fields will be used as a filter.

adapter IMessageAdapter

Target adapter. Can be null.

offlineMode MessageOfflineModes

Offline mode handling message.

Returns

Subscription

Subscription.

LookupOrders(ISubscriptionProvider, OrderStatusMessage)

To find orders that match the filter criteria. Found orders will be passed through the event NewOrder.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupOrders(this ISubscriptionProvider provider, OrderStatusMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria OrderStatusMessage

The order which fields will be used as a filter.

Returns

Subscription

Subscription.

LookupPortfolios(ISubscriptionProvider, Portfolio, IMessageAdapter, MessageOfflineModes)

To find portfolios that match the filter criteria. Found portfolios will be passed through the event LookupPortfoliosResult.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupPortfolios(this ISubscriptionProvider provider, Portfolio criteria, IMessageAdapter adapter = null, MessageOfflineModes offlineMode = MessageOfflineModes.None)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria Portfolio

The criterion which fields will be used as a filter.

adapter IMessageAdapter

Target adapter. Can be null.

offlineMode MessageOfflineModes

Offline mode handling message.

Returns

Subscription

Subscription.

LookupPortfolios(ISubscriptionProvider, PortfolioLookupMessage)

To find portfolios that match the filter criteria. Found portfolios will be passed through the event LookupPortfoliosResult.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupPortfolios(this ISubscriptionProvider provider, PortfolioLookupMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria PortfolioLookupMessage

The criterion which fields will be used as a filter.

Returns

Subscription

Subscription.

LookupSecurities(ISubscriptionProvider, Security, IMessageAdapter, MessageOfflineModes)

To find instruments that match the filter criteria. Found instruments will be passed through the event LookupSecuritiesResult.

public static Subscription LookupSecurities(this ISubscriptionProvider provider, Security criteria, IMessageAdapter adapter = null, MessageOfflineModes offlineMode = MessageOfflineModes.None)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria Security

The criterion which fields will be used as a filter.

adapter IMessageAdapter

Target adapter. Can be null.

offlineMode MessageOfflineModes

Offline mode handling message.

Returns

Subscription

Subscription.

LookupSecurities(ISubscriptionProvider, SecurityLookupMessage)

To find instruments that match the filter criteria. Found instruments will be passed through the event LookupSecuritiesResult.

public static Subscription LookupSecurities(this ISubscriptionProvider provider, SecurityLookupMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria SecurityLookupMessage

The criterion which fields will be used as a filter.

Returns

Subscription

Subscription.

LookupTimeFrames(ISubscriptionProvider, TimeFrameLookupMessage)

To find time-frames that match the filter criteria. Found time-frames will be passed through the event LookupTimeFramesResult.

[Obsolete("Use ISubscriptionProvider.Subscribe method.")]
public static Subscription LookupTimeFrames(this ISubscriptionProvider provider, TimeFrameLookupMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria TimeFrameLookupMessage

The criterion which fields will be used as a filter.

Returns

Subscription

Subscription.

ShrinkPrice(Order, ShrinkRules)

To cut the price for the order, to make it multiple of the minimal step, also to limit number of decimal places.

public static void ShrinkPrice(this Order order, ShrinkRules rule = ShrinkRules.Auto)

Parameters

order Order

The order for which the price will be cut Price.

rule ShrinkRules

The price rounding rule.

ShrinkPrice(Security, decimal, ShrinkRules)

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

public static decimal ShrinkPrice(this Security security, decimal price, ShrinkRules rule = ShrinkRules.Auto)

Parameters

security Security

The instrument from which the PriceStep and Decimals values are taken.

price decimal

The price to be made multiple.

rule ShrinkRules

The price rounding rule.

Returns

decimal

The multiple price.

SubscribeBoard(ISubscriptionProvider, ExchangeBoard, DateTimeOffset?, DateTimeOffset?, long?, IMessageAdapter, long?)

Subscribe on the board changes.

public static Subscription SubscribeBoard(this ISubscriptionProvider provider, ExchangeBoard board, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, IMessageAdapter adapter = null, long? skip = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

board ExchangeBoard

Board for 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?

Max count.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

Returns

Subscription

Subscription.

SubscribeCandles(ISubscriptionProvider, CandleSeries, DateTimeOffset?, DateTimeOffset?, long?, long?, IMessageAdapter, long?, FillGapsDays?)

Subscribe to receive new candles.

public static Subscription SubscribeCandles(this ISubscriptionProvider provider, CandleSeries series, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, long? transactionId = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

series CandleSeries

Candles series.

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.

transactionId long?

Transaction ID.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribeFilteredMarketDepth(ISubscriptionProvider, Security)

To start getting filtered quotes (order book) by the instrument. Quotes values are available through the event OrderBookReceived.

public static Subscription SubscribeFilteredMarketDepth(this ISubscriptionProvider provider, Security security)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which quotes getting should be started.

Returns

Subscription

Subscription.

SubscribeLevel1(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, MarketDataBuildModes, DataType, IMessageAdapter, long?, FillGapsDays?)

To start getting new information (for example, LastTick or BestBid) by the instrument.

public static Subscription SubscribeLevel1(this ISubscriptionProvider provider, Security security, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, MarketDataBuildModes buildMode = MarketDataBuildModes.LoadAndBuild, DataType buildFrom = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which new information getting should be started.

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?

Max count.

buildMode MarketDataBuildModes

Build mode.

buildFrom DataType

Which market-data type is used as a source value.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribeMarketData(ISubscriptionProvider, Security, MarketDataMessage)

To subscribe to get market data by the instrument.

public static Subscription SubscribeMarketData(this ISubscriptionProvider provider, Security security, MarketDataMessage message)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which new information getting should be started.

message MarketDataMessage

The message that contain subscribe info.

Returns

Subscription

Subscription.

SubscribeMarketData(ISubscriptionProvider, MarketDataMessage)

To subscribe to get market data.

public static Subscription SubscribeMarketData(this ISubscriptionProvider provider, MarketDataMessage message)

Parameters

provider ISubscriptionProvider

Subscription provider.

message MarketDataMessage

The message that contain subscribe info.

Returns

Subscription

Subscription.

SubscribeMarketDepth(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, MarketDataBuildModes, DataType, int?, TimeSpan?, IOrderLogMarketDepthBuilder, bool, IMessageAdapter, long?, FillGapsDays?)

To start getting quotes (order book) by the instrument. Quotes values are available through the event MarketDepthChanged.

public static Subscription SubscribeMarketDepth(this ISubscriptionProvider provider, Security security, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, MarketDataBuildModes buildMode = MarketDataBuildModes.LoadAndBuild, DataType buildFrom = null, int? maxDepth = null, TimeSpan? refreshSpeed = null, IOrderLogMarketDepthBuilder depthBuilder = null, bool passThroughOrderBookInrement = false, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which quotes getting should be started.

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?

Max count.

buildMode MarketDataBuildModes

Build mode.

buildFrom DataType

Which market-data type is used as a source value.

maxDepth int?

Max depth of requested order book.

refreshSpeed TimeSpan?

Interval for data refresh.

depthBuilder IOrderLogMarketDepthBuilder

Order log to market depth builder.

passThroughOrderBookInrement bool

Pass through incremental QuoteChangeMessage.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribeNews(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, IMessageAdapter, long?)

Subscribe on news.

public static Subscription SubscribeNews(this ISubscriptionProvider provider, Security security = null, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, IMessageAdapter adapter = null, long? skip = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

Security for 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?

Max count.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

Returns

Subscription

Subscription.

SubscribeOrderLog(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, IMessageAdapter, long?, FillGapsDays?)

Subscribe on order log for the security.

public static Subscription SubscribeOrderLog(this ISubscriptionProvider provider, Security security, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

Security for 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?

Max count.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribeOrders(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, IEnumerable<OrderStates>, IMessageAdapter, long?, FillGapsDays?)

Subscribe on orders changes.

public static Subscription SubscribeOrders(this ISubscriptionProvider provider, Security security = null, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, IEnumerable<OrderStates> states = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

Security for 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?

Max count.

states IEnumerable<OrderStates>

Filter order by the specified states.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribeOrders(ISubscriptionProvider, OrderStatusMessage)

To find orders that match the filter criteria. Found orders will be passed through the event NewOrder.

public static Subscription SubscribeOrders(this ISubscriptionProvider provider, OrderStatusMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria OrderStatusMessage

The order which fields will be used as a filter.

Returns

Subscription

Subscription.

SubscribePositions(ISubscriptionProvider, Security, Portfolio, DateTimeOffset?, DateTimeOffset?, long?, IMessageAdapter, long?, FillGapsDays?)

Subscribe on positions changes.

public static Subscription SubscribePositions(this ISubscriptionProvider provider, Security security = null, Portfolio portfolio = null, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument on which the position should be found.

portfolio Portfolio

The portfolio on which the position should be found.

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?

Max count.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

SubscribePositions(ISubscriptionProvider, PortfolioLookupMessage)

To find portfolios that match the filter criteria. Found portfolios will be passed through the event LookupPortfoliosResult.

public static Subscription SubscribePositions(this ISubscriptionProvider provider, PortfolioLookupMessage criteria)

Parameters

provider ISubscriptionProvider

Subscription provider.

criteria PortfolioLookupMessage

The criterion which fields will be used as a filter.

Returns

Subscription

Subscription.

SubscribeTrades(ISubscriptionProvider, Security, DateTimeOffset?, DateTimeOffset?, long?, MarketDataBuildModes, DataType, IMessageAdapter, long?, FillGapsDays?)

To start getting trades (tick data) by the instrument. New trades will come through the event NewTrade.

public static Subscription SubscribeTrades(this ISubscriptionProvider provider, Security security, DateTimeOffset? from = null, DateTimeOffset? to = null, long? count = null, MarketDataBuildModes buildMode = MarketDataBuildModes.LoadAndBuild, DataType buildFrom = null, IMessageAdapter adapter = null, long? skip = null, FillGapsDays? fillGaps = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which trades getting should be started.

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?

Max count.

buildMode MarketDataBuildModes

Build mode.

buildFrom DataType

Which market-data type is used as a source value.

adapter IMessageAdapter

Target adapter. Can be null.

skip long?

Skip count.

fillGaps FillGapsDays?

FillGapsDays

Returns

Subscription

Subscription.

ToBasket(Security, IBasketSecurityProcessorProvider)

Convert Security to BasketSecurity value.

public static BasketSecurity ToBasket(this Security security, IBasketSecurityProcessorProvider processorProvider)

Parameters

security Security

Security.

processorProvider IBasketSecurityProcessorProvider

Basket security processors provider.

Returns

BasketSecurity

Instruments basket.

ToBasket<TBasketSecurity>(Security)

Convert Security to BasketSecurity value.

public static TBasketSecurity ToBasket<TBasketSecurity>(this Security security) where TBasketSecurity : BasketSecurity, new()

Parameters

security Security

Security.

Returns

TBasketSecurity

Instruments basket.

Type Parameters

TBasketSecurity

Basket security type.

ToBasket<TMessage>(IEnumerable<TMessage>, Security, IBasketSecurityProcessorProvider)

Convert inner securities messages to basket.

public static IEnumerable<TMessage> ToBasket<TMessage>(this IEnumerable<TMessage> innerSecMessages, Security security, IBasketSecurityProcessorProvider processorProvider) where TMessage : Message

Parameters

innerSecMessages IEnumerable<TMessage>

Inner securities messages.

security Security

Basket security.

processorProvider IBasketSecurityProcessorProvider

Basket security processors provider.

Returns

IEnumerable<TMessage>

Messages of basket securities.

Type Parameters

TMessage

Message type.

ToChannelState(ProcessStates)

Convert ProcessStates value to ChannelStates.

public static ChannelStates ToChannelState(this ProcessStates state)

Parameters

state ProcessStates

ProcessStates value.

Returns

ChannelStates

ChannelStates value.

ToPositionManager(Position)

Convert the position object to the type IPositionManager.

[Obsolete]
public static IPositionManager ToPositionManager(this Position position)

Parameters

position Position

Position.

Returns

IPositionManager

Position calc manager.

ToProcessState(ChannelStates)

Convert ChannelStates value to ProcessStates.

public static ProcessStates ToProcessState(this ChannelStates state)

Parameters

state ChannelStates

ChannelStates value.

Returns

ProcessStates

ProcessStates value.

ToTimeQuotes(QuoteChangeMessage)

Convert depth to quotes.

public static IEnumerable<TimeQuoteChange> ToTimeQuotes(this QuoteChangeMessage message)

Parameters

message QuoteChangeMessage

Depth.

Returns

IEnumerable<TimeQuoteChange>

Quotes.

ToTimeQuotes(IEnumerable<QuoteChangeMessage>)

Convert depths to quotes.

public static IEnumerable<TimeQuoteChange> ToTimeQuotes(this IEnumerable<QuoteChangeMessage> messages)

Parameters

messages IEnumerable<QuoteChangeMessage>

Depths.

Returns

IEnumerable<TimeQuoteChange>

Quotes.

TryGetAdapter(IPortfolioMessageAdapterProvider, IMessageAdapterProvider, Portfolio)

Get adapter by portfolio.

public static IMessageAdapter TryGetAdapter(this IPortfolioMessageAdapterProvider portfolioProvider, IMessageAdapterProvider adapterProvider, Portfolio portfolio)

Parameters

portfolioProvider IPortfolioMessageAdapterProvider

The portfolio based message adapter's provider.

adapterProvider IMessageAdapterProvider

The message adapter's provider.

portfolio Portfolio

Portfolio.

Returns

IMessageAdapter

Found adapter or null.

TryGetAdapter(IPortfolioMessageAdapterProvider, IEnumerable<IMessageAdapter>, Portfolio)

Get adapter by portfolio.

public static IMessageAdapter TryGetAdapter(this IPortfolioMessageAdapterProvider portfolioProvider, IEnumerable<IMessageAdapter> adapters, Portfolio portfolio)

Parameters

portfolioProvider IPortfolioMessageAdapterProvider

The portfolio based message adapter's provider.

adapters IEnumerable<IMessageAdapter>

All available adapters.

portfolio Portfolio

Portfolio.

Returns

IMessageAdapter

Found adapter or null.

UnSubscribe(ISubscriptionProvider, long)

Unsubscribe.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribe(this ISubscriptionProvider provider, long subscriptionId)

Parameters

provider ISubscriptionProvider

Subscription provider.

subscriptionId long

Subscription id.

UnSubscribeBoard(ISubscriptionProvider, ExchangeBoard)

Unsubscribe from the board changes.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeBoard(this ISubscriptionProvider provider, ExchangeBoard board)

Parameters

provider ISubscriptionProvider

Subscription provider.

board ExchangeBoard

Board for unsubscription.

UnSubscribeCandles(ISubscriptionProvider, CandleSeries)

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeCandles(this ISubscriptionProvider provider, CandleSeries series)

Parameters

provider ISubscriptionProvider

Subscription provider.

series CandleSeries

Candles series.

UnSubscribeLevel1(ISubscriptionProvider, Security)

To stop getting new information.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeLevel1(this ISubscriptionProvider provider, Security security)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which new information getting should be stopped.

UnSubscribeMarketData(ISubscriptionProvider, Security, MarketDataMessage)

To unsubscribe from getting market data by the instrument.

public static void UnSubscribeMarketData(this ISubscriptionProvider provider, Security security, MarketDataMessage message)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which new information getting should be started.

message MarketDataMessage

The message that contain unsubscribe info.

UnSubscribeMarketData(ISubscriptionProvider, MarketDataMessage)

To unsubscribe from getting market data.

public static void UnSubscribeMarketData(this ISubscriptionProvider provider, MarketDataMessage message)

Parameters

provider ISubscriptionProvider

Subscription provider.

message MarketDataMessage

The message that contain unsubscribe info.

UnSubscribeMarketDepth(ISubscriptionProvider, Security)

To stop getting quotes by the instrument.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeMarketDepth(this ISubscriptionProvider provider, Security security)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which quotes getting should be stopped.

UnSubscribeNews(ISubscriptionProvider, Security)

Unsubscribe from news.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeNews(this ISubscriptionProvider provider, Security security = null)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

Security for subscription.

UnSubscribeOrderLog(ISubscriptionProvider, Security)

Unsubscribe from order log for the security.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeOrderLog(this ISubscriptionProvider provider, Security security)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

Security for unsubscription.

UnSubscribeOrders(ISubscriptionProvider, long)

Unsubscribe from orders changes.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeOrders(this ISubscriptionProvider provider, long originalTransactionId = 0)

Parameters

provider ISubscriptionProvider

Subscription provider.

originalTransactionId long

ID of the original message SubscribeOrders(ISubscriptionProvider, OrderStatusMessage) for which this message is a response.

UnSubscribePositions(ISubscriptionProvider, long)

Unsubscribe from positions changes.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribePositions(this ISubscriptionProvider provider, long originalTransactionId = 0)

Parameters

provider ISubscriptionProvider

Subscription provider.

originalTransactionId long

ID of the original message SubscribePositions(ISubscriptionProvider, PortfolioLookupMessage) for which this message is a response.

UnSubscribeTrades(ISubscriptionProvider, Security)

To stop getting trades (tick data) by the instrument.

[Obsolete("Use ISubscriptionProvider.UnSubscribe method.")]
public static void UnSubscribeTrades(this ISubscriptionProvider provider, Security security)

Parameters

provider ISubscriptionProvider

Subscription provider.

security Security

The instrument by which trades getting should be stopped.

Upload<TMessage>(IMessageAdapter, IEnumerable<TMessage>)

Upload data.

public static void Upload<TMessage>(this IMessageAdapter adapter, IEnumerable<TMessage> messages) where TMessage : Message

Parameters

adapter IMessageAdapter

Adapter.

messages IEnumerable<TMessage>

Messages.

Type Parameters

TMessage

Request type.

ValidateId(ref string)

To check the correctness of the entered identifier.

public static string ValidateId(ref string id)

Parameters

id string

Security ID.

Returns

string

An error message text, or null if no error.