Table of Contents

Class ProtectiveStrategy

Namespace
StockSharp.Algo.Strategies.Protective
Assembly
StockSharp.Algo.dll

The base strategy of the position protection.

[Obsolete("Use ProtectiveController class.")]
public abstract class ProtectiveStrategy : QuotingStrategy, IPersistable, INotifyPropertyChangedEx, INotifyPropertyChanged, IMarketRuleContainer, ILogReceiver, ILogSource, IDisposable, ICloneable<Strategy>, ICloneable, IMarketDataProvider, ISubscriptionProvider, ISecurityProvider, ISecurityMessageProvider, ITransactionProvider, IPositionProvider, IPortfolioProvider, IScheduledTask, IProtectiveStrategy
Inheritance
ProtectiveStrategy
Implements
IPersistable
INotifyPropertyChangedEx
ICloneable<Strategy>
Derived
Inherited Members
Extension Methods

Constructors

ProtectiveStrategy(Sides, decimal, decimal, Unit, bool)

Initialize ProtectiveStrategy.

protected ProtectiveStrategy(Sides protectiveSide, decimal protectivePrice, decimal protectiveVolume, Unit protectiveLevel, bool isUpTrend)

Parameters

protectiveSide Sides

Protected position side.

protectivePrice decimal

Protected position price.

protectiveVolume decimal

The protected position volume.

protectiveLevel Unit

The protective level. If the Type type is equal to Limit, then the given price is specified. Otherwise, the shift value from protectivePrice is specified.

isUpTrend bool

To track price increase or falling.

Properties

BestPriceOffset

The shift from the best price, on which the quoted order can be changed.

public Unit BestPriceOffset { get; set; }

Property Value

Unit

IsActivated

Whether the protective strategy is activated.

public bool IsActivated { get; }

Property Value

bool

IsTrailing

Whether to use a trailing technique. For the TakeProfitStrategy with profit increasing the level of profit taking is automatically increased. For the StopLossStrategy with profit increasing the level of loss protection is automatically increased. The default is disabled.

public bool IsTrailing { get; set; }

Property Value

bool

PriceOffset

The price shift for the registering order. It determines the amount of shift from the best quote (for the buy it is added to the price, for the sell it is subtracted).

public Unit PriceOffset { get; set; }

Property Value

Unit

ProtectiveLevel

The protective level. If the Type type is equal to Limit, then the given price is specified. Otherwise, the shift value from the protected trade Trade is specified.

public Unit ProtectiveLevel { get; set; }

Property Value

Unit

ProtectivePrice

Protected position price.

public decimal ProtectivePrice { get; }

Property Value

decimal

ProtectiveSide

Protected position side.

public Sides ProtectiveSide { get; }

Property Value

Sides

ProtectiveVolume

Protected volume.

public decimal ProtectiveVolume { get; set; }

Property Value

decimal

QuotingVolume

Total quoting volume.

public override decimal QuotingVolume { set; }

Property Value

decimal

UseMarketOrders

Whether to use Market for protection.

public bool UseMarketOrders { get; set; }

Property Value

bool

Remarks

By default, orders Limit are used.

UseQuoting

Whether to quote the registered order by the market price. The default mode is disabled.

public bool UseQuoting { get; set; }

Property Value

bool

Methods

CreateQuoting()

To create a quoting strategy for the protective order (its fulfilment is guaranteed).

protected virtual QuotingStrategy CreateQuoting()

Returns

QuotingStrategy

The strategy of quoting.

GetNotificationRules()

To get a list of rules on which the quoting will respond.

protected override IEnumerable<IMarketRule> GetNotificationRules()

Returns

IEnumerable<IMarketRule>

Rule list.

NeedQuoting(DateTimeOffset, decimal?, decimal?, decimal)

Should the order be quoted.

protected override decimal? NeedQuoting(DateTimeOffset currentTime, decimal? currentPrice, decimal? currentVolume, decimal newVolume)

Parameters

currentTime DateTimeOffset

Current time.

currentPrice decimal?

The current price. If the value is equal to null then the order is not registered yet.

currentVolume decimal?

The current volume. If the value is equal to null then the order is not registered yet.

newVolume decimal

New volume.

Returns

decimal?

The price at which the order will be registered. If the value is equal to null then the quoting is not required.

OnReseted()

It is called from the Reset() method.

protected override void OnReseted()

OnStarted(DateTimeOffset)

The method is called when the Start() method has been called and the ProcessState state has been taken the Started value.

protected override void OnStarted(DateTimeOffset time)

Parameters

time DateTimeOffset

ProcessQuoting(DateTimeOffset)

To initiate the quoting.

protected override void ProcessQuoting(DateTimeOffset currentTime)

Parameters

currentTime DateTimeOffset

Current time.

ProcessTimeOut(DateTimeOffset)

The TimeOut occurrence event handler.

protected override void ProcessTimeOut(DateTimeOffset currentTime)

Parameters

currentTime DateTimeOffset

RegisterQuotingOrder(Order)

To register the quoted order.

protected override void RegisterQuotingOrder(Order order)

Parameters

order Order

The quoted order.

Events

Activated

The protective strategy activation event.

public event Action Activated

Event Type

Action

ProtectiveVolumeChanged

The protected volume change event.

public event Action ProtectiveVolumeChanged

Event Type

Action