StrategyHelper

StockSharp.Algo.Strategies

Класс расширения для стратегии.

Методы

Cancel
public static IMarketRule Cancel(IMarketRule rule, Order order)
result = StrategyHelper.Cancel(rule, order)

Создать действие по отмене заказа.

rule
Правило.
order
Заказ, подлежащий отмене.

Возвращает: Правило.

Compile
public static Func<Strategy, decimal> Compile(IFitnessFormulaProvider provider, string formula)
result = StrategyHelper.Compile(provider, formula)

Compile a fitness formula string into an evaluation function.

provider
IFitnessFormulaProvider
formula
The formula string (e.g., "PnL", "PnL * SharpeRatio").

Возвращает: A function that evaluates a strategy and returns a fitness value.

ExecAsync
public static ValueTask<ValueTuple<bool, Exception>> ExecAsync(Strategy strategy, Func<CancellationToken, ValueTask> extra, CancellationToken cancellationToken)
result = StrategyHelper.ExecAsync(strategy, extra, cancellationToken)

Реализуйте стратегию.

strategy
Стратегия.
extra
Дополнительное действие.
cancellationToken
CancellationToken.

Возвращает: ValueTask.

Register
public static IMarketRule Register(IMarketRule rule, Order order)
result = StrategyHelper.Register(rule, order)

Создать действие, зарегистрировав заказ.

rule
Правило.
order
Заказ на регистрацию.

Возвращает: Правило.

ReRegister
public static IMarketRule ReRegister(IMarketRule rule, Order oldOrder, Order newOrder)
result = StrategyHelper.ReRegister(rule, oldOrder, newOrder)

Для создания действия перерегистрируем заказ.

rule
Правило.
oldOrder
Приказ о перерегистрации.
newOrder
Информация о новом заказе.

Возвращает: Правило.

ReversalVolume
public static decimal ReversalVolume(Strategy strategy)
result = StrategyHelper.ReversalVolume(strategy)

The volume that leaves the strategy holding Volume on the other side of zero.

strategy
The strategy that is reversing.

Возвращает: Volume to trade, never more than twice Volume.

StopIfNoMarketDataAsync
public static ValueTask<bool> StopIfNoMarketDataAsync(Strategy strategy, CancellationToken cancellationToken)
result = StrategyHelper.StopIfNoMarketDataAsync(strategy, cancellationToken)

Stop a started strategy that has no market data to run on, with an error that says so: it asked for none, or all it asked for was refused. A run over history replays only the market data subscribed and would wait forever for such a strategy. Called once the strategy has started, when it has asked for its data.

strategy
Strategy.
cancellationToken
CancellationToken.

Возвращает: if the strategy was stopped.

WhenError
public static MarketRule<IStrategy, Exception> WhenError(IStrategy 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.

Возвращает: Rule.

WhenNewMyTrade
public static MarketRule<IStrategy, MyTrade> WhenNewMyTrade(IStrategy 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.

Возвращает: Rule.

WhenOrderRegistered
public static MarketRule<IStrategy, Order> WhenOrderRegistered(IStrategy 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.

Возвращает: Rule.

WhenPnLChanged
public static MarketRule<IStrategy, decimal> WhenPnLChanged(IStrategy 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.

Возвращает: Rule.

WhenPnLLess
public static MarketRule<IStrategy, decimal> WhenPnLLess(IStrategy 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.

Возвращает: Rule.

WhenPnLMore
public static MarketRule<IStrategy, decimal> WhenPnLMore(IStrategy 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.

Возвращает: Rule.

WhenPositionChanged
public static MarketRule<IStrategy, decimal> WhenPositionChanged(IStrategy 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.

Возвращает: Rule.

WhenPositionLess
public static MarketRule<IStrategy, decimal> WhenPositionLess(IStrategy 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.

Возвращает: Rule.

WhenPositionMore
public static MarketRule<IStrategy, decimal> WhenPositionMore(IStrategy 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.

Возвращает: Rule.

WhenStarted
public static MarketRule<IStrategy, IStrategy> WhenStarted(IStrategy 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.

Возвращает: Rule.

WhenStopped
public static MarketRule<IStrategy, IStrategy> WhenStopped(IStrategy 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.

Возвращает: Rule.

WhenStopping
public static MarketRule<IStrategy, IStrategy> WhenStopping(IStrategy 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.

Возвращает: Rule.

WhenWarning
public static MarketRule<IStrategy, IStrategy> WhenWarning(IStrategy 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.

Возвращает: Rule.