Class StrategyHelper
- Namespace
- StockSharp.Algo.Strategies
- Assembly
- StockSharp.Algo.dll
Extension class for Strategy.
public static class StrategyHelper
- Inheritance
-
StrategyHelper
- Inherited Members
Methods
BuyAtLimit(Strategy, decimal, decimal?)
To create the initialized order object for buy.
[Obsolete("Use Strategy.BuyLimit method.")]
public static Order BuyAtLimit(this Strategy strategy, decimal price, decimal? volume = null)
Parameters
strategy
StrategyStrategy.
price
decimalPrice.
volume
decimal?The volume. If null value is passed, then Volume value is used.
Returns
- Order
The initialized order object.
Remarks
The order is not registered, only the object is created.
BuyAtMarket(Strategy, decimal?)
To create initialized object of buy order at market price.
[Obsolete("Use Strategy.BuyMarket method.")]
public static Order BuyAtMarket(this Strategy strategy, decimal? volume = null)
Parameters
strategy
StrategyStrategy.
volume
decimal?The volume. If null value is passed, then Volume value is used.
Returns
- Order
The initialized order object.
Remarks
The order is not registered, only the object is created.
Cancel(IMarketRule, Order)
To create an action, cancelling the order.
public static IMarketRule Cancel(this IMarketRule rule, Order order)
Parameters
rule
IMarketRuleRule.
order
OrderThe order to be cancelled.
Returns
- IMarketRule
Rule.
GetIsEmulation(Strategy)
To get the strategy start-up mode (paper trading or real).
[Obsolete("Use Strategy.IsBacktesting property.")]
public static bool GetIsEmulation(this Strategy strategy)
Parameters
strategy
StrategyStrategy.
Returns
Protect(MarketRule<Order, MyTrade>, Unit, Unit)
To create the action protecting orders by strategies TakeProfitStrategy and StopLossStrategy.
[Obsolete("Use ProtectiveController class.")]
public static MarketRule<Order, MyTrade> Protect(this MarketRule<Order, MyTrade> rule, Unit takePriceDelta, Unit stopPriceDelta)
Parameters
rule
MarketRule<Order, MyTrade>The rule for new orders.
takePriceDelta
UnitThe delta from the price of the protected order, by which the protective take profit order is to be registered.
stopPriceDelta
UnitThe delta from the price of the protected order, by which the protective stop loss order is to be registered.
Returns
- MarketRule<Order, MyTrade>
Rule.
Protect(MarketRule<Order, MyTrade>, Func<MyTrade, TakeProfitStrategy>, Func<MyTrade, StopLossStrategy>)
To create the action protecting orders by strategies TakeProfitStrategy and StopLossStrategy.
[Obsolete("Use ProtectiveController class.")]
public static MarketRule<Order, MyTrade> Protect(this MarketRule<Order, MyTrade> rule, Func<MyTrade, TakeProfitStrategy> takeProfit, Func<MyTrade, StopLossStrategy> stopLoss)
Parameters
rule
MarketRule<Order, MyTrade>The rule for new orders.
takeProfit
Func<MyTrade, TakeProfitStrategy>The function that creates the strategy TakeProfitStrategy by the order.
stopLoss
Func<MyTrade, StopLossStrategy>The function that creates the strategy StopLossStrategy by the order.
Returns
- MarketRule<Order, MyTrade>
Rule.
ReRegister(IMarketRule, Order, Order)
To create an action, re-registering the order.
public static IMarketRule ReRegister(this IMarketRule rule, Order oldOrder, Order newOrder)
Parameters
rule
IMarketRuleRule.
oldOrder
OrderThe order to be re-registered.
newOrder
OrderInformation about new order.
Returns
- IMarketRule
Rule.
Register(IMarketRule, Order)
To create an action, registering the order.
public static IMarketRule Register(this IMarketRule rule, Order order)
Parameters
rule
IMarketRuleRule.
order
OrderThe order to be registered.
Returns
- IMarketRule
Rule.
SellAtLimit(Strategy, decimal, decimal?)
To create the initialized order object for sell.
[Obsolete("Use Strategy.SellLimit method.")]
public static Order SellAtLimit(this Strategy strategy, decimal price, decimal? volume = null)
Parameters
strategy
StrategyStrategy.
price
decimalPrice.
volume
decimal?The volume. If null value is passed, then Volume value is used.
Returns
- Order
The initialized order object.
Remarks
The order is not registered, only the object is created.
SellAtMarket(Strategy, decimal?)
To create the initialized order object of sell order at market price.
[Obsolete("Use Strategy.SellMarket method.")]
public static Order SellAtMarket(this Strategy strategy, decimal? volume = null)
Parameters
strategy
StrategyStrategy.
volume
decimal?The volume. If null value is passed, then Volume value is used.
Returns
- Order
The initialized order object.
Remarks
The order is not registered, only the object is created.
SetIsEmulation(Strategy, bool)
To set the strategy start-up mode (paper trading or real).
[Obsolete("Use Strategy.IsBacktesting property.")]
public static void SetIsEmulation(this Strategy strategy, bool isEmulation)
Parameters
strategy
StrategyStrategy.
isEmulation
boolIf the paper trading mode is used - true, otherwise - false.
WhenActivated(ProtectiveStrategy)
To create the rule for the event Activated.
[Obsolete("Use ProtectiveController class.")]
public static IMarketRule WhenActivated(this ProtectiveStrategy strategy)
Parameters
strategy
ProtectiveStrategyThe strategy, by which the event will be monitored.
Returns
- IMarketRule
Rule.
WhenError(Strategy, bool)
To create a rule for event of strategy error (transition of state ErrorState into Error).
public static MarketRule<Strategy, Exception> WhenError(this Strategy strategy, bool processChildStrategyErrors = false)
Parameters
strategy
StrategyThe strategy, based on which error will be expected.
processChildStrategyErrors
boolProcess the child strategies errors.
Returns
- MarketRule<Strategy, Exception>
Rule.
WhenNewMyTrade(Strategy)
To create a rule for the event of occurrence new strategy trade.
public static MarketRule<Strategy, MyTrade> WhenNewMyTrade(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which trade occurrence will be traced.
Returns
- MarketRule<Strategy, MyTrade>
Rule.
WhenOrderChanged(Strategy)
To create a rule for event of change of any strategy order.
public static MarketRule<Strategy, Order> WhenOrderChanged(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which orders change will be traced.
Returns
- MarketRule<Strategy, Order>
Rule.
WhenOrderRegistered(Strategy)
To create a rule for event of occurrence of new strategy order.
public static MarketRule<Strategy, Order> WhenOrderRegistered(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which order occurrence will be traced.
Returns
- MarketRule<Strategy, Order>
Rule.
WhenPnLChanged(Strategy)
To create a rule for event of profit change.
public static MarketRule<Strategy, decimal> WhenPnLChanged(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which the profit change will be traced.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenPnLLess(Strategy, Unit)
To create a rule for event of profit reduction below the specified level.
public static MarketRule<Strategy, decimal> WhenPnLLess(this Strategy strategy, Unit value)
Parameters
strategy
StrategyThe strategy, based on which the profit change will be traced.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenPnLMore(Strategy, Unit)
To create a rule for event of profit increase above the specified level.
public static MarketRule<Strategy, decimal> WhenPnLMore(this Strategy strategy, Unit value)
Parameters
strategy
StrategyThe strategy, based on which the profit change will be traced.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenPositionChanged(Strategy)
To create a rule for the event of strategy position change.
public static MarketRule<Strategy, decimal> WhenPositionChanged(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which position change will be traced.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenPositionLess(Strategy, Unit)
To create a rule for event of position event reduction below the specified level.
public static MarketRule<Strategy, decimal> WhenPositionLess(this Strategy strategy, Unit value)
Parameters
strategy
StrategyThe strategy, based on which position change will be traced.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenPositionMore(Strategy, Unit)
To create a rule for event of position event increase above the specified level.
public static MarketRule<Strategy, decimal> WhenPositionMore(this Strategy strategy, Unit value)
Parameters
strategy
StrategyThe strategy, based on which position change will be traced.
value
UnitThe level. If the Type type equals to Limit, specified price is set. Otherwise, shift value is specified.
Returns
- MarketRule<Strategy, decimal>
Rule.
WhenStarted(Strategy)
To create a rule for event of start of strategy operation.
public static MarketRule<Strategy, Strategy> WhenStarted(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which the start of strategy operation will be expected.
Returns
- MarketRule<Strategy, Strategy>
Rule.
WhenStopped(Strategy)
To create a rule for event full stop of strategy operation.
public static MarketRule<Strategy, Strategy> WhenStopped(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which the full stop will be expected.
Returns
- MarketRule<Strategy, Strategy>
Rule.
WhenStopping(Strategy)
To create a rule for event of beginning of the strategy operation stop.
public static MarketRule<Strategy, Strategy> WhenStopping(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which the beginning of stop will be determined.
Returns
- MarketRule<Strategy, Strategy>
Rule.
WhenWarning(Strategy)
To create a rule for event of strategy warning (transition of state ErrorState into Warning).
public static MarketRule<Strategy, Strategy> WhenWarning(this Strategy strategy)
Parameters
strategy
StrategyThe strategy, based on which the warning will be expected.
Returns
- MarketRule<Strategy, Strategy>
Rule.