Пример #1
0
        protected override void ProcessBusinessResponse(CTPResponseType responseType, IntPtr pData, CTPResponseInfo rspInfo, int requestID)
        {
            switch (responseType)
            {
                #region 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
            case CTPResponseType.FrontConnectedResponse:
            {
                this.isConnect = true;

                this.UserLogin();

                //调用事件
                OnEventHandler(CTPResponseType.FrontConnectedResponse, new CTPEventArgs());

                break;
            }
                #endregion

                #region 用户登录
            case CTPResponseType.UserLoginResponse:
            {
                CTPEventArgs <CThostFtdcRspUserLoginField> args = CreateEventArgs <CThostFtdcRspUserLoginField>(requestID, rspInfo);

                this.isLogin = true;

                this.OnEventHandler(CTPResponseType.UserLoginResponse, args);
            }
            break;
                #endregion


            case CTPResponseType.DepthMarketDataResponse:
            {
                if (this == null || this.isDispose == true)
                {
                    return;
                }

                CTPEventArgs <CThostFtdcDepthMarketDataField> args = CreateEventArgs <CThostFtdcDepthMarketDataField>(pData, rspInfo);

                OnEventHandler(CTPResponseType.DepthMarketDataResponse, args);

                break;
            }
            }
        }
Пример #2
0
        protected override void ProcessBusinessResponse(CTPResponseType responseType, IntPtr pData, CTPResponseInfo rspInfo, int requestID)
        {
            switch (responseType)
              {
            #region 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
            case CTPResponseType.FrontConnectedResponse:
              {
            this.isConnect = true;

            this.UserLogin();

            //调用事件
            OnEventHandler(CTPResponseType.FrontConnectedResponse, new CTPEventArgs());

            break;
              }
            #endregion

            #region 用户登录
            case CTPResponseType.UserLoginResponse:
              {
            CTPEventArgs<CThostFtdcRspUserLoginField> args = CreateEventArgs<CThostFtdcRspUserLoginField>(pData, rspInfo);

            this.isLogin = true;

            this.OnEventHandler(CTPResponseType.UserLoginResponse, args);
              }
              break;
            #endregion

            case CTPResponseType.DepthMarketDataResponse:
              {
            if (this == null || this.isDispose == true)
            {
              return;
            }

            CTPEventArgs<CThostFtdcDepthMarketDataField> args = CreateEventArgs<CThostFtdcDepthMarketDataField>(pData, rspInfo);

            OnEventHandler(CTPResponseType.DepthMarketDataResponse, args);

            break;
              }
              }
        }
Пример #3
0
        protected override void ProcessBusinessResponse(CTPResponseType responseType, IntPtr pData, CTPResponseInfo rspInfo, int requestID)
        {
            try
            {
                switch (responseType)
                {
                    #region 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
                case CTPResponseType.FrontConnectedResponse:
                {
                    this.isConnect = true;
                    if (this.isLogin == false)
                    {
                        if (this.canLogin)
                        {
                            this.canLogin = false;
                            this.UserLogin();
                            this.reconnectedCount++;
                            //if (this.reconnectedCount < this.reconnectMaxCount)
                            //{
                            //    this.canLogin = false;
                            //    this.UserLogin();
                            //    this.reconnectedCount++;
                            //}
                        }
                        else
                        {
                            //this.canLogin = true;
                            this.needLogin = true;
                        }
                    }

                    //调用事件
                    OnEventHandler(CTPResponseType.FrontConnectedResponse, new CTPEventArgs());

                    break;
                }
                    #endregion

                    #region 错误返回
                case CTPResponseType.ErrorResponse:
                {
                    CTPEventArgs obj = new CTPEventArgs();
                    obj.RequestID    = requestID;
                    obj.ResponseInfo = rspInfo;
                    //调用事件
                    OnEventHandler(CTPResponseType.ErrorResponse, obj);
                    break;
                }
                    #endregion

                    #region 连接断开返回
                case CTPResponseType.FrontDisconnectedResponse:
                {
                    this.isConnect = false;
                    this.isLogin   = false;
                    this.needLogin = false;
                    //this.canLogin = true;
                    CTPEventArgs obj = new CTPEventArgs();
                    obj.RequestID    = requestID;
                    obj.ResponseInfo = rspInfo;
                    //调用事件
                    OnEventHandler(CTPResponseType.FrontDisconnectedResponse, obj);
                    break;
                }
                    #endregion

                    #region 心跳警告返回
                case CTPResponseType.HeartBeatWarningResponse:
                {
                    CTPEventArgs obj = new CTPEventArgs();
                    obj.RequestID    = requestID;
                    obj.ResponseInfo = rspInfo;
                    //调用事件
                    OnEventHandler(CTPResponseType.HeartBeatWarningResponse, obj);
                    break;
                }
                    #endregion

                    #region 客户端认证响应
                case CTPResponseType.AuthenticateResponse:
                {
                    CTPEventArgs <CThostFtdcRspAuthenticateField> args = CreateEventArgs <CThostFtdcRspAuthenticateField>(requestID, rspInfo);

                    this.OnEventHandler(CTPResponseType.AuthenticateResponse, args);

                    break;
                }
                    #endregion

                    #region 登出返回
                case CTPResponseType.UserLogoutResponse:
                {
                    this.isLogin = false;
                    CTPEventArgs obj = new CTPEventArgs();
                    obj.RequestID    = requestID;
                    obj.ResponseInfo = rspInfo;
                    //调用事件
                    OnEventHandler(CTPResponseType.UserLogoutResponse, obj);
                    break;
                }
                    #endregion

                    #region 用户登录
                case CTPResponseType.UserLoginResponse:
                {
                    CTPEventArgs <CThostFtdcRspUserLoginField> args = CreateEventArgs <CThostFtdcRspUserLoginField>(pData, rspInfo);
                    CThostFtdcRspUserLoginField userLogin           = args.Value;


                    if (rspInfo.ErrorID == 0)
                    {
                        this.BrokerID         = userLogin.BrokerID;
                        this.FrontID          = userLogin.FrontID;
                        this.SessionID        = userLogin.SessionID;
                        this.isLogin          = true;
                        this.needLogin        = false;
                        this.canLogin         = true;
                        this.reconnectedCount = 0;
                        //this.loginTime = userLogin.LoginTime;
                    }
                    else
                    {
                        //this.canLogin = true;
                    }
                    this.OnEventHandler(CTPResponseType.UserLoginResponse, args);
                }
                break;
                    #endregion

                    #region 接收到行情数据返回
                case CTPResponseType.DepthMarketDataResponse:
                {
                    if (this == null || this.isDispose == true)
                    {
                        return;
                    }

                    CTPEventArgs <CThostFtdcDepthMarketDataField> args = CreateEventArgs <CThostFtdcDepthMarketDataField>(pData, rspInfo);

                    OnEventHandler(CTPResponseType.DepthMarketDataResponse, args);

                    break;
                }
                    #endregion

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                try
                {
                    CTPEventArgs obj = new CTPEventArgs();
                    obj.RequestID             = requestID;
                    obj.ResponseInfo          = rspInfo;
                    obj.ResponseInfo.Message += ex.StackTrace;
                    //调用事件
                    OnEventHandler(CTPResponseType.ErrorResponse, obj);
                }
                catch (Exception e)
                {
                }
            }
        }
Пример #4
0
        protected override void ProcessBusinessResponse(CTPResponseType responseType, IntPtr pData, CTPResponseInfo rspInfo, int requestID)
        {
            Trace.WriteLine(string.Format("{0} [{1}]:{2},{3},{4}", this.wallTimeStopwatch.ElapsedMilliseconds, this.UserKey, "ProcessBusinessResponse", responseType, requestID));

              switch (responseType)
              {
            #region 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
            case CTPResponseType.FrontConnectedResponse:
              {

            this.isConnect = true;

            this.UserLogin();

            //调用事件
            OnEventHandler(CTPResponseType.FrontConnectedResponse, new CTPEventArgs());

            break;
              }
            #endregion

            #region 通信中断
            case CTPResponseType.FrontDisconnectedResponse:
              ///  当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
              ///@param nReason 错误原因
              ///        0x1001 网络读失败
              ///        0x1002 网络写失败
              ///        0x2001 接收心跳超时
              ///        0x2002 发送心跳失败
              ///        0x2003 收到错误报文
              {
            this.isConnect = false;

            //调用事件
            OnEventHandler(CTPResponseType.FrontDisconnectedResponse, new CTPEventArgs());
              }
              break;
            #endregion

            #region 心跳超时警告
            case CTPResponseType.HeartBeatWarningResponse:
              {
            /// <summary>
            ///心跳超时警告。当长时间未收到报文时,该方法被调用。
            ///@param nTimeLapse 距离上次接收报文的时间
            /// </summary>
            /// <param name="nTimeLapse"></param>
            break;
              }
            #endregion

            #region 客户端认证响应
            case CTPResponseType.AuthenticateResponse:
              {
            CTPEventArgs<CThostFtdcRspAuthenticateField> args = CreateEventArgs<CThostFtdcRspAuthenticateField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.AuthenticateResponse, args);

            break;
              }
            #endregion

            #region 用户登录
            case CTPResponseType.UserLoginResponse:
              {

            CTPEventArgs<CThostFtdcRspUserLoginField> args = CreateEventArgs<CThostFtdcRspUserLoginField>(requestID, rspInfo);

            CThostFtdcRspUserLoginField userLogin = args.Value;

            if (rspInfo.ErrorID == 0)
            {

              this.BrokerID = userLogin.BrokerID;
              this.FrontID = userLogin.FrontID;
              this.SessionID = userLogin.SessionID;
              this.isLogin = true;
              this.loginTime = userLogin.LoginTime;

              //最大报单引用
              int orderRef = 0;

              if (int.TryParse(userLogin.MaxOrderRef, out orderRef) == false)
              {
                orderRef = 0;
              }

              this.orderRef = orderRef;
              //this.currentOrderRef++;

              DateTime.TryParseExact(userLogin.TradingDay, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out this.tradingDate);

              //大连
              TimeSpan.TryParse(userLogin.DCETime, out this.loginTimeDCE);
              this.exchanges["DCE"].CurrentTime = this.loginTimeDCE;
              //郑州
              TimeSpan.TryParse(userLogin.CZCETime, out this.loginTimeCZCE);
              this.exchanges["CZCE"].CurrentTime = this.loginTimeCZCE;
              //中金
              TimeSpan.TryParse(userLogin.FFEXTime, out this.loginTimeCFFEX);
              this.exchanges["CFFEX"].CurrentTime = this.loginTimeCFFEX;
              //上海
              TimeSpan.TryParse(userLogin.SHFETime, out this.loginTimeSHFE);
              this.exchanges["SHFE"].CurrentTime = this.loginTimeSHFE;

              this.wallTimeStopwatch.Start();
              this.timer.Change(0, 1000);
            }

            this.OnEventHandler(CTPResponseType.UserLoginResponse, args);
              }
              break;
            #endregion

            #region 登出请求响应
            case CTPResponseType.UserLogoutResponse:
              {
            this.isLogin = false;

            //调用事件
            OnEventHandler(CTPResponseType.UserLogoutResponse, new CTPEventArgs());
            break;
              }
            #endregion

            #region 用户口令更新请求响应
            case CTPResponseType.UserPasswordUpdateResponse:
              /// <summary>
              /// 用户口令更新请求响应
              /// </summary>
              {
            CTPEventArgs<CThostFtdcUserPasswordUpdateField> args = CreateEventArgs<CThostFtdcUserPasswordUpdateField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.UserPasswordUpdateResponse, args);

            break;
              }
            #endregion

            #region 资金账户口令更新请求响应
            case CTPResponseType.TradingAccountPasswordUpdateResponse:
              /// <summary>
              /// 资金账户口令更新请求响应
              /// </summary>
              /// <param name="pTradingAccountPasswordUpdate"></param>
              /// <param name="pRspInfo"></param>
              /// <param name="nRequestID"></param>
              /// <param name="bIsLast"></param>
              {
            CTPEventArgs<CThostFtdcTradingAccountPasswordUpdateField> args = CreateEventArgs<CThostFtdcTradingAccountPasswordUpdateField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.TradingAccountPasswordUpdateResponse, args);

            break;
              }
            #endregion

            #region 报单录入请求响应
            case CTPResponseType.OrderInsertResponse:
              {

            CTPEventArgs<CThostFtdcInputOrderField> args = CreateEventArgs<CThostFtdcInputOrderField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.OrderInsertResponse, args);

            break;
              }
            #endregion

            #region 预埋单录入请求响应
            case CTPResponseType.ParkedOrderInsertResponse:
              {
            CTPEventArgs<CThostFtdcParkedOrderField> args = CreateEventArgs<CThostFtdcParkedOrderField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ParkedOrderInsertResponse, args);

            break;
              }
            #endregion

            #region 预埋单撤单请求响应
            case CTPResponseType.ParkedOrderActionResponse:
              {
            CTPEventArgs<CThostFtdcParkedOrderActionField> args = CreateEventArgs<CThostFtdcParkedOrderActionField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ParkedOrderActionResponse, args);
            break;
              }
            #endregion

            #region 改单响应
            case CTPResponseType.OrderActionResponse:
              {
            CTPEventArgs<CThostFtdcInputOrderActionField> args = CreateEventArgs<CThostFtdcInputOrderActionField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.OrderActionResponse, args);

            break;
              }
            #endregion

            #region 查询最大报单数量响应
            case CTPResponseType.QueryMaxOrderVolumeResponse:
              {
            CTPEventArgs<CThostFtdcQueryMaxOrderVolumeField> args = CreateEventArgs<CThostFtdcQueryMaxOrderVolumeField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.QueryMaxOrderVolumeResponse, args);

            break;
              }
            #endregion

            #region 投资者结算结果确认响应
            case CTPResponseType.SettlementInfoConfirmResponse:
              {

            if (rspInfo.ErrorID == 0)
            {
              this.isSettlementConfim = true;
            }

            CTPEventArgs<CThostFtdcSettlementInfoConfirmField> args = CreateEventArgs<CThostFtdcSettlementInfoConfirmField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.SettlementInfoConfirmResponse, args);

            break;
              }
            #endregion

            #region 删除预埋单响应
            case CTPResponseType.RemoveParkedOrderResponse:
              {
            CTPEventArgs<CThostFtdcRemoveParkedOrderField> args = CreateEventArgs<CThostFtdcRemoveParkedOrderField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.RemoveParkedOrderResponse, args);

            break;
              }
            #endregion

            #region 删除预埋撤单响应
            case CTPResponseType.RemoveParkedOrderActionResponse:
              {
            CTPEventArgs<CThostFtdcRemoveParkedOrderActionField> args = CreateEventArgs<CThostFtdcRemoveParkedOrderActionField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.RemoveParkedOrderActionResponse, args);

            break;
              }
            #endregion

            #region 查询报单响应
            case CTPResponseType.QueryOrderResponse:
              {
            CTPEventArgs<List<CThostFtdcOrderField>> args = CreateListEventArgs<CThostFtdcOrderField>(requestID, rspInfo);

            lock (this.OrderList)
            {
              this.OrderList.Clear();
              this.OrderList.AddRange(args.Value);
            }

            //调用事件
            OnEventHandler(CTPResponseType.QueryOrderResponse, args);

            break;
              }
            #endregion

            #region 查询成交单响应
            case CTPResponseType.QueryTradeResponse:
              {
            CTPEventArgs<List<CThostFtdcTradeField>> args = CreateListEventArgs<CThostFtdcTradeField>(requestID, rspInfo);

            this.TradeList.Clear();
            this.TradeList.AddRange(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryTradeResponse, args);

            break;
              }
            #endregion

            #region 查询投资者持仓响应
            case CTPResponseType.QueryInvestorPositionResponse:
              {
            CTPEventArgs<List<CThostFtdcInvestorPositionField>> args = CreateListEventArgs<CThostFtdcInvestorPositionField>(requestID, rspInfo);

            this.PositionList.Clear();
            this.PositionList.AddRange(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryInvestorPositionResponse, args);
            break;
              }
            #endregion

            #region 查询资金账户响应
            case CTPResponseType.QueryTradingAccountResponse:
              {

            /// 查询资金账户响应
            CTPEventArgs<CThostFtdcTradingAccountField> args = CreateEventArgs<CThostFtdcTradingAccountField>(requestID, rspInfo);

            this.tradingAccount = args.Value;

            this.OnEventHandler(CTPResponseType.QueryTradingAccountResponse, args);

            break;
              }
            #endregion

            #region 查询投资者响应
            case CTPResponseType.QueryInvestorResponse:
              {
            CTPEventArgs<CThostFtdcInvestorField> args = CreateEventArgs<CThostFtdcInvestorField>(requestID, rspInfo);

            this.investor = args.Value;

            this.OnEventHandler(CTPResponseType.QueryInvestorResponse, args);

            break;
              }
            #endregion

            #region 请求查询交易编码响应
            case CTPResponseType.QueryTradingCodeResponse:
              {
            CTPEventArgs<CThostFtdcTradingCodeField> args = CreateEventArgs<CThostFtdcTradingCodeField>(requestID, rspInfo);

            this.OnEventHandler(CTPResponseType.QueryTradingCodeResponse, args);

            break;
              }
            #endregion

            #region 查询保证金响应
            case CTPResponseType.QueryInstrumentMarginRateResponse:
              {
            CTPEventArgs<CThostFtdcInstrumentMarginRateField> args = CreateEventArgs<CThostFtdcInstrumentMarginRateField>(requestID, rspInfo);

            this.SetInstrumentRate(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryInstrumentMarginRateResponse, args);

            break;
              }
            #endregion

            #region 查询手续费响应
            case CTPResponseType.QueryInstrumentCommissionRateResponse:
              {
            CTPEventArgs<CThostFtdcInstrumentCommissionRateField> args = CreateEventArgs<CThostFtdcInstrumentCommissionRateField>(requestID, rspInfo);

            this.SetInstrumentRate(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryInstrumentCommissionRateResponse, args);

            CTPTaskBase<CTPRequestAction> task = null;
            if (this.processedTasks.TryGetValue(args.RequestID, out task))
            {
              if (task.Callback != null)
              {
                task.Callback(task,args);
              }
            }
            break;
              }
            #endregion

            #region 查询交易所响应
            case CTPResponseType.QueryExchangeResponse:
              {

            CTPEventArgs<CThostFtdcExchangeField> args = CreateEventArgs<CThostFtdcExchangeField>(requestID, rspInfo);

            //保存市场信息
            CTPExchange ctpExchange = new CTPExchange();
            ctpExchange.SetNativeValue(args.Value);
            this.Exchanges.Add(args.Value.ExchangeID, ctpExchange);

            //调用事件
            OnEventHandler(CTPResponseType.QueryExchangeResponse, new CTPEventArgs<CTPExchange>(ctpExchange));

            break;
              }
            #endregion

            #region 查询合约响应
            case CTPResponseType.QueryInstrumentResponse:
              {

            CTPEventArgs<List<CThostFtdcInstrumentField>> values = CreateListEventArgs<CThostFtdcInstrumentField>(requestID, rspInfo);

            foreach (var instrument in values.Value)
            {

              if (instrument.ProductClass == CTPProductClassType.EFP)
              {
                continue;
              }

              CTPInstrument ctpInstrument = new CTPInstrument();
              ctpInstrument.SetNativeValue(instrument);

              //加入到市场列表
              if (this.Exchanges.ContainsKey(ctpInstrument.ExchangeID))
              {
                this.Exchanges[instrument.ExchangeID].Instruments.Add(ctpInstrument);
              }

              //if (this.SymbolProducts.ContainsKey(ctpInstrument.ProductID.ToUpper()) == false)
              //{
              //  this.SymbolProducts.Add(ctpInstrument.ProductID.ToUpper(), new CTPSymbolProduct(instrument));
              //}

              //加入到合约表
              if (this.InstrumentDictionary.ContainsKey(ctpInstrument.ID) == false)
              {
                this.InstrumentDictionary.Add(ctpInstrument.ID, ctpInstrument);
              }
            }

            //创建新的事件参数
            List<CTPInstrument> list = new List<CTPInstrument>(this.InstrumentDictionary.Values);
            CTPEventArgs<List<CTPInstrument>> args = new CTPEventArgs<List<CTPInstrument>>(list);

            //调用事件
            OnEventHandler(CTPResponseType.QueryInstrumentResponse, args);

            break;
              }
            #endregion

            #region 查询行情响应
            case CTPResponseType.QueryDepthMarketDataResponse:
              {
            CTPEventArgs<CThostFtdcDepthMarketDataField> args = CreateEventArgs<CThostFtdcDepthMarketDataField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryDepthMarketDataResponse, args);

            break;
              }
            #endregion

            #region 查询结算单
            case CTPResponseType.QuerySettlementInfoResponse:
              {

            CTPEventArgs<List<CThostFtdcSettlementInfoField>> rspData = CreateListEventArgs<CThostFtdcSettlementInfoField>(requestID, rspInfo);

            CTPSettlementInfo sinfo = new CTPSettlementInfo();

            foreach (var item in rspData.Value)
            {
              sinfo.Context += PInvokeUtility.GetUnicodeString(item.Content);
            }

            //读取结算单信息
            //sinfo.ReadContext();

            //从请求参数中获取日期
            CThostFtdcQrySettlementInfoField queryData = (CThostFtdcQrySettlementInfoField)this.processedTasks[requestID].Parameter;
            string tradingDate = queryData.TradingDay;

            if (string.IsNullOrEmpty(tradingDate))
            {
              tradingDate = sinfo.TradingDate;
            }

            if (string.IsNullOrEmpty(tradingDate))
            {
              tradingDate = this.TradingDate.ToString("yyyyMMdd");
            }

            if (this.settlementInfoDictionary.ContainsKey(tradingDate) == false)
            {
              this.settlementInfoDictionary.Add(tradingDate, sinfo);
            }
            else
            {
              this.settlementInfoDictionary[tradingDate] = sinfo;
            }

            //调用事件
            OnEventHandler(CTPResponseType.QuerySettlementInfoResponse, new CTPEventArgs<CTPSettlementInfo>(sinfo, rspInfo));

            break;
              }
            #endregion

            #region 请求查询转帐银行响应
            case CTPResponseType.QueryTransferBankResponse:
              {
            CTPEventArgs<CThostFtdcTransferBankField> args = CreateEventArgs<CThostFtdcTransferBankField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryTransferBankResponse, args);

            break;
              }
            #endregion

            #region 查询投资者持仓明细响应
            case CTPResponseType.QueryInvestorPositionDetailResponse:
              {

            CTPEventArgs<List<CThostFtdcInvestorPositionDetailField>> args = CreateListEventArgs<CThostFtdcInvestorPositionDetailField>(requestID, rspInfo);

            this.PositionDetailList.Clear();
            this.PositionDetailList.AddRange(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryInvestorPositionDetailResponse, args);

            break;
              }
            #endregion

            #region 请求查询客户通知响应
            case CTPResponseType.QueryNoticeResponse:
              {

            CTPEventArgs<List<CThostFtdcNoticeField>> args = CreateListEventArgs<CThostFtdcNoticeField>(requestID, rspInfo);

            StringBuilder buffer = new StringBuilder();

            foreach (var item in args.Value)
            {
              buffer.Append(PInvokeUtility.GetUnicodeString(item.Content));
            }

            //调用事件
            OnEventHandler(CTPResponseType.QueryNoticeResponse, new CTPEventArgs<String>(buffer.ToString()));

            break;
              }
            #endregion

            #region 查询结算单确认响应
            case CTPResponseType.QuerySettlementInfoConfirmResponse:
              {
            CTPEventArgs<CThostFtdcSettlementInfoConfirmField> args = CreateEventArgs<CThostFtdcSettlementInfoConfirmField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QuerySettlementInfoConfirmResponse, args);

            break;
              }
            #endregion

            #region 查询投资者组合持仓明细响应
            case CTPResponseType.QueryInvestorPositionCombineDetailResponse:
              {
            CTPEventArgs<List<CThostFtdcInvestorPositionCombineDetailField>> args = CreateListEventArgs<CThostFtdcInvestorPositionCombineDetailField>(requestID, rspInfo);

            this.investorPositionCombineDetailList = args.Value;

            //调用事件
            OnEventHandler(CTPResponseType.QueryInvestorPositionCombineDetailResponse, args);
            break;
              }
            #endregion

            #region 查询保证金中心响应
            case CTPResponseType.QueryCFMMCTradingAccountKeyResponse:
              {
            if (pData == IntPtr.Zero)
            {
              //不存在保证金KEY的服务器,是模拟服务器
              this.isSimulationServer = true;
            }

            //查询保证金中心,为登录后内部初始化时的最后调用
            //因此,当该查询返回时,可认为初始化完成
            this.isInitialized = true;

            CTPEventArgs<CThostFtdcCFMMCTradingAccountKeyField> args = CreateEventArgs<CThostFtdcCFMMCTradingAccountKeyField>(requestID, rspInfo);

            this.cfmmcTradingAccountKey = args.Value;

            //调用事件
            OnEventHandler(CTPResponseType.QueryCFMMCTradingAccountKeyResponse, args);

            break;
              }
            #endregion

            #region 【20120828增加(未实现)】请求查询仓单折抵信息响应
            case CTPResponseType.QueryEWarrantOffsetResponse:
              {
            break;
              }
            #endregion

            #region 请求查询转帐流水响应
            case CTPResponseType.QueryTransferSerialResponse:
              {
            CTPEventArgs<List<CThostFtdcTransferSerialField>> args = CreateListEventArgs<CThostFtdcTransferSerialField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryTransferSerialResponse, args);

            break;
              }
            #endregion

            #region 【20120828增加(未实现)】请求查询银期签约关系响应
            case CTPResponseType.QueryAccountregisterResponse:
              {
            break;
              }
            #endregion

            #region 错误回报
            case CTPResponseType.ErrorResponse:
              {
            this.OnEventHandler(CTPResponseType.ErrorResponse, new CTPEventArgs(rspInfo));
            break;
              }
            #endregion

            #region 报单回报
            case CTPResponseType.ReturnOrderResponse:
              {

            CTPEventArgs<CThostFtdcOrderField> args = CreateEventArgs<CThostFtdcOrderField>(pData, rspInfo);

            lock (this.orderList)
            {
              AppendOrReplaceOrder(this.orderList, args.Value);
            }

            //调用事件
            OnEventHandler(CTPResponseType.ReturnOrderResponse, args);

            break;
              }
            #endregion

            #region 成交回报
            case CTPResponseType.ReturnTradeResponse:
              {
            CTPEventArgs<CThostFtdcTradeField> args = CreateEventArgs<CThostFtdcTradeField>(pData, rspInfo);

            //插入到列表中
            AppendOrReplaceOrder(this.tradeList, args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnTradeResponse, args);

            break;
              }
            #endregion

            #region 错单回报
            case CTPResponseType.ErrorReturnOrderInsertResponse:
              {

            CTPEventArgs<CThostFtdcInputOrderField> args = CreateEventArgs<CThostFtdcInputOrderField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnOrderInsertResponse, args);

            break;
              }
            #endregion

            #region 报单操作错误回报
            case CTPResponseType.ErrorReturnOrderActionResponse:
              {

            CTPEventArgs<CThostFtdcOrderActionField> args = CreateEventArgs<CThostFtdcOrderActionField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnOrderActionResponse, args);

            break;
              }
            #endregion

            #region 合约交易状态通知
            case CTPResponseType.ReturnInstrumentStatusResponse:
              {

            CTPEventArgs<CThostFtdcInstrumentStatusField> args = CreateEventArgs<CThostFtdcInstrumentStatusField>(pData, rspInfo);

            CThostFtdcInstrumentStatusField instrumentStatus = args.Value;

            Trace.WriteLine(string.Format("{0}:{1} {2}", instrumentStatus.ExchangeID, instrumentStatus.InstrumentStatus,instrumentStatus.EnterTime));

            //交易所状态
            if (this.exchangeStatus.ContainsKey(instrumentStatus.ExchangeID) == false)
            {
              this.exchangeStatus.Add(instrumentStatus.ExchangeID, instrumentStatus.InstrumentStatus);
            }
            //更新交易所状态
            this.exchangeStatus[instrumentStatus.ExchangeID] = instrumentStatus.InstrumentStatus;

            this.tradingStatus = instrumentStatus.InstrumentStatus;

            //初始化完成之前不推送状态事件
            if (isInitialized)
            {
              //调用事件
              OnEventHandler(CTPResponseType.ReturnInstrumentStatusResponse, args);
            }
            break;
              }
            #endregion

            #region 交易通知
            case CTPResponseType.ReturnTradingNoticeResponse:
              {
            //CTPEventArgs<CThostFtdcTradingNoticeInfoField> args = CreateEventArgs<CThostFtdcTradingNoticeInfoField>(pData, rspInfo);
            CThostFtdcTradingNoticeInfoField value = PInvokeUtility.GetObjectFromIntPtr<CThostFtdcTradingNoticeInfoField>(pData);

            CTPEventArgs<string> args = new CTPEventArgs<string>(PInvokeUtility.GetUnicodeString(value.FieldContent));

            //调用事件
            OnEventHandler(CTPResponseType.ReturnTradingNoticeResponse, args);

            break;
              }
            #endregion

            #region 【已删除】提示条件单校验错误
            //case CTPResponseType.ReturnErrorConditionalOrderResponse:
            //  {

            //    CTPEventArgs<CThostFtdcErrorConditionalOrderField> args = CreateEventArgs<CThostFtdcErrorConditionalOrderField>(pData, rspInfo);

            //    //调用事件
            //    OnEventHandler(CTPResponseType.ReturnErrorConditionalOrderResponse, args);

            //    break;
            //  }
            #endregion

            #region 请求查询签约银行响应
            case CTPResponseType.QueryContractBankResponse:
              {
            CTPEventArgs<List<CThostFtdcContractBankField>> args = CreateListEventArgs<CThostFtdcContractBankField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryContractBankResponse, args);

            break;
              }
            #endregion

            #region 查询预埋单响应
            case CTPResponseType.QueryParkedOrderResponse:
              {
            CTPEventArgs<List<CThostFtdcParkedOrderField>> args = CreateListEventArgs<CThostFtdcParkedOrderField>(requestID, rspInfo);

            this.ParkedOrderList.Clear();
            this.ParkedOrderList.AddRange(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryParkedOrderResponse, args);

            break;
              }
            #endregion

            #region 查询预埋撤单响应
            case CTPResponseType.QueryParkedOrderActionResponse:
              {

            CTPEventArgs<List<CThostFtdcParkedOrderActionField>> args = CreateListEventArgs<CThostFtdcParkedOrderActionField>(requestID, rspInfo);

            this.ParkedOrderActionList.Clear();
            this.ParkedOrderActionList.AddRange(args.Value);

            //调用事件
            OnEventHandler(CTPResponseType.QueryParkedOrderActionResponse, args);

            break;
              }
            #endregion

            #region 请求查询交易通知响应
            case CTPResponseType.QueryTradingNoticeResponse:
              {
            CTPEventArgs<List<CThostFtdcTradingNoticeField>> args = CreateListEventArgs<CThostFtdcTradingNoticeField>(requestID, rspInfo);

            StringBuilder buffer = new StringBuilder();

            //合并消息内容
            foreach (var item in args.Value)
            {
              buffer.Append(PInvokeUtility.GetUnicodeString(item.FieldContent));
            }

            //调用事件
            OnEventHandler(CTPResponseType.QueryTradingNoticeResponse, new CTPEventArgs<string>(buffer.ToString()));

            break;
              }
            #endregion

            #region 请求查询经纪公司交易参数响应
            case CTPResponseType.QueryBrokerTradingParamsResponse:
              {

            CTPEventArgs<CThostFtdcBrokerTradingParamsField> args = CreateEventArgs<CThostFtdcBrokerTradingParamsField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryBrokerTradingParamsResponse, args);

              }
              break;
            #endregion

            #region 请求查询经纪公司交易参数响应
            case CTPResponseType.QueryBrokerTradingAlgosResponse:
              {
            CTPEventArgs<CThostFtdcBrokerTradingAlgosField> args = CreateEventArgs<CThostFtdcBrokerTradingAlgosField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryBrokerTradingAlgosResponse, args);

            break;
              }
            #endregion

            #region 银行发起银行资金转期货通知
            case CTPResponseType.ReturnFromBankToFutureByBankResponse:
              {
            CTPEventArgs<CThostFtdcRspTransferField> args = CreateEventArgs<CThostFtdcRspTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnFromBankToFutureByBankResponse, args);

            break;
              }
            #endregion

            #region 银行发起期货资金转银行通知
            case CTPResponseType.ReturnFromFutureToBankByBankResponse:
              {
            CTPEventArgs<CThostFtdcRspTransferField> args = CreateEventArgs<CThostFtdcRspTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnFromFutureToBankByBankResponse, args);

            break;
              }
            #endregion

            #region 银行发起冲正银行转期货通知
            case CTPResponseType.ReturnRepealFromBankToFutureByBankResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromBankToFutureByBankResponse, args);

            break;
              }
            #endregion

            #region 银行发起冲正期货转银行通知
            case CTPResponseType.ReturnRepealFromFutureToBankByBankResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromFutureToBankByBankResponse, args);

            break;
              }
            #endregion

            #region 期货发起银行资金转期货通知
            case CTPResponseType.ReturnFromBankToFutureByFutureResponse:
              {
            CTPEventArgs<CThostFtdcRspTransferField> args = CreateEventArgs<CThostFtdcRspTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnFromBankToFutureByFutureResponse, args);

            break;
              }
            #endregion

            #region 期货发起期货资金转银行通知
            case CTPResponseType.ReturnFromFutureToBankByFutureResponse:
              {
            CTPEventArgs<CThostFtdcRspTransferField> args = CreateEventArgs<CThostFtdcRspTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnFromFutureToBankByFutureResponse, args);

            break;
              }
            #endregion

            #region 系统运行时期手工冲正
            case CTPResponseType.ReturnRepealFromBankToFutureByFutureManualResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromBankToFutureByFutureManualResponse, args);

            break;
              }
            case CTPResponseType.ReturnRepealFromFutureToBankByFutureManualResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromFutureToBankByFutureManualResponse, args);

            break;
              }
            #endregion

            #region 期货发起查询银行余额通知
            case CTPResponseType.ReturnQueryBankBalanceByFutureResponse:
              {
            CTPEventArgs<CThostFtdcNotifyQueryAccountField> args = CreateEventArgs<CThostFtdcNotifyQueryAccountField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnQueryBankBalanceByFutureResponse, args);

            break;
              }
            #endregion

            #region 期货端出入金错误回报
            case CTPResponseType.ErrorReturnBankToFutureByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqTransferField> args = CreateEventArgs<CThostFtdcReqTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnBankToFutureByFutureResponse, args);

            break;
              }
            case CTPResponseType.ErrorReturnFutureToBankByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqTransferField> args = CreateEventArgs<CThostFtdcReqTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnFutureToBankByFutureResponse, args);

            break;
              }
            #endregion

            #region 手工冲正错误回报
            case CTPResponseType.ErrorReturnRepealBankToFutureByFutureManualResponse:
              {
            CTPEventArgs<CThostFtdcReqRepealField> args = CreateEventArgs<CThostFtdcReqRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnRepealBankToFutureByFutureManualResponse, args);

            break;
              }
            case CTPResponseType.ErrorReturnRepealFutureToBankByFutureManualResponse:
              {
            CTPEventArgs<CThostFtdcReqRepealField> args = CreateEventArgs<CThostFtdcReqRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnRepealFutureToBankByFutureManualResponse, args);

            break;
              }
            #endregion

            #region 期货发起查询银行余额错误回报
            case CTPResponseType.ErrorReturnQueryBankBalanceByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqQueryAccountField> args = CreateEventArgs<CThostFtdcReqQueryAccountField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ErrorReturnQueryBankBalanceByFutureResponse, args);

            break;
              }
            #endregion

            #region 期货发起冲正请求,银行处理完毕后报盘发回的通知
            case CTPResponseType.ReturnRepealFromBankToFutureByFutureResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromBankToFutureByFutureResponse, args);

            break;
              }
            case CTPResponseType.ReturnRepealFromFutureToBankByFutureResponse:
              {
            CTPEventArgs<CThostFtdcRspRepealField> args = CreateEventArgs<CThostFtdcRspRepealField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.ReturnRepealFromFutureToBankByFutureResponse, args);

            break;
              }
            #endregion

            #region 期货发起出入金应答
            case CTPResponseType.FromBankToFutureByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqTransferField> args = CreateEventArgs<CThostFtdcReqTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.FromBankToFutureByFutureResponse, args);

            break;
              }
            case CTPResponseType.FromFutureToBankByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqTransferField> args = CreateEventArgs<CThostFtdcReqTransferField>(pData, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.FromFutureToBankByFutureResponse, args);

            break;
              }
            #endregion

            #region 期货发起查询银行余额应答
            case CTPResponseType.QueryBankAccountMoneyByFutureResponse:
              {
            CTPEventArgs<CThostFtdcReqQueryAccountField> args = CreateEventArgs<CThostFtdcReqQueryAccountField>(requestID, rspInfo);

            //调用事件
            OnEventHandler(CTPResponseType.QueryBankAccountMoneyByFutureResponse, args);

            break;
              }
            #endregion

            #region 【20120828增加(未实现)】银行发起银期开户通知
            case CTPResponseType.OpenAccountByBankResponse:
              {
            break;
              }
            #endregion

            #region 【20120828增加(未实现)】银行发起银期销户通知
            case CTPResponseType.CancelAccountByBankResponse:
              {
            break;
              }
            #endregion

            #region 【20120828增加(未实现)】银行发起变更银行账号通知
            case CTPResponseType.ChangeAccountByBankResponse:
              {
            break;
              }
            #endregion

            default:
              break;
              }
        }