private void ProcessCancelOrder(string id) { if (_cancelPending.Contains(id)) { return; } if (!_orders.TryGetById(id, out var order)) { return; } if (string.IsNullOrEmpty(order.OrderID)) { _cancelPending.Add(id); return; } var action = new CtpInputOrderAction(); action.OrderSysID = order.OrderID; action.ExchangeID = order.ExchangeID.ToUpper(); action.InstrumentID = order.InstrumentID; action.ActionFlag = CtpActionFlagType.Delete; action.OrderActionRef = _client.GetNextRequestId(); action.InvestorID = _client.ctpLoginInfo.UserID; action.BrokerID = _client.ctpLoginInfo.BrokerID; _client.api.ReqOrderAction(action, _client.GetNextRequestId()); }
private void ProcessRtnOrder(CtpOrder data) { var id = CtpConvert.GetId(data); if (!_orders.TryGetById(id, out var order)) { return; } if (!string.IsNullOrEmpty(data.OrderSysID) && string.IsNullOrEmpty(order.OrderID)) { order.OrderID = data.OrderSysID; order.ExchangeID = data.ExchangeID; _orders.SetMap(order); ProcessTradePending(); } ReportOrder(order, CtpConvert.GetExecType(data), CtpConvert.GetOrderStatus(data), 0, 0, data.StatusMsg); if (_cancelPendings.Contains(id)) { _cancelPendings.Remove(id); ProcessCancelOrder(id); } }