StrategyHelper
Extension class for Strategy.
Methods
public static IMarketRule Cancel(IMarketRule rule, Order order)
result = StrategyHelper.Cancel(rule, order)
To create an action, cancelling the order.
- rule
- Rule.
- order
- The order to be cancelled.
Returns: Rule.
public static ValueTask<ValueTuple<bool, Exception>> ExecAsync(Strategy strategy, Func<CancellationToken, ValueTask> extra, CancellationToken cancellationToken)
result = StrategyHelper.ExecAsync(strategy, extra, cancellationToken)
Execute strategy.
- strategy
- Strategy.
- extra
- Extra action.
- cancellationToken
- CancellationToken.
Returns: ValueTask.
public static IMarketRule Register(IMarketRule rule, Order order)
result = StrategyHelper.Register(rule, order)
To create an action, registering the order.
- rule
- Rule.
- order
- The order to be registered.
Returns: Rule.
public static IMarketRule ReRegister(IMarketRule rule, Order oldOrder, Order newOrder)
result = StrategyHelper.ReRegister(rule, oldOrder, newOrder)
To create an action, re-registering the order.
- rule
- Rule.
- oldOrder
- The order to be re-registered.
- newOrder
- Information about new order.
Returns: Rule.
public static MarketRule<Strategy, Exception> WhenError(Strategy strategy, bool processChildStrategyErrors)
result = StrategyHelper.WhenError(strategy, processChildStrategyErrors)
To create a rule for event of strategy error (transition of state ErrorState into Error).
- strategy
- The strategy, based on which error will be expected.
- processChildStrategyErrors
- Process the child strategies errors.
Returns: Rule.
public static MarketRule<Strategy, MyTrade> WhenNewMyTrade(Strategy strategy)
result = StrategyHelper.WhenNewMyTrade(strategy)
To create a rule for the event of occurrence new strategy trade.
- strategy
- The strategy, based on which trade occurrence will be traced.
Returns: Rule.
public static MarketRule<Strategy, Order> WhenOrderRegistered(Strategy strategy)
result = StrategyHelper.WhenOrderRegistered(strategy)
To create a rule for event of occurrence of new strategy order.
- strategy
- The strategy, based on which order occurrence will be traced.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPnLChanged(Strategy strategy)
result = StrategyHelper.WhenPnLChanged(strategy)
To create a rule for event of profit change.
- strategy
- The strategy, based on which the profit change will be traced.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPnLLess(Strategy strategy, Unit value)
result = StrategyHelper.WhenPnLLess(strategy, value)
To create a rule for event of profit reduction below the specified level.
- strategy
- The strategy, based on which the profit change will be traced.
- value
- The level. If the Type type equals to Absolute, specified price is set. Otherwise, shift value is specified.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPnLMore(Strategy strategy, Unit value)
result = StrategyHelper.WhenPnLMore(strategy, value)
To create a rule for event of profit increase above the specified level.
- strategy
- The strategy, based on which the profit change will be traced.
- value
- The level. If the Type type equals to Absolute, specified price is set. Otherwise, shift value is specified.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPositionChanged(Strategy strategy)
result = StrategyHelper.WhenPositionChanged(strategy)
To create a rule for the event of strategy position change.
- strategy
- The strategy, based on which position change will be traced.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPositionLess(Strategy strategy, Unit value)
result = StrategyHelper.WhenPositionLess(strategy, value)
To create a rule for event of position event reduction below the specified level.
- strategy
- The strategy, based on which position change will be traced.
- value
- The level. If the Type type equals to Absolute, specified price is set. Otherwise, shift value is specified.
Returns: Rule.
public static MarketRule<Strategy, decimal> WhenPositionMore(Strategy strategy, Unit value)
result = StrategyHelper.WhenPositionMore(strategy, value)
To create a rule for event of position event increase above the specified level.
- strategy
- The strategy, based on which position change will be traced.
- value
- The level. If the Type type equals to Absolute, specified price is set. Otherwise, shift value is specified.
Returns: Rule.
public static MarketRule<Strategy, Strategy> WhenStarted(Strategy strategy)
result = StrategyHelper.WhenStarted(strategy)
To create a rule for event of start of strategy operation.
- strategy
- The strategy, based on which the start of strategy operation will be expected.
Returns: Rule.
public static MarketRule<Strategy, Strategy> WhenStopped(Strategy strategy)
result = StrategyHelper.WhenStopped(strategy)
To create a rule for event full stop of strategy operation.
- strategy
- The strategy, based on which the full stop will be expected.
Returns: Rule.
public static MarketRule<Strategy, Strategy> WhenStopping(Strategy strategy)
result = StrategyHelper.WhenStopping(strategy)
To create a rule for event of beginning of the strategy operation stop.
- strategy
- The strategy, based on which the beginning of stop will be determined.
Returns: Rule.
public static MarketRule<Strategy, Strategy> WhenWarning(Strategy strategy)
result = StrategyHelper.WhenWarning(strategy)
To create a rule for event of strategy warning (transition of state ErrorState into Warning).
- strategy
- The strategy, based on which the warning will be expected.
Returns: Rule.