mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-04 00:21:31 +00:00
Add IPercentStopOrderCondition with three flags (IsActivationPricePercent, IsClosePositionPricePercent, IsTrailingOffsetPercent) and carry them through StopOrderCondition / StopOrderInfo. StopOrderManager: - percent limit price: resolved at trigger time against the actual activated stop price (Buy: stop*(1+pct/100), Sell: stop*(1-pct/100)) - percent trailing offset: stop price recomputed each tick from the high/low watermark (Sell: high*(1-pct/100), Buy: low*(1+pct/100)) Percent activation is resolved by the caller (server side) because it requires a market-price snapshot that the matcher does not track.
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
namespace StockSharp.MatchingEngine;
|
|
|
|
/// <summary>
|
|
/// Stop order condition for matching engine.
|
|
/// </summary>
|
|
[System.Runtime.Serialization.DataContract]
|
|
[Serializable]
|
|
public class StopOrderCondition : OrderCondition, IStopLossOrderCondition, IPercentStopOrderCondition
|
|
{
|
|
/// <summary>
|
|
/// Stop activation price.
|
|
/// </summary>
|
|
public decimal? ActivationPrice
|
|
{
|
|
get => (decimal?)Parameters.TryGetValue(nameof(ActivationPrice));
|
|
set => Parameters[nameof(ActivationPrice)] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Close position price. <see langword="null"/> means close by market.
|
|
/// </summary>
|
|
public decimal? ClosePositionPrice
|
|
{
|
|
get => (decimal?)Parameters.TryGetValue(nameof(ClosePositionPrice));
|
|
set => Parameters[nameof(ClosePositionPrice)] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Trailing stop flag.
|
|
/// </summary>
|
|
public bool IsTrailing
|
|
{
|
|
get => Parameters.TryGetValue(nameof(IsTrailing)) is true;
|
|
set => Parameters[nameof(IsTrailing)] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Trailing stop offset from extremum.
|
|
/// </summary>
|
|
public decimal? TrailingOffset
|
|
{
|
|
get => (decimal?)Parameters.TryGetValue(nameof(TrailingOffset));
|
|
set => Parameters[nameof(TrailingOffset)] = value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool IsActivationPricePercent
|
|
{
|
|
get => Parameters.TryGetValue(nameof(IsActivationPricePercent)) is true;
|
|
set => Parameters[nameof(IsActivationPricePercent)] = value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool IsClosePositionPricePercent
|
|
{
|
|
get => Parameters.TryGetValue(nameof(IsClosePositionPricePercent)) is true;
|
|
set => Parameters[nameof(IsClosePositionPricePercent)] = value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool IsTrailingOffsetPercent
|
|
{
|
|
get => Parameters.TryGetValue(nameof(IsTrailingOffsetPercent)) is true;
|
|
set => Parameters[nameof(IsTrailingOffsetPercent)] = value;
|
|
}
|
|
}
|