namespace StockSharp.MatchingEngine; /// /// Stop order information. /// public class StopOrderInfo { /// /// Transaction ID. /// public long TransactionId { get; set; } /// /// Security ID. /// public SecurityId SecurityId { get; set; } /// /// Order side. /// public Sides Side { get; set; } /// /// Order volume. /// public decimal Volume { get; set; } /// /// Portfolio name. /// public string PortfolioName { get; set; } /// /// Stop activation price. /// public decimal StopPrice { get; set; } /// /// Limit price for stop-limit orders. means market order. /// public decimal? LimitPrice { get; set; } /// /// Whether this is a trailing stop. /// public bool IsTrailing { get; set; } /// /// Trailing offset from extremum. /// public decimal? TrailingOffset { get; set; } /// /// Best seen price for trailing stop (max for sell, min for buy). /// public decimal? BestSeenPrice { get; set; } /// /// When , trigger logic is inverted (TakeProfit mode): /// Buy triggers when price <= StopPrice, Sell triggers when price >= StopPrice. /// public bool InvertTrigger { get; set; } /// /// When , is a percent of ; /// the absolute limit price is computed at trigger time /// (Buy: stop*(1+pct/100), Sell: stop*(1-pct/100)). /// public bool IsLimitPricePercent { get; set; } /// /// When , is a percent of the /// high/low watermark; the stop price is recomputed on each tick as /// Sell: high*(1-pct/100), Buy: low*(1+pct/100). /// public bool IsTrailingOffsetPercent { get; set; } } /// /// Triggered stop order result. /// /// Stop order info. /// The price that triggered the stop. /// The order to submit to the matcher. public record StopOrderTrigger(StopOrderInfo Info, decimal TriggerPrice, OrderRegisterMessage ResultingOrder); /// /// Interface for managing stop orders. /// public interface IStopOrderManager { /// /// Register a new stop order. /// void Register(StopOrderInfo info); /// /// Cancel a stop order. /// /// Transaction ID of the stop order. /// Cancelled stop order info. /// if the stop order was found and cancelled. bool Cancel(long transactionId, out StopOrderInfo info); /// /// Atomically replace an existing stop order with a new one. /// /// Transaction ID of the stop order to replace. /// New stop order info. /// if the old stop order was found and replaced. bool Replace(long origTransactionId, StopOrderInfo newInfo); /// /// Check price against all registered stop orders for the given security. /// /// Security ID. /// Current market price. /// Current time. /// List of triggered stop orders with resulting orders to submit. IReadOnlyList CheckPrice(SecurityId securityId, decimal price, DateTime time); /// /// Get the stop orders resting on the given security. /// /// Security ID. /// Transaction IDs of the stop orders registered for the security, empty when none rest on it. IReadOnlyList GetStopIds(SecurityId securityId); /// /// Clear all stop orders. /// void Clear(); }