Class MarketRuleHelper
- Namespace
- StockSharp.Algo
- Assembly
- StockSharp.Algo.dll
Extension class for IMarketRule.
public static class MarketRuleHelper
- Inheritance
-
MarketRuleHelper
- Inherited Members
Fields
DefaultRuleContainer
The container of rules, which will be applied by default to all rules, not included into strategy.
public static readonly IMarketRuleContainer DefaultRuleContainer
Field Value
Methods
ActiveRule(IMarketRuleContainer, IMarketRule, Func<bool>)
To activate the rule.
public static void ActiveRule(this IMarketRuleContainer container, IMarketRule rule, Func<bool> process)
Parameters
container
IMarketRuleContainerThe rules container.
rule
IMarketRuleRule.
process
Func<bool>The handler.
AddRuleLog(IMarketRuleContainer, LogLevels, IMarketRule, string, params object[])
To write the message from the rule.
public static void AddRuleLog(this IMarketRuleContainer container, LogLevels level, IMarketRule rule, string message, params object[] args)
Parameters
container
IMarketRuleContainerThe rules container.
level
LogLevelsThe level of the log message.
rule
IMarketRuleRule.
message
stringText message.
args
object[]Text message settings. Used if a message is the format string. For details, see Format(string, params object[]).
And(IMarketRule, params IMarketRule[])
To combine rules by AND condition.
public static IMarketRule And(this IMarketRule rule, params IMarketRule[] rules)
Parameters
rule
IMarketRuleFirst rule.
rules
IMarketRule[]Additional rules.
Returns
- IMarketRule
Combined rule.
And(IEnumerable<IMarketRule>)
To combine rules by AND condition.
public static IMarketRule And(this IEnumerable<IMarketRule> rules)
Parameters
rules
IEnumerable<IMarketRule>Rules.
Returns
- IMarketRule
Combined rule.
And<TToken, TArg>(MarketRule<TToken, TArg>, params MarketRule<TToken, TArg>[])
To combine rules by AND condition.
public static MarketRule<TToken, TArg> And<TToken, TArg>(this MarketRule<TToken, TArg> rule, params MarketRule<TToken, TArg>[] rules)
Parameters
rule
MarketRule<TToken, TArg>First rule.
rules
MarketRule<TToken, TArg>[]Additional rules.
Returns
- MarketRule<TToken, TArg>
Combined rule.
Type Parameters
TToken
The type of token.
TArg
The type of argument, accepted by the rule.
Apply(IMarketRule)
To form a rule (include IsReady).
public static IMarketRule Apply(this IMarketRule rule)
Parameters
rule
IMarketRuleRule.
Returns
- IMarketRule
Rule.
Apply(IMarketRule, IMarketRuleContainer)
To form a rule (include IsReady).
public static IMarketRule Apply(this IMarketRule rule, IMarketRuleContainer container)
Parameters
rule
IMarketRuleRule.
container
IMarketRuleContainerThe rules container.
Returns
- IMarketRule
Rule.
Apply<TToken, TArg>(MarketRule<TToken, TArg>)
To form a rule (include IsReady).
public static MarketRule<TToken, TArg> Apply<TToken, TArg>(this MarketRule<TToken, TArg> rule)
Parameters
rule
MarketRule<TToken, TArg>Rule.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TToken
The type of token.
TArg
The type of argument, accepted by the rule.
Apply<TToken, TArg>(MarketRule<TToken, TArg>, IMarketRuleContainer)
To form a rule (include IsReady).
public static MarketRule<TToken, TArg> Apply<TToken, TArg>(this MarketRule<TToken, TArg> rule, IMarketRuleContainer container)
Parameters
rule
MarketRule<TToken, TArg>Rule.
container
IMarketRuleContainerThe rules container.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TToken
The type of token.
TArg
The type of argument, accepted by the rule.
Changed(Position, IPositionProvider)
To create a rule for the position change event.
public static MarketRule<Position, Position> Changed(this Position position, IPositionProvider provider)
Parameters
position
PositionThe position to be traced for the change event.
provider
IPositionProviderThe position provider.
Returns
- MarketRule<Position, Position>
Rule.
Do<TToken>(MarketRule<TToken, ICandleMessage>, Action<Candle>)
Backward compatibility.
[Obsolete("Use ICandleMessage.")]
public static MarketRule<TToken, ICandleMessage> Do<TToken>(this MarketRule<TToken, ICandleMessage> rule, Action<Candle> action)
Parameters
rule
MarketRule<TToken, ICandleMessage>action
Action<Candle>
Returns
- MarketRule<TToken, ICandleMessage>
Type Parameters
TToken
Do<TToken, TResult>(MarketRule<TToken, ICandleMessage>, Func<Candle, TResult>)
Backward compatibility.
[Obsolete("Use ICandleMessage.")]
public static MarketRule<TToken, ICandleMessage> Do<TToken, TResult>(this MarketRule<TToken, ICandleMessage> rule, Func<Candle, TResult> action)
Parameters
rule
MarketRule<TToken, ICandleMessage>action
Func<Candle, TResult>
Returns
- MarketRule<TToken, ICandleMessage>
Type Parameters
TToken
TResult
Exclusive(IMarketRule, IMarketRule)
To make rules mutually exclusive.
public static void Exclusive(this IMarketRule rule1, IMarketRule rule2)
Parameters
rule1
IMarketRuleFirst rule.
rule2
IMarketRuleSecond rule.
Once<TRule>(TRule)
To make the rule one-time rule (will be called only once).
public static TRule Once<TRule>(this TRule rule) where TRule : IMarketRule
Parameters
rule
TRuleRule.
Returns
- TRule
Rule.
Type Parameters
TRule
The type of the rule.
Or(IMarketRule, params IMarketRule[])
To combine rules by OR condition.
public static IMarketRule Or(this IMarketRule rule, params IMarketRule[] rules)
Parameters
rule
IMarketRuleFirst rule.
rules
IMarketRule[]Additional rules.
Returns
- IMarketRule
Combined rule.
Or(IEnumerable<IMarketRule>)
To combine rules by OR condition.
public static IMarketRule Or(this IEnumerable<IMarketRule> rules)
Parameters
rules
IEnumerable<IMarketRule>Rules.
Returns
- IMarketRule
Combined rule.
Or<TToken, TArg>(MarketRule<TToken, TArg>, params MarketRule<TToken, TArg>[])
To combine rules by OR condition.
public static MarketRule<TToken, TArg> Or<TToken, TArg>(this MarketRule<TToken, TArg> rule, params MarketRule<TToken, TArg>[] rules)
Parameters
rule
MarketRule<TToken, TArg>First rule.
rules
MarketRule<TToken, TArg>[]Additional rules.
Returns
- MarketRule<TToken, TArg>
Combined rule.
Type Parameters
TToken
The type of token.
TArg
The type of argument, accepted by the rule.
SuspendRules(IMarketRuleContainer, Action)
To process rules in suspended mode (for example, create several rules and start them up simultaneously). After completion of method operation all rules, attached to the container resume their activity.
public static void SuspendRules(this IMarketRuleContainer container, Action action)
Parameters
container
IMarketRuleContainerThe rules container.
action
ActionThe action to be processed at suspended rules. For example, to add several rules simultaneously.
SuspendRules(Action)
To process rules in suspended mode (for example, create several rules and start them up simultaneously). After completion of method operation all rules, attached to the container resume their activity.
public static void SuspendRules(Action action)
Parameters
action
ActionThe action to be processed at suspended rules. For example, to add several rules simultaneously.
Suspend<TRule>(TRule, bool)
To suspend or resume the rule.
public static TRule Suspend<TRule>(this TRule rule, bool suspend) where TRule : IMarketRule
Parameters
Returns
- TRule
Rule.
Type Parameters
TRule
The type of the rule.
TryRemoveRule(IMarketRuleContainer, IMarketRule, bool)
To delete a rule. If a rule is executed at the time when this method is called, it will not be deleted.
public static bool TryRemoveRule(this IMarketRuleContainer container, IMarketRule rule, bool checkCanFinish = true)
Parameters
container
IMarketRuleContainerThe rules container.
rule
IMarketRuleRule.
checkCanFinish
boolTo check the possibility of rule suspension.
Returns
TryRemoveWithExclusive(IMarketRuleContainer, IMarketRule)
To delete the rule and all opposite rules. If the rule is executed at the time when this method is called, it will not be deleted.
public static bool TryRemoveWithExclusive(this IMarketRuleContainer container, IMarketRule rule)
Parameters
container
IMarketRuleContainerThe rules container.
rule
IMarketRuleRule.
Returns
UpdateLogLevel<TRule>(TRule, LogLevels)
To set the logging level.
public static TRule UpdateLogLevel<TRule>(this TRule rule, LogLevels level) where TRule : IMarketRule
Parameters
rule
TRuleRule.
level
LogLevelsThe level, on which logging is performed.
Returns
- TRule
Rule.
Type Parameters
TRule
The type of the rule.
UpdateName<TRule>(TRule, string)
To assign the rule a new name Name.
public static TRule UpdateName<TRule>(this TRule rule, string name) where TRule : IMarketRule
Parameters
rule
TRuleRule.
name
stringThe rule new name.
Returns
- TRule
Rule.
Type Parameters
TRule
The type of the rule.
WhenAllTrades(Order, ITransactionProvider)
To create a rule for the event of all trades occurrence for the order.
public static MarketRule<Order, IEnumerable<MyTrade>> WhenAllTrades(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for all trades occurrence event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, IEnumerable<MyTrade>>
Rule.
WhenBestAskPriceLess(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of the best offer decrease on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenBestAskPriceLess(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the event of the best offer decrease on a specific value.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenBestAskPriceLess(Security, IMarketDataProvider, Unit)
To create a rule for the event of dropping the best offer below the specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenBestAskPriceLess(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of dropping the best offer below the specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenBestAskPriceMore(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of the best offer increase on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenBestAskPriceMore(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the event of the best offer increase on a specific value.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenBestAskPriceMore(Security, IMarketDataProvider, Unit)
To create a rule for the event of excess of the best offer of the specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenBestAskPriceMore(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of excess of the best offer of the specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenBestBidPriceLess(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of the best bid decrease on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenBestBidPriceLess(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the event of the best bid decrease on a specific value.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenBestBidPriceLess(Security, IMarketDataProvider, Unit)
To create a rule for the event of dropping the best bid below the specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenBestBidPriceLess(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of dropping the best bid below the specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenBestBidPriceMore(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of the best bid increase on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenBestBidPriceMore(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the event of the best bid increase on a specific value.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenBestBidPriceMore(Security, IMarketDataProvider, Unit)
To create a rule for the event of excess of the best bid of specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenBestBidPriceMore(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of excess of the best bid of specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenCancelFailed(Order, ITransactionProvider)
To create a rule for the event of unsuccessful order cancelling on exchange.
public static MarketRule<Order, OrderFail> WhenCancelFailed(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for unsuccessful cancelling event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, OrderFail>
Rule.
WhenCanceled(Order, ITransactionProvider)
To create a rule for the order cancelling event.
public static MarketRule<Order, Order> WhenCanceled(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for cancelling event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenCandleReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of CandleReceived.
public static MarketRule<Subscription, ICandleMessage> WhenCandleReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, ICandleMessage>
Rule.
WhenCandleReceived<TCandle>(Subscription, ISubscriptionProvider)
To create a rule for the event of CandleReceived.
public static MarketRule<Subscription, TCandle> WhenCandleReceived<TCandle>(this Subscription subscription, ISubscriptionProvider provider) where TCandle : ICandleMessage
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenCandlesChanged(ISubscriptionProvider, CandleSeries)
[Obsolete("Use overrloding with Subscription arg type.")]
public static MarketRule<Subscription, Candle> WhenCandlesChanged(this ISubscriptionProvider subscriptionProvider, CandleSeries candleSeries)
Parameters
subscriptionProvider
ISubscriptionProvidercandleSeries
CandleSeries
Returns
WhenCandlesChanged(ISubscriptionProvider, Subscription)
To create a rule for candle change event.
public static MarketRule<Subscription, ICandleMessage> WhenCandlesChanged(this ISubscriptionProvider subscriptionProvider, Subscription subscription)
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for changed candles.
Returns
- MarketRule<Subscription, ICandleMessage>
Rule.
WhenCandlesChanged<TCandle>(ISubscriptionProvider, Subscription)
To create a rule for candle change event.
public static MarketRule<Subscription, TCandle> WhenCandlesChanged<TCandle>(this ISubscriptionProvider subscriptionProvider, Subscription subscription) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for changed candles.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenCandlesFinished(ISubscriptionProvider, CandleSeries)
[Obsolete("Use overrloding with Subscription arg type.")]
public static MarketRule<Subscription, Candle> WhenCandlesFinished(this ISubscriptionProvider subscriptionProvider, CandleSeries candleSeries)
Parameters
subscriptionProvider
ISubscriptionProvidercandleSeries
CandleSeries
Returns
WhenCandlesFinished(ISubscriptionProvider, Subscription)
To create a rule for candles end event.
public static MarketRule<Subscription, ICandleMessage> WhenCandlesFinished(this ISubscriptionProvider subscriptionProvider, Subscription subscription)
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for end of candle.
Returns
- MarketRule<Subscription, ICandleMessage>
Rule.
WhenCandlesFinished<TCandle>(ISubscriptionProvider, Subscription)
To create a rule for candles end event.
public static MarketRule<Subscription, TCandle> WhenCandlesFinished<TCandle>(this ISubscriptionProvider subscriptionProvider, Subscription subscription) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for end of candle.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenCandlesStarted(ISubscriptionProvider, CandleSeries)
[Obsolete("Use overrloding with Subscription arg type.")]
public static MarketRule<Subscription, Candle> WhenCandlesStarted(this ISubscriptionProvider subscriptionProvider, CandleSeries candleSeries)
Parameters
subscriptionProvider
ISubscriptionProvidercandleSeries
CandleSeries
Returns
WhenCandlesStarted(ISubscriptionProvider, Subscription)
To create a rule for the event of new candles occurrence.
public static MarketRule<Subscription, ICandleMessage> WhenCandlesStarted(this ISubscriptionProvider subscriptionProvider, Subscription subscription)
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for new candles.
Returns
- MarketRule<Subscription, ICandleMessage>
Rule.
WhenCandlesStarted<TCandle>(ISubscriptionProvider, Subscription)
To create a rule for the event of new candles occurrence.
public static MarketRule<Subscription, TCandle> WhenCandlesStarted<TCandle>(this ISubscriptionProvider subscriptionProvider, Subscription subscription) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for new candles.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenCandles<TCandle>(ISubscriptionProvider, Subscription)
To create a rule for the event of candles occurrence, change and end.
public static MarketRule<Subscription, TCandle> WhenCandles<TCandle>(this ISubscriptionProvider subscriptionProvider, Subscription subscription) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionCandles series to be traced for candles.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenChanged(MarketDepth, IMarketDataProvider)
To create a rule for the order book change event.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenChanged(this MarketDepth depth, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for change event.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenChanged(Order, ITransactionProvider)
To create a rule for the order change event.
public static MarketRule<Order, Order> WhenChanged(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for the change event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenChanged(Portfolio, IPortfolioProvider)
To create a rule for the event of change portfolio .
public static MarketRule<Portfolio, Portfolio> WhenChanged(this Portfolio portfolio, IPortfolioProvider provider)
Parameters
portfolio
PortfolioThe portfolio to be traced for the event of change.
provider
IPortfolioProviderThe provider of information about portfolios.
Returns
- MarketRule<Portfolio, Portfolio>
Rule.
WhenChanged(Security, IMarketDataProvider)
To create a rule for the instrument change event.
[Obsolete("Use WhenLevel1Received method.")]
public static MarketRule<Security, Security> WhenChanged(this Security security, IMarketDataProvider provider)
Parameters
security
SecurityThe instrument to be traced for changes.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Security, Security>
Rule.
WhenChanged<TCandle>(ISubscriptionProvider, TCandle)
To create a rule for candle change event.
public static MarketRule<TCandle, TCandle> WhenChanged<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for change.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle
WhenClosePriceLess<TCandle>(ISubscriptionProvider, TCandle, Unit)
To create a rule for the event of candle closing price reduction below a specific level.
public static MarketRule<TCandle, TCandle> WhenClosePriceLess<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle, Unit price) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for the event of candle closing price reduction below a specific level.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle
WhenClosePriceMore<TCandle>(ISubscriptionProvider, TCandle, Unit)
To create a rule for the event of candle closing price excess above a specific level.
public static MarketRule<TCandle, TCandle> WhenClosePriceMore<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle, Unit price) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for the event of candle closing price excess above a specific level.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle
WhenConnected(IConnector)
To create a rule for the event of connection established.
public static MarketRule<IConnector, IMessageAdapter> WhenConnected(this IConnector connector)
Parameters
connector
IConnectorThe connection to be traced for state.
Returns
- MarketRule<IConnector, IMessageAdapter>
Rule.
WhenConnectionLost(IConnector)
To create a rule for the event of connection lost.
public static MarketRule<IConnector, Tuple<IMessageAdapter, Exception>> WhenConnectionLost(this IConnector connector)
Parameters
connector
IConnectorThe connection to be traced for state.
Returns
- MarketRule<IConnector, Tuple<IMessageAdapter, Exception>>
Rule.
WhenDisconnected(IConnector)
To create a rule for the event of disconnection.
public static MarketRule<IConnector, IMessageAdapter> WhenDisconnected(this IConnector connector)
Parameters
connector
IConnectorThe connection to be traced for state.
Returns
- MarketRule<IConnector, IMessageAdapter>
Rule.
WhenEditFailed(Order, ITransactionProvider)
To create a rule for the order OrderEditFailed event.
public static MarketRule<Order, OrderFail> WhenEditFailed(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, OrderFail>
Rule.
WhenEdited(Order, ITransactionProvider)
To create a rule for the order OrderEdited event.
public static MarketRule<Order, Order> WhenEdited(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenFinished<TCandle>(ISubscriptionProvider, TCandle)
To create a rule for candle end event.
public static MarketRule<TCandle, TCandle> WhenFinished<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for end.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle
WhenIntervalElapsed(IConnector, TimeSpan)
To create a rule for the event MarketTimeChanged, activated after expiration of interval
.
public static MarketRule<IConnector, IConnector> WhenIntervalElapsed(this IConnector connector, TimeSpan interval)
Parameters
connector
IConnectorConnection to the trading system.
interval
TimeSpanInterval.
Returns
- MarketRule<IConnector, IConnector>
Rule.
WhenLastTradePriceLess(Security, IMarketDataProvider, Unit)
To create a rule for the event of reduction of the last trade price below the specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenLastTradePriceLess(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of reduction of the last trade price below the specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenLastTradePriceMore(Security, IMarketDataProvider, Unit)
To create a rule for the event of increase of the last trade price above the specific level.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Security> WhenLastTradePriceMore(this Security security, IMarketDataProvider provider, Unit price)
Parameters
security
SecurityThe instrument to be traced for the event of increase of the last trade price above the specific level.
provider
IMarketDataProviderThe market data provider.
price
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Security, Security>
Rule.
WhenLess(Position, IPositionProvider, Unit)
To create a rule for the event of position decrease below the specific level.
public static MarketRule<Position, Position> WhenLess(this Position position, IPositionProvider provider, Unit value)
Parameters
position
PositionThe position to be traced for the event of decrease below the specific level.
provider
IPositionProviderThe position provider.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Position, Position>
Rule.
WhenLevel1Received(Subscription, ISubscriptionProvider)
To create a rule for the event of Level1Received.
public static MarketRule<Subscription, Level1ChangeMessage> WhenLevel1Received(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
WhenLossMore(Order, Unit, IConnector)
To create a rule for the order's loss more on offset.
[Obsolete("Use WhenOrderChanged method.")]
public static MarketRule<Order, Order> WhenLossMore(this Order order, Unit profitOffset, IConnector connector)
Parameters
order
OrderThe order to be traced for loss.
profitOffset
UnitLoss offset.
connector
IConnectorConnection to the trading system.
Returns
- MarketRule<Order, Order>
Rule.
WhenLossMore(Order, Unit, ITransactionProvider, IMarketDataProvider)
To create a rule for the order's loss more on offset.
[Obsolete("Use WhenOrderChanged method.")]
public static MarketRule<Order, Order> WhenLossMore(this Order order, Unit profitOffset, ITransactionProvider transactionProvider, IMarketDataProvider marketDataProvider)
Parameters
order
OrderThe order to be traced for loss.
profitOffset
UnitLoss offset.
transactionProvider
ITransactionProviderThe transactional provider.
marketDataProvider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenMarketDepthChanged(BasketSecurity, IMarketDataProvider)
To create a rule for the event of order book change by instruments basket.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<Security, MarketDepth> WhenMarketDepthChanged(this BasketSecurity security, IMarketDataProvider provider)
Parameters
security
BasketSecurityInstruments basket to be traced for the event of order books change by internal instruments.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Security, MarketDepth>
Rule.
WhenMarketDepthChanged(Security, IMarketDataProvider)
To create a rule for the event of order book change by instrument.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<Security, MarketDepth> WhenMarketDepthChanged(this Security security, IMarketDataProvider provider)
Parameters
security
SecurityThe instrument to be traced for the event of order book change by instrument.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Security, MarketDepth>
Rule.
WhenMarketDepthReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of MarketDepthReceived.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<Subscription, MarketDepth> WhenMarketDepthReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, MarketDepth>
Rule.
WhenMatched(Order, ITransactionProvider)
To create a rule for the event of order fully matching.
public static MarketRule<Order, Order> WhenMatched(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for the fully matching event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenMoneyLess(Portfolio, IPortfolioProvider, Unit)
To create a rule for the event of money decrease in portfolio below the specific level.
public static MarketRule<Portfolio, Portfolio> WhenMoneyLess(this Portfolio portfolio, IPortfolioProvider provider, Unit money)
Parameters
portfolio
PortfolioThe portfolio to be traced for the event of money decrease below the specific level.
provider
IPortfolioProviderThe provider of information about portfolios.
money
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Portfolio, Portfolio>
Rule.
WhenMoneyMore(Portfolio, IPortfolioProvider, Unit)
To create a rule for the event of money increase in portfolio above the specific level.
public static MarketRule<Portfolio, Portfolio> WhenMoneyMore(this Portfolio portfolio, IPortfolioProvider provider, Unit money)
Parameters
portfolio
PortfolioThe portfolio to be traced for the event of money increase above the specific level.
provider
IPortfolioProviderThe provider of information about portfolios.
money
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Portfolio, Portfolio>
Rule.
WhenMore(Position, IPositionProvider, Unit)
To create a rule for the event of position increase above the specific level.
public static MarketRule<Position, Position> WhenMore(this Position position, IPositionProvider provider, Unit value)
Parameters
position
PositionThe position to be traced of the event of increase above the specific level.
provider
IPositionProviderThe position provider.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Position, Position>
Rule.
WhenNewMyTrade(ITransactionProvider)
To create a rule for the event of new trade occurrences.
public static MarketRule<ITransactionProvider, MyTrade> WhenNewMyTrade(this ITransactionProvider provider)
Parameters
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<ITransactionProvider, MyTrade>
Rule.
WhenNewOrder(ITransactionProvider)
To create a rule for the event of new orders occurrences.
public static MarketRule<ITransactionProvider, Order> WhenNewOrder(this ITransactionProvider provider)
Parameters
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<ITransactionProvider, Order>
Rule.
WhenNewOrderLogItem(Security, IMarketDataProvider)
To create a rule for the event of new notes occurrence in the orders log for instrument.
[Obsolete("Use WhenOrderLogReceived method.")]
public static MarketRule<Security, OrderLogItem> WhenNewOrderLogItem(this Security security, IMarketDataProvider provider)
Parameters
security
SecurityThe instrument to be traced for the event of new notes occurrence in the orders log.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Security, OrderLogItem>
Rule.
WhenNewTrade(Order, ITransactionProvider)
To create a rule for the event of trade occurrence for the order.
public static MarketRule<Order, MyTrade> WhenNewTrade(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for trades occurrence events.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, MyTrade>
Rule.
WhenNewTrade(Security, IMarketDataProvider)
To create a rule for the event of new trade occurrence for the instrument.
[Obsolete("Use WhenTickTradeReceived method.")]
public static MarketRule<Security, Trade> WhenNewTrade(this Security security, IMarketDataProvider provider)
Parameters
security
SecurityThe instrument to be traced for new trade occurrence event.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Security, Trade>
Rule.
WhenNewsReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of NewsReceived.
public static MarketRule<Subscription, News> WhenNewsReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, News>
Rule.
WhenOrderBookReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of OrderBookReceived.
public static MarketRule<Subscription, IOrderBookMessage> WhenOrderBookReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, IOrderBookMessage>
Rule.
WhenOrderEditFailReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of OrderEditFailReceived or OrderCancelFailReceived.
public static MarketRule<Subscription, OrderFail> WhenOrderEditFailReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, OrderFail>
Rule.
WhenOrderFailReceived(Subscription, ISubscriptionProvider, bool)
To create a rule for the event of OrderRegisterFailReceived or OrderCancelFailReceived.
public static MarketRule<Subscription, OrderFail> WhenOrderFailReceived(this Subscription subscription, ISubscriptionProvider provider, bool isRegister)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
isRegister
bool
Returns
- MarketRule<Subscription, OrderFail>
Rule.
WhenOrderLogReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of OrderLogItemReceived.
public static MarketRule<Subscription, IOrderLogMessage> WhenOrderLogReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, IOrderLogMessage>
Rule.
WhenOrderReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of OrderReceived.
public static MarketRule<Subscription, Order> WhenOrderReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Order>
Rule.
WhenOwnTradeReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of OwnTradeReceived.
public static MarketRule<Subscription, MyTrade> WhenOwnTradeReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, MyTrade>
Rule.
WhenPartiallyFinishedCandles<TCandle>(ISubscriptionProvider, Subscription, decimal)
To create a rule for the event of candle partial end.
public static MarketRule<Subscription, TCandle> WhenPartiallyFinishedCandles<TCandle>(this ISubscriptionProvider subscriptionProvider, Subscription subscription, decimal percent) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
subscription
SubscriptionThe candle series to be traced for candle partial end.
percent
decimalThe percentage of candle completion.
Returns
- MarketRule<Subscription, TCandle>
Rule.
Type Parameters
TCandle
WhenPartiallyFinished<TCandle>(ISubscriptionProvider, TCandle, decimal)
To create a rule for the event of candle partial end.
public static MarketRule<TCandle, TCandle> WhenPartiallyFinished<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle, decimal percent) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for partial end.
percent
decimalThe percentage of candle completion.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle
WhenPartiallyMatched(Order, ITransactionProvider)
To create a rule for the event of order partial matching.
public static MarketRule<Order, Order> WhenPartiallyMatched(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for partial matching event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenPositionReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of PositionReceived.
public static MarketRule<Subscription, Position> WhenPositionReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Position>
Rule.
WhenProfitMore(Order, Unit, IConnector)
To create a rule for the order's profit more on offset.
[Obsolete("Use WhenOrderChanged method.")]
public static MarketRule<Order, Order> WhenProfitMore(this Order order, Unit profitOffset, IConnector connector)
Parameters
order
OrderThe order to be traced for profit.
profitOffset
UnitProfit offset.
connector
IConnectorConnection to the trading system.
Returns
- MarketRule<Order, Order>
Rule.
WhenProfitMore(Order, Unit, ITransactionProvider, IMarketDataProvider)
To create a rule for the order's profit more on offset.
[Obsolete("Use WhenOrderChanged method.")]
public static MarketRule<Order, Order> WhenProfitMore(this Order order, Unit profitOffset, ITransactionProvider transactionProvider, IMarketDataProvider marketDataProvider)
Parameters
order
OrderThe order to be traced for profit.
profitOffset
UnitProfit offset.
transactionProvider
ITransactionProviderThe transactional provider.
marketDataProvider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenRegisterFailed(Order, ITransactionProvider)
To create a for the event of order unsuccessful registration on exchange.
public static MarketRule<Order, OrderFail> WhenRegisterFailed(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for unsuccessful registration event.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, OrderFail>
Rule.
WhenRegistered(Order, ITransactionProvider)
To create a rule for the event of successful order registration on exchange.
public static MarketRule<Order, Order> WhenRegistered(this Order order, ITransactionProvider provider)
Parameters
order
OrderThe order to be traced for the event of successful registration.
provider
ITransactionProviderThe transactional provider.
Returns
- MarketRule<Order, Order>
Rule.
WhenSpreadLess(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of order book spread size decrease on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenSpreadLess(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the spread change event.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenSpreadMore(MarketDepth, Unit, IMarketDataProvider)
To create a rule for the event of order book spread size increase on a specific value.
[Obsolete("Use WhenOrderBookReceived method.")]
public static MarketRule<MarketDepth, MarketDepth> WhenSpreadMore(this MarketDepth depth, Unit price, IMarketDataProvider provider)
Parameters
depth
MarketDepthThe order book to be traced for the spread change event.
price
UnitThe shift value.
provider
IMarketDataProviderThe market data provider.
Returns
- MarketRule<MarketDepth, MarketDepth>
Rule.
WhenSubscriptionFailed(Subscription, ISubscriptionProvider)
To create a rule for the event of SubscriptionFailed.
public static MarketRule<Subscription, Tuple<Subscription, Exception, bool>> WhenSubscriptionFailed(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Tuple<Subscription, Exception, bool>>
Rule.
WhenSubscriptionOnline(Subscription, ISubscriptionProvider)
To create a rule for the event of SubscriptionOnline.
public static MarketRule<Subscription, Subscription> WhenSubscriptionOnline(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Subscription>
Rule.
WhenSubscriptionStarted(Subscription, ISubscriptionProvider)
To create a rule for the event of SubscriptionStarted.
public static MarketRule<Subscription, Subscription> WhenSubscriptionStarted(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Subscription>
Rule.
WhenSubscriptionStopped(Subscription, ISubscriptionProvider)
To create a rule for the event of SubscriptionStopped.
public static MarketRule<Subscription, Tuple<Subscription, Exception>> WhenSubscriptionStopped(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, Tuple<Subscription, Exception>>
Rule.
WhenTickTradeReceived(Subscription, ISubscriptionProvider)
To create a rule for the event of TickTradeReceived.
public static MarketRule<Subscription, ITickTradeMessage> WhenTickTradeReceived(this Subscription subscription, ISubscriptionProvider provider)
Parameters
subscription
SubscriptionSubscription.
provider
ISubscriptionProviderSubscription provider.
Returns
- MarketRule<Subscription, ITickTradeMessage>
Rule.
WhenTimeCome(IConnector, IEnumerable<DateTimeOffset>)
To create a rule, activated at the exact time, specified through times
.
public static MarketRule<IConnector, DateTimeOffset> WhenTimeCome(this IConnector connector, IEnumerable<DateTimeOffset> times)
Parameters
connector
IConnectorConnection to the trading system.
times
IEnumerable<DateTimeOffset>The exact time. Several values may be sent.
Returns
- MarketRule<IConnector, DateTimeOffset>
Rule.
WhenTimeCome(IConnector, params DateTimeOffset[])
To create a rule, activated at the exact time, specified through times
.
public static MarketRule<IConnector, DateTimeOffset> WhenTimeCome(this IConnector connector, params DateTimeOffset[] times)
Parameters
connector
IConnectorConnection to the trading system.
times
DateTimeOffset[]The exact time. Several values may be sent.
Returns
- MarketRule<IConnector, DateTimeOffset>
Rule.
WhenTotalVolumeMore<TCandle>(ISubscriptionProvider, TCandle, Unit)
To create a rule for the event of candle total volume excess above a specific level.
public static MarketRule<TCandle, TCandle> WhenTotalVolumeMore<TCandle>(this ISubscriptionProvider subscriptionProvider, TCandle candle, Unit volume) where TCandle : ICandleMessage
Parameters
subscriptionProvider
ISubscriptionProviderThe subscription manager.
candle
TCandleThe candle to be traced for the event of candle total volume excess above a specific level.
volume
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<TCandle, TCandle>
Rule.
Type Parameters
TCandle