static public OrderSide ToOrderSide(MetaOperationType mot) { switch (mot) { case MetaOperationType.OP_BUY: case MetaOperationType.OP_BUYLIMIT: case MetaOperationType.OP_BUYSTOP: return(OrderSide.Buy); default: return(OrderSide.Sell); } }
static public OrderType ToOrderType(MetaOperationType mot) { switch (mot) { case MetaOperationType.OP_BUY: case MetaOperationType.OP_SELL: return(OrderType.Market); case MetaOperationType.OP_BUYLIMIT: case MetaOperationType.OP_SELLLIMIT: return(OrderType.Limit); default: return(OrderType.Stop); } }
virtual public MetaOperationType GetOrderType() { if (IsInverted) { AsyncCommand aCmd = new AsyncCommand(Commands.OrderType); ExecuteCommand(aCmd); MetaOperationType mtp = (MetaOperationType)aCmd.Result; switch (mtp) { case MetaOperationType.OP_BUY: return(MetaOperationType.OP_SELL); case MetaOperationType.OP_SELL: return(MetaOperationType.OP_BUY); case MetaOperationType.OP_BUYLIMIT: return(MetaOperationType.OP_SELLSTOP); case MetaOperationType.OP_SELLLIMIT: return(MetaOperationType.OP_BUYSTOP); case MetaOperationType.OP_BUYSTOP: return(MetaOperationType.OP_SELLLIMIT); case MetaOperationType.OP_SELLSTOP: return(MetaOperationType.OP_BUYLIMIT); default: throw new ApplicationException("Unknown order type:" + mtp.ToString()); } } else { AsyncCommand aCmd = new AsyncCommand(Commands.OrderType); ExecuteCommand(aCmd); return((MetaOperationType)aCmd.Result); } }
internal Order(int orderID, string symbol, MetaOperationType mot, int openprice, int volume, int SL, int TP, string comment) : this(orderID, symbol, MetaTypeConvertor.ToOrderType(mot), openprice, MetaTypeConvertor.ToOrderSide(mot), volume, SL, TP, comment) { }