Class MarketRule<TToken, TArg>
- Namespace
- StockSharp.Algo
- Assembly
- StockSharp.Algo.dll
The rule, activating action at market condition occurrence.
public abstract class MarketRule<TToken, TArg> : Disposable, IMarketRule, IDisposable
Type Parameters
TToken
The type of token.
TArg
The type of accepted argument.
- Inheritance
-
MarketRule<TToken, TArg>
- Implements
- Extension Methods
Constructors
MarketRule(TToken)
Initialize MarketRule<TToken, TArg>.
protected MarketRule(TToken token)
Parameters
token
TTokenToken rules.
Properties
Container
The rules container.
public IMarketRuleContainer Container { get; set; }
Property Value
ExclusiveRules
Rules, opposite to given rule. They are deleted automatically at activation of this rule.
public virtual ISynchronizedCollection<IMarketRule> ExclusiveRules { get; }
Property Value
- ISynchronizedCollection<IMarketRule>
IsActive
Is the rule currently activated.
public bool IsActive { get; set; }
Property Value
IsReady
Is the rule formed.
public bool IsReady { get; }
Property Value
IsSuspended
Is the rule suspended.
public virtual bool IsSuspended { get; set; }
Property Value
LogLevel
The level to perform this rule logging.
public virtual LogLevels LogLevel { get; set; }
Property Value
Name
The name of the rule.
public string Name { get; set; }
Property Value
Methods
Activate()
To activate the rule.
protected void Activate()
Activate(TArg)
To activate the rule.
protected virtual void Activate(TArg arg)
Parameters
arg
TArgThe value, which will be sent to processor, registered through Do(Action<TArg>).
Activated(Action)
To add the processor, which will be called at action activation.
public MarketRule<TToken, TArg> Activated(Action handler)
Parameters
handler
ActionThe handler.
Returns
- MarketRule<TToken, TArg>
Rule.
Activated<TResult>(Action<TResult>)
To add the processor, accepting argument from Do<TResult>(Func<TResult>), which will be called at action activation.
public MarketRule<TToken, TArg> Activated<TResult>(Action<TResult> handler)
Parameters
handler
Action<TResult>The handler.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TResult
The type of result, returned from the processor.
CanFinish()
Can the rule be ended.
protected virtual bool CanFinish()
Returns
DisposeManaged()
Release resources.
protected override void DisposeManaged()
Do(Action)
To add the action, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do(Action action)
Parameters
action
ActionAction.
Returns
- MarketRule<TToken, TArg>
Rule.
Do(Action<MarketRule<TToken, TArg>, TArg>)
To add the action, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do(Action<MarketRule<TToken, TArg>, TArg> action)
Parameters
action
Action<MarketRule<TToken, TArg>, TArg>Action.
Returns
- MarketRule<TToken, TArg>
Rule.
Do(Action<TArg>)
To add the action, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do(Action<TArg> action)
Parameters
action
Action<TArg>Action.
Returns
- MarketRule<TToken, TArg>
Rule.
Do<TResult>(Func<MarketRule<TToken, TArg>, TArg, TResult>)
To add the action, returning result, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do<TResult>(Func<MarketRule<TToken, TArg>, TArg, TResult> action)
Parameters
action
Func<MarketRule<TToken, TArg>, TArg, TResult>The action, returning a result.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TResult
The type of returned result.
Do<TResult>(Func<TArg, TResult>)
To add the action, returning result, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do<TResult>(Func<TArg, TResult> action)
Parameters
action
Func<TArg, TResult>The action, returning a result.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TResult
The type of returned result.
Do<TResult>(Func<TResult>)
To add the action, returning result, activated at occurrence of condition.
public MarketRule<TToken, TArg> Do<TResult>(Func<TResult> action)
Parameters
action
Func<TResult>The action, returning a result.
Returns
- MarketRule<TToken, TArg>
Rule.
Type Parameters
TResult
The type of returned result.
ToString()
public override string ToString()
Returns
Until(Func<bool>)
To make the rule periodical (will be called until canFinish
returns true).
public MarketRule<TToken, TArg> Until(Func<bool> canFinish)
Parameters
Returns
- MarketRule<TToken, TArg>
Rule.