namespace StockSharp.Fix; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; /// /// The stop orders types that are specific for . /// [Serializable] [DataContract] public enum FixStopOrderTypes { /// /// Stop-loss. /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.StopLossKey)] [EnumMember] StopLoss, /// /// Trailing stop-loss. /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.TrailingStopLossKey)] [EnumMember] StopLossTrailing, /// /// Take. /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.TakeProfitKey)] [EnumMember] TakeProfit, /// /// Trailing take-profit. /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.TrailingTakeProfitKey)] [EnumMember] TakeProfitTrailing, /// /// Market on close (pit). /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.MarketOnPitCloseKey)] [EnumMember] MarketOnClose, /// /// With the market price when the condition is fulfilled. /// [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.MarketOnTouchKey)] [EnumMember] MarketIfTouched, } /// /// order condition. /// [Serializable] [DataContract] [Display(ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.FIXKey)] public class FixOrderCondition : OrderCondition, IStopLossOrderCondition, ITakeProfitOrderCondition { /// /// Initializes a new instance of the . /// public FixOrderCondition() { Type = FixStopOrderTypes.StopLoss; } /// /// Stop-order type. /// [DataMember] [Display( ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.TypeKey, Description = LocalizedStrings.StopOrderTypeDescKey, GroupName = LocalizedStrings.ParametersKey, Order = 0)] public FixStopOrderTypes? Type { get => (FixStopOrderTypes?)Parameters.TryGetValue(nameof(Type)); set => Parameters[nameof(Type)] = value; } /// /// Stop-loss. /// [DataMember] [Display( ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.StopLossKey, Description = LocalizedStrings.StopLossActivationPriceKey, GroupName = LocalizedStrings.ParametersKey, Order = 1)] public decimal? StopLoss { get => (decimal?)Parameters.TryGetValue(nameof(StopLoss)); set => Parameters[nameof(StopLoss)] = value; } /// /// Take-profit. /// [DataMember] [Display( ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.TakeProfitKey, Description = LocalizedStrings.TakeProfitDescKey, GroupName = LocalizedStrings.ParametersKey, Order = 1)] public decimal? TakeProfit { get => (decimal?)Parameters.TryGetValue(nameof(TakeProfit)); set => Parameters[nameof(TakeProfit)] = value; } /// /// Offset. /// [DataMember] [Display( ResourceType = typeof(LocalizedStrings), Name = LocalizedStrings.PriceOffsetKey, Description = LocalizedStrings.PriceOffsetForOrderKey, GroupName = LocalizedStrings.ParametersKey, Order = 2)] public decimal? Offset { get => (decimal?)Parameters.TryGetValue(nameof(Offset)); set => Parameters[nameof(Offset)] = value; } decimal? IStopLossOrderCondition.ClosePositionPrice { get => null; set { } } decimal? ITakeProfitOrderCondition.ActivationPrice { get => TakeProfit; set => TakeProfit = value; } decimal? ITakeProfitOrderCondition.ClosePositionPrice { get => null; set { } } decimal? IStopLossOrderCondition.ActivationPrice { get => StopLoss; set => StopLoss = value; } bool IStopLossOrderCondition.IsTrailing { get => Type == FixStopOrderTypes.StopLossTrailing; set => Type = value ? FixStopOrderTypes.StopLossTrailing : FixStopOrderTypes.StopLoss; } }