Class ProtectiveStrategy
The base strategy of the position protection.
Inheritance
Implements
Inherited Members
Namespace: StockSharp.Algo.Strategies.Protective
Assembly: StockSharp.Algo.Strategies.dll
Syntax
public abstract class ProtectiveStrategy : QuotingStrategy, IPersistable, INotifyPropertyChangedEx, INotifyPropertyChanged, IMarketRuleContainer, ILogReceiver, ILogSource, ICloneable<Strategy>, ICloneable, IMarketDataProvider, ISubscriptionProvider, ISecurityProvider, ICandleManager, ICandleSource<Candle>, IDisposable, ITransactionProvider, IPositionProvider, IPortfolioProvider, IScheduledTask, IProtectiveStrategy
Constructors
ProtectiveStrategy(Sides, Decimal, Decimal, Unit, Boolean)
Initialize ProtectiveStrategy.
Declaration
protected ProtectiveStrategy(Sides protectiveSide, Decimal protectivePrice, Decimal protectiveVolume, Unit protectiveLevel, bool isUpTrend)
Parameters
Type | Name | Description |
---|---|---|
Sides | protectiveSide | Protected position side. |
Decimal | protectivePrice | Protected position price. |
Decimal | protectiveVolume | The protected position volume. |
Unit | protectiveLevel | The protective level. If the Type type is equal to Limit, then the given price is specified. Otherwise, the shift value from |
Boolean | isUpTrend | To track price increase or falling. |
Properties
ActivationPrice
The absolute value of the price when the one is reached the protective strategy is activated.
Declaration
public virtual Nullable<Decimal> ActivationPrice { get; }
Property Value
Type | Description |
---|---|
Nullable<Decimal> |
Remarks
If the price is equal to null then the activation is not required.
BestPriceOffset
The shift from the best price, on which the quoted order can be changed.
Declaration
public Unit BestPriceOffset { get; set; }
Property Value
Type | Description |
---|---|
Unit |
ClosePositionPrice
The market price of position closing. If there is no information about the current price, then the null will be returned.
Declaration
protected virtual Nullable<Decimal> ClosePositionPrice { get; }
Property Value
Type | Description |
---|---|
Nullable<Decimal> |
IsActivated
Whether the protective strategy is activated.
Declaration
public bool IsActivated { get; }
Property Value
Type | Description |
---|---|
Boolean |
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.
Declaration
public bool IsTrailing { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
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).
Declaration
public Unit PriceOffset { get; set; }
Property Value
Type | Description |
---|---|
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.
Declaration
public Unit ProtectiveLevel { get; set; }
Property Value
Type | Description |
---|---|
Unit |
ProtectivePrice
Protected position price.
Declaration
public Decimal ProtectivePrice { get; }
Property Value
Type | Description |
---|---|
Decimal |
ProtectiveSide
Protected position side.
Declaration
public Sides ProtectiveSide { get; }
Property Value
Type | Description |
---|---|
Sides |
ProtectiveVolume
Protected volume.
Declaration
public Decimal ProtectiveVolume { get; set; }
Property Value
Type | Description |
---|---|
Decimal |
QuotingVolume
Total quoting volume.
Declaration
public override Decimal QuotingVolume { set; }
Property Value
Type | Description |
---|---|
Decimal |
Overrides
UseMarketOrders
Declaration
public bool UseMarketOrders { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
UseQuoting
Whether to quote the registered order by the market price. The default mode is disabled.
Declaration
public bool UseQuoting { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
CreateQuoting()
To create a quoting strategy for the protective order (its fulfilment is guaranteed).
Declaration
protected virtual QuotingStrategy CreateQuoting()
Returns
Type | Description |
---|---|
QuotingStrategy | The strategy of quoting. |
GetNotificationRules()
To get a list of rules on which the quoting will respond.
Declaration
protected override IEnumerable<IMarketRule> GetNotificationRules()
Returns
Type | Description |
---|---|
IEnumerable<IMarketRule> | Rule list. |
Overrides
NeedQuoting(Nullable<Decimal>, Nullable<Decimal>, Decimal)
Should the order be quoted.
Declaration
protected override Nullable<Decimal> NeedQuoting(Nullable<Decimal> currentPrice, Nullable<Decimal> currentVolume, Decimal newVolume)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Decimal> | currentPrice | The current price. If the value is equal to null then the order is not registered yet. |
Nullable<Decimal> | currentVolume | The current volume. If the value is equal to null then the order is not registered yet. |
Decimal | newVolume | New volume. |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The price at which the order will be registered. If the value is equal to null then the quoting is not required. |
Overrides
OnReseted()
It is called from the Reset() method.
Declaration
protected override void OnReseted()
Overrides
OnStarted()
The method is called when the Start() method has been called and the ProcessState state has been taken the Started value.
Declaration
protected override void OnStarted()
Overrides
ProcessQuoting()
To initiate the quoting.
Declaration
protected override void ProcessQuoting()
Overrides
ProcessTimeOut()
The TimeOut occurrence event handler.
Declaration
protected override void ProcessTimeOut()
Overrides
RegisterQuotingOrder(Order)
To register the quoted order.
Declaration
protected override void RegisterQuotingOrder(Order order)
Parameters
Type | Name | Description |
---|---|---|
Order | order | The quoted order. |
Overrides
Events
Activated
The protective strategy activation event.
Declaration
public event Action Activated
Event Type
Type | Description |
---|---|
Action |
ProtectiveVolumeChanged
The protected volume change event.
Declaration
public event Action ProtectiveVolumeChanged
Event Type
Type | Description |
---|---|
Action |