public void RemoveOrder(string orderId, int cookie) { /* int buyIndex = BuyOrders.FindIndex(order => (order.OrderId == orderId)); * int sellIndex = SellOrders.FindIndex(order => (order.OrderId == orderId)); * if (buyIndex >= 0) * BuyOrders.RemoveAt(buyIndex); * else if (sellIndex >= 0) * SellOrders.RemoveAt(sellIndex); * else * { * buyIndex = BuyOrders.FindIndex(order => (order.Cookie == cookie)); * sellIndex = SellOrders.FindIndex(order => (order.Cookie == cookie)); * if (buyIndex >= 0) * BuyOrders.RemoveAt(buyIndex); * else if (sellIndex >= 0) * SellOrders.RemoveAt(sellIndex); * } */ Order foundOrder = FindOrder(orderId, cookie); if (foundOrder != null) { if (foundOrder.Action == ActionEnum.BUY) { BuyOrders.Remove(foundOrder); } else if (foundOrder.Action == ActionEnum.SELL) { SellOrders.Remove(foundOrder); } else { throw new SmartException(ExceptionImportanceLevel.LOW, "RemoveOrder", "StrategyState", "No other choices in foundOrder.Action"); } } }
public void RemoveOrder(ILimitOrder order) { switch (order.Way) { case WayEnum.Buy: BuyOrders.Remove(order); break; case WayEnum.Sell: SellOrders.Remove(order); break; } order.UnRegisterDeleteNotificationHandler(HandleDeleteOrFilled); order.UnRegisterFilledNotification(HandleDeleteOrFilled); }