TraderHelper
The auxiliary class for provision of various algorithmic functionalities.
Свойства
IndicatorValue : DataType
Indicator value.
Методы
AddAdapter(Connector, Type, Action<IMessageAdapter>) : IMessageAdapter
Create IMessageAdapter.
- connector
- The class to create connections to trading systems.
- adapterType
- Adapter type.
- init
- Initialize adapter.
Возвращает: The class to create connections to trading systems.
AddAdapter``1(Connector, Action<T>)
Create IMessageAdapter.
- connector
- The class to create connections to trading systems.
- init
- Initialize adapter.
Возвращает: The class to create connections to trading systems.
AddOrderErrorLog(ILogReceiver, Order, string, Func<string>)
Write order error to the log.
- receiver
- Logs receiver.
- order
- Order.
- operation
- Order action name.
- getAdditionalInfo
- Extended order info.
AddOrderInfoLog(ILogReceiver, Order, string, Func<string>)
Write order info to the log.
- receiver
- Logs receiver.
- order
- Order.
- operation
- Order action name.
- getAdditionalInfo
- Extended order info.
ApplyOffset(decimal, Sides, Unit, Security) : decimal
To use shifting for price, depending on direction .
- price
- Price.
- side
- The order direction, used as shift direction (for buy the shift is added, for sell - subtracted).
- offset
- Price shift.
- security
- Security.
Возвращает: New price.
CancelOrders(IConnector, IEnumerable<Order>, bool?, Portfolio, Sides?, ExchangeBoard, Security, SecurityTypes?)
Cancel orders by filter.
- connector
- The connection of interaction with trade systems.
- orders
- The group of orders, from which the required orders shall be found and cancelled.
- isStopOrder
- , if cancel only a stop orders, - if regular orders, - both.
- portfolio
- Portfolio. If the value is equal to , then the portfolio does not match the orders cancel filter.
- side
- Order side. If the value is , the direction does not use.
- board
- Trading board. If the value is equal to , then the board does not match the orders cancel filter.
- security
- Instrument. If the value is equal to , then the instrument does not match the orders cancel filter.
- securityType
- Security type. If the value is , the type does not use.
Compile(string, IFileSystem, AssemblyLoadContextTracker) : ExpressionFormula<T>
Compile mathematical formula.
- expression
- Text expression.
- fileSystem
- File system.
- tracker
- AssemblyLoadContextTracker
Возвращает: Compiled mathematical formula.
CompileAsync(string, IFileSystem, AssemblyLoadContextTracker, CancellationToken) : Task<ExpressionFormula<T>>
Compile mathematical formula.
- expression
- Text expression.
- fileSystem
- File system.
- tracker
- AssemblyLoadContextTracker
- cancellationToken
- CancellationToken
Возвращает: Compiled mathematical formula.
CompileAsync``1(string, IFileSystem, AssemblyLoadContextTracker, CancellationToken)
Compile mathematical formula.
- expression
- Text expression.
- fileSystem
- File system.
- tracker
- AssemblyLoadContextTracker
- cancellationToken
- CancellationToken
Возвращает: Compiled mathematical formula.
Compile``1(string, IFileSystem, AssemblyLoadContextTracker)
Compile mathematical formula.
- expression
- Text expression.
- fileSystem
- File system.
- tracker
- AssemblyLoadContextTracker
Возвращает: Compiled mathematical formula.
Contains(BasketSecurity, ISecurityProvider, Security) : bool
To check whether specified instrument is used now.
- basketSecurity
- Instruments basket.
- securityProvider
- The provider of information about instruments.
- security
- The instrument that should be checked.
Возвращает: , if specified instrument is used now, otherwise .
CreateProcessor(IBasketSecurityProcessorProvider, Security) : IBasketSecurityProcessor
Create market data processor for basket securities.
- processorProvider
- Basket security processors provider.
- security
- Basket security.
Возвращает: Market data processor for basket securities.
DeleteAllAsync(ISecurityStorage, CancellationToken) : ValueTask
To delete all instruments.
- storage
- Securities meta info storage.
- cancellationToken
- CancellationToken
ExtractBoardsAsync(byte[]) : IAsyncEnumerable<BoardMessage>
Extract boards from the archive.
- archive
- The archive.
Возвращает: Boards.
ExtractSecuritiesAsync(byte[]) : IAsyncEnumerable<SecurityMessage>
Extract securities from the archive.
- archive
- The archive.
Возвращает: Securities.
FillFortsJumps(ExpirationContinuousSecurity, ISecurityProvider, string, DateTime, DateTime)
To fill transitions ExpirationJumps.
- continuousSecurity
- Continuous security.
- provider
- The provider of information about instruments.
- baseCode
- The base part of the instrument code.
- from
- The start of the expiration range.
- to
- The end of the expiration range.
Filter(IEnumerable<Order>, Security) : IEnumerable<MyTrade>
To filter orders for the given instrument.
- orders
- All orders, in which the required shall be searched for.
- security
- The instrument, for which the orders shall be filtered.
Возвращает: Filtered orders.
Filter(IEnumerable<Position>, Security) : IEnumerable<MyTrade>
To filter positions for the given instrument.
- positions
- All positions, in which the required shall be searched for.
- security
- The instrument, for which positions shall be filtered.
Возвращает: Filtered positions.
Filter(IEnumerable<MyTrade>, Security) : IEnumerable<MyTrade>
To filter own trades for the given instrument.
- myTrades
- All own trades, in which the required shall be looked for.
- security
- The instrument, on which the trades shall be found.
Возвращает: Filtered trades.
GenerateId(SecurityIdGenerator, string, ExchangeBoard) : string
Generate SecurityId security.
- generator
- SecurityIdGenerator
- secCode
- Security code.
- board
- Security board.
Возвращает: Id security.
GetAllSecurity(ISecurityProvider) : Security
Find AllSecurity instance in the specified provider.
- provider
- The provider of information about instruments.
Возвращает: Found instance.
GetCurrentPrice(Security, IMarketDataProvider, Sides?) : decimal?
To calculate the current price by the instrument depending on the order direction.
- security
- The instrument used for the current price calculation.
- provider
- The market data provider.
- direction
- Order side.
Возвращает: The current price. If information in order book is insufficient, then will be returned.
GetDirection(decimal) : Sides?
To get the order direction for the position.
- position
- The position value.
Возвращает: Order side.
GetDirection(Position) : Sides?
To get the order direction for the position.
- position
- The position value.
Возвращает: Order side.
GetFortsJumps(string, DateTime, DateTime, Func<string, Security>, bool) : IEnumerable<Security>
To get real expiration instruments for base part of the code.
- baseCode
- The base part of the instrument code.
- from
- The start of the expiration range.
- to
- The end of the expiration range.
- getSecurity
- The function to get instrument by the code.
- throwIfNotExists
- To generate exception, if some of instruments are not available.
Возвращает: Expiration instruments.
GetFortsJumps(ExpirationContinuousSecurity, ISecurityProvider, string, DateTime, DateTime, bool) : IEnumerable<Security>
To get real expiration instruments for the continuous instrument.
- continuousSecurity
- Continuous security.
- provider
- The provider of information about instruments.
- baseCode
- The base part of the instrument code.
- from
- The start of the expiration range.
- to
- The end of the expiration range.
- throwIfNotExists
- To generate exception, if some of instruments for passed are not available.
Возвращает: Expiration instruments.
GetInnerSecurities(BasketSecurity, ISecurityProvider) : IEnumerable<Security>
Find inner security instances.
- security
- Instruments basket.
- securityProvider
- The provider of information about instruments.
Возвращает: Instruments, from which this basket is created.
GetOrCreate(ISecurityStorage, SecurityId, Func<string, Security>, bool) : Security
Get or create (if not exist).
- storage
- Securities meta info storage.
- id
- Security ID.
- creator
- Creator.
- isNew
- Is newly created.
Возвращает: Security.
GetOrCreateAsync(ISecurityStorage, SecurityId, Func<string, Security>, CancellationToken) : ValueTask<ValueTuple<Security, bool>>
Get or create (if not exist).
- storage
- Securities meta info storage.
- id
- Security ID.
- creator
- Creator.
- cancellationToken
- CancellationToken
Возвращает: Security and the flag whether it was newly created.
GetOrCreatePortfolio(IPositionStorage, string, Func<string, Portfolio>, bool) : Portfolio
Get or create (if not exist).
- storage
- Storage.
- portfolioName
- Portfolio code name.
- creator
- Creator.
- isNew
- Is newly created.
Возвращает: Portfolio.
GetOrCreatePosition(IPositionStorage, Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Func<Portfolio, Security, string, Sides?, string, string, TPlusLimits?, Position>, bool) : Position
Get or create (if not exist).
- storage
- Storage.
- portfolio
- Portfolio.
- security
- Security.
- strategyId
- Strategy ID.
- side
- Side.
- clientCode
- Client code.
- depoName
- Depo name.
- limitType
- Limit type.
- creator
- Creator.
- isNew
- Is newly created.
Возвращает: Position.
GetPnL(IPnLManager) : decimal
Get the total profit and loss (PnL) value.
- manager
- IPnLManager
Возвращает: Total profit and loss (PnL) value, which is the sum of unrealized and realized PnL.
GetPnL(Portfolio) : decimal
To calculate profit-loss based on the portfolio.
- portfolio
- The portfolio, for which the profit-loss shall be calculated.
Возвращает: Profit-loss.
GetPosition(MyTrade) : decimal
To get the position on own trade.
- trade
- Own trade, used for position calculation. At buy the trade volume Volume is taken with positive sign, at sell - with negative.
Возвращает: Position.
GetSecurityCriteria(Connector, SecurityLookupMessage, IExchangeInfoProvider) : Security
To create the search criteria Security from SecurityLookupMessage.
- connector
- Connection to the trading system.
- criteria
- The criterion which fields will be used as a filter.
- exchangeInfoProvider
- Exchanges and trading boards provider.
Возвращает: Search criterion.
GetSecurityValues(IMarketDataProvider, Security) : IDictionary<Level1Fields, object>
To get all market data values for the instrument.
- provider
- The market data provider.
- security
- Security.
Возвращает: Filed values. If there is no data, is returned.
GetSecurityValue``1(IMarketDataProvider, Security, Level1Fields)
To get the value of market data for the instrument.
- provider
- The market data provider.
- security
- Security.
- field
- Market-data field.
Возвращает: The field value. If no data, the will be returned.
IsAssociated(SecurityId, ExchangeBoard) : bool
Is specified security id associated with the board.
- securityId
- Security ID.
- board
- Board info.
Возвращает: , if associated, otherwise, .
IsBasket(Security) : bool
Is specified security is basket.
- security
- Security.
Возвращает: Check result.
IsContinuous(Security) : bool
Is specified security is continuous.
- security
- Security.
Возвращает: Check result.
IsContinuous(SecurityMessage) : bool
Is specified security is continuous.
- security
- Security.
Возвращает: Check result.
IsIndex(Security) : bool
Is specified security is index.
- security
- Security.
Возвращает: Check result.
IsStockSharp(News) : bool
Determines whether the specified news related with StockSharp.
- news
- News.
Возвращает: Check result.
IsTradeTime(ExchangeBoard, DateTime, bool?, WorkingTimePeriod) : bool
To check, whether the time is traded (has the session started, ended, is there a clearing).
- board
- Board info.
- time
- The passed time to be checked.
- isWorkingDay
- , if the date is traded, otherwise, is not traded.
- period
- Current working time period.
Возвращает: , if time is traded, otherwise, not traded.
IsTradeTime(ExchangeBoard, DateTime) : bool
To check, whether the time is traded (has the session started, ended, is there a clearing).
- board
- Board info.
- time
- The passed time to be checked.
Возвращает: , if time is traded, otherwise, not traded.
Lookup(ISecurityProvider, Security) : IEnumerable<Security>
Lookup securities by criteria .
- provider
- The provider of information about instruments.
- criteria
- The instrument whose fields will be used as a filter.
Возвращает: Found instruments.
LookupAll(ISecurityProvider)
Get all available instruments.
- provider
- The provider of information about instruments.
Возвращает: All available instruments.
LookupAll(Connector)
Lookup securities, portfolios and orders.
- connector
- The connection of interaction with trade systems.
LookupAllAsync(ISecurityProvider) : IAsyncEnumerable<Security>
Get all available instruments.
- provider
- The provider of information about instruments.
Возвращает: All available instruments.
LookupByCode(ISecurityProvider, string, SecurityTypes?) : IEnumerable<Security>
To get the instrument by the instrument code.
- provider
- The provider of information about instruments.
- code
- Security code.
- type
- Security type.
Возвращает: The got instrument. If there is no instrument by given criteria, is returned.
LookupByNativeIdAsync(ISecurityProvider, INativeIdStorageProvider, string, object, CancellationToken) : ValueTask<Security>
To get the instrument by the system identifier.
- provider
- The provider of information about instruments.
- nativeIdStorageProvider
- Security native identifier storage provider.
- storageName
- Storage name.
- nativeId
- Native (internal) trading system security id.
- cancellationToken
- CancellationToken
Возвращает: The got instrument. If there is no instrument by given criteria, is returned.
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.
- order
- The order for which the price will be cut Price.
- rule
- The price rounding rule.
ShrinkPrice(Security, decimal, ShrinkRules) : decimal
To cut the price, to make it multiple of minimal step, also to limit number of signs after the comma.
- security
- The instrument from which the PriceStep and Decimals values are taken.
- price
- The price to be made multiple.
- rule
- The price rounding rule.
Возвращает: The multiple price.
ToBasket(Security, IBasketSecurityProcessorProvider) : BasketSecurity
Convert Security to BasketSecurity value.
- security
- Security.
- processorProvider
- Basket security processors provider.
Возвращает: Instruments basket.
ToBasket``1(IAsyncEnumerable<T>, Security, IBasketSecurityProcessorProvider)
Convert inner securities messages to basket.
- innerSecMessages
- Inner securities messages.
- security
- Basket security.
- processorProvider
- Basket security processors provider.
Возвращает: Messages of basket securities.
ToBasket``1(IEnumerable<T>, Security, IBasketSecurityProcessorProvider)
Convert inner securities messages to basket.
- innerSecMessages
- Inner securities messages.
- security
- Basket security.
- processorProvider
- Basket security processors provider.
Возвращает: Messages of basket securities.
ToBasket``1(Security)
Convert Security to BasketSecurity value.
- security
- Security.
Возвращает: Instruments basket.
ToChannelState(ProcessStates) : ChannelStates
Convert ProcessStates value to ChannelStates.
- state
- ProcessStates value.
Возвращает: ChannelStates value.
ToProcessState(ChannelStates) : ProcessStates
Convert ChannelStates value to ProcessStates.
- state
- ChannelStates value.
Возвращает: ProcessStates value.
ToTimeQuotes(QuoteChangeMessage) : IEnumerable<TimeQuoteChange>
Convert depth to quotes.
- message
- Depth.
Возвращает: Quotes.
ToTimeQuotes(IEnumerable<QuoteChangeMessage>) : IEnumerable<TimeQuoteChange>
Convert depths to quotes.
- messages
- Depths.
Возвращает: Quotes.
TryGetAdapter(IPortfolioMessageAdapterProvider, IEnumerable<IMessageAdapter>, Portfolio) : IMessageAdapter
Get adapter by portfolio.
- portfolioProvider
- The portfolio based message adapter's provider.
- adapters
- All available adapters.
- portfolio
- Portfolio.
Возвращает: Found adapter or .
TryGetAdapter(IPortfolioMessageAdapterProvider, IMessageAdapterProvider, Portfolio) : IMessageAdapter
Get adapter by portfolio.
- portfolioProvider
- The portfolio based message adapter's provider.
- adapterProvider
- The message adapter's provider.
- portfolio
- Portfolio.
Возвращает: Found adapter or .
ValidateId(string) : string
To check the correctness of the entered identifier.
- id
- Security ID.
Возвращает: An error message text, or if no error.