public static string ToString(TradeOp value) { switch (value) { case TradeOp.Buy: return("Покупка"); case TradeOp.Sell: return("Продажа"); case TradeOp.Upsize: return("Наращивание"); case TradeOp.Close: return("Закрытие"); case TradeOp.Pause: return("Пауза"); case TradeOp.Wait: return("Ожидание"); case TradeOp.Kill: return("Снятие"); case TradeOp.Cancel: return("Отмена"); } return(value.ToString()); }
public static string ToString(TradeOp value) { switch (value) { case TradeOp.Buy: return("Покупка"); case TradeOp.Sell: return("Продажа"); case TradeOp.Upsize: return("Наращивание"); case TradeOp.Downsize: return("Уменьшение"); case TradeOp.Close: return("Закрытие"); case TradeOp.Reverse: return("Разворот"); case TradeOp.Cancel: return("Отмена"); } return(value.ToString()); }
public KeyBinding(Key key, bool onKeyDown, TradeOp operation, BaseQuote quote, double value, int quantity) { this.Key = key; this.OnKeyDown = onKeyDown; this.Action = new OwnAction(operation, quote, value, quantity); }
public OwnAction(TradeOp operation, BaseQuote quote, double value, int quantity) { this.Operation = operation; this.Quote = quote; this.Value = value; this.Quantity = quantity; }
public OwnAction(TradeOp operation, BaseQuote quote = BaseQuote.None, int value = 0, QtyType qtyType = QtyType.None, int quantity = 0, bool isStop = false, int slippage = 0, int trailStart = 0, int trailOffset = 0) { this.Operation = operation; this.Quote = quote; this.Value = value; this.QtyType = qtyType; this.Quantity = quantity; this.IsStop = isStop; this.Slippage = slippage; this.TrailStart = trailStart; this.TrailOffset = trailOffset; }
// -------------------------------------------------------------- public void ReadXml(XmlReader reader) { List <OwnAction> actions = new List <OwnAction>(); if (!reader.IsEmptyElement) { while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) { if (reader.NodeType == XmlNodeType.Element && reader.Name == cnBinding) { Key key = (Key)Enum.Parse(typeof(Key), reader.GetAttribute(cnKey)); actions.Clear(); if (!reader.IsEmptyElement) { while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) { if (reader.IsEmptyElement) { TradeOp op = (TradeOp)Enum.Parse(typeof(TradeOp), reader.Name); BaseQuote quote = BaseQuote.None; int value = 0; QtyType qtyType = QtyType.None; int quantity = 0; bool isStop = false; int slippage = 0; int trailStart = 0; int trailOffset = 0; if (reader.MoveToAttribute(cnQuote)) { quote = (BaseQuote)Enum.Parse(typeof(BaseQuote), reader.ReadContentAsString()); } if (reader.MoveToAttribute(cnValue)) { value = reader.ReadContentAsInt(); } if (reader.MoveToAttribute(cnQtyType)) { qtyType = (QtyType)Enum.Parse(typeof(QtyType), reader.ReadContentAsString()); } if (reader.MoveToAttribute(cnQuantity)) { quantity = reader.ReadContentAsInt(); } if (reader.MoveToAttribute(cnSlippage)) { isStop = true; slippage = reader.ReadContentAsInt(); if (reader.MoveToAttribute(cnTrailStart)) { trailStart = reader.ReadContentAsInt(); } if (reader.MoveToAttribute(cnTrailOffset)) { trailOffset = reader.ReadContentAsInt(); } } // ========== конвертация с версии 3.5 ========== if (qtyType == QtyType.None) { switch (op) { case TradeOp.Close: qtyType = QtyType.Position; quantity = 100; break; case TradeOp.Downsize: op = TradeOp.Close; break; case TradeOp.Reverse: op = TradeOp.Close; qtyType = QtyType.Position; quantity = 200; break; } if (quantity < 0) { qtyType = QtyType.WorkSize; quantity = -quantity; } } // ============================================== actions.Add(new OwnAction(op, quote, value, qtyType, quantity, isStop, slippage, trailStart, trailOffset)); } else { throw new FormatException(); } } } this.Add(key, actions.ToArray()); } else { throw new FormatException(); } } } reader.Read(); }
public TradeOpItem(TradeOp value) { this.Value = value; }