public GroupService.Queryinfo SendOrderHK(int Category, int PriceType, string Gddm, string Zqdm, float Price, int Quantity, StringBuilder result, StringBuilder errInfo) { GroupClient.GroupService.Queryinfo response = new GroupService.Queryinfo(); try { TdxApi.QueryHKData(ClientID, 2, result, errInfo); var 单前ErrInfo = errInfo.ToString(); if (单前ErrInfo != string.Empty) { response.Result = result.ToString(); response.Error = errInfo.ToString(); } else { response.Other = result.ToString(); TdxApi.SendHKOrder(ClientID, Category, 2, 0, Gddm, Zqdm, Price.ToString(), Quantity.ToString(), result, errInfo); } } catch (Exception ex) { response.Error += "下单异常:" + ex.Message; } return(response); }
/// <summary> /// A股下单逻辑 /// </summary> public GroupService.Queryinfo SendOrderNormal(int Category, int PriceType, string Gddm, string Zqdm, float Price, int Quantity, string mac, StringBuilder result, StringBuilder errInfo) { DateTime st = DateTime.Now; StringBuilder sbResult = new StringBuilder(1024 * 1024); StringBuilder sbError = new StringBuilder(256); GroupService.Queryinfo response = new GroupService.Queryinfo(); try { sbResult.Append(this.strTitleWt + "\n" + string.Join("\n", dictWt.Values)); sbError.Append(this.QueryInfo.SearchOperatorError); var 单前ErrInfo = sbError.ToString(); if (单前ErrInfo != string.Empty) { response.Result = sbResult.ToString(); response.Error = sbError.ToString(); CommonUtils.Log("下单前查询异常,组合号{0},证券代码{1},错误信息{2},耗时{3}", this.称, Zqdm, response.Error, (DateTime.Now - st).TotalSeconds.ToString()); } else { response.Other = result.ToString(); TdxApi.SendOrder(ClientID, Category, PriceType, Gddm, Zqdm, Price, Quantity, sbResult, sbError); string ErrInfo = sbError.ToString(); if (ErrInfo == string.Empty) { DataTable DataTable1 = CommonUtils.ChangeDataStringToTable(sbResult.ToString()); string id = null; if (DataTable1.Columns.Contains("委托编号")) { id = DataTable1.Rows[0]["委托编号"] as string; } else if (DataTable1.Columns.Contains("合同编号")) { id = DataTable1.Rows[0]["合同编号"] as string; } if (id != null && !lstOrderID.Contains(id)) { lstOrderID.Add(id); dictOrderSuccessTime[id] = DateTime.Now; } } else { CommonUtils.Log("下单异常,组合号{0},证券代码{1},错误信息{2}", this.称, Zqdm, ErrInfo); if (ErrInfo.Contains("尝试其他交易服务器") || ErrInfo.Contains("超时")) { CommonUtils.Log("开始记录可能存在漏单数据"); var mayLostOrder = new OrderInfoCache() { Category = Category, GroupName = this.称, SendPrice = Price, SendQty = Quantity, StockID = Zqdm, SendTime = DateTime.Now, SendMac = mac, }; CommonUtils.Log("可能存在漏单数据,请求数据{0}", mayLostOrder.ToJson()); var table = Tool.ChangeDataStringToTable(this.QueryInfo.SearchOperatorResult); if (table != null && table.Rows.Count > 0) { mayLostOrder.CheckedIndex = table.Rows.Count; } queueMayLostOrder.Enqueue(mayLostOrder); } } } } catch (Exception ex) { CommonUtils.Log("下单异常,组合号{0}, 股票代码{1},异常信息{2}", this.称, Zqdm, ex.Message); } response.Result = sbResult.ToString(); response.Error = sbError.ToString(); return(response); }