void trader_QueryInvestorPositionDetailResponse(object sender, CTPEventArgs <List <CThostFtdcInvestorPositionDetailField> > e) { PrintObjectList(e.Value); BindObjectList(this.idPositionDetailDataGridView, e.Value); //订阅行情 List <string> symbols = new List <string>(); //筛选持仓合约 foreach (var item in e.Value) { CTPInstrument inst = this.trader.GetInstrument(item.InstrumentID); if (inst != null) { if (symbols.Contains(inst.ID) == false) { symbols.Add(inst.ID); } } } //订阅行情 this.quote.SubscribeMarketData(symbols.ToArray()); }
void trader_ReturnOrderResponse(object sender, CTPEventArgs <CThostFtdcOrderField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idOrderDataGridView, e.Value, new Func <DataRow, object, bool>( (DataRow row, object obj) => { CThostFtdcOrderField order = (CThostFtdcOrderField)obj; if (row["OrderSysID"] != null && string.IsNullOrWhiteSpace(row["OrderSysID"].ToString()) == false) { return(order.OrderSysID == (string)row["OrderSysID"]); } else if (order.FrontID == (int)row["FrontID"] && order.SessionID == (int)row["SessionID"] && order.OrderRef == (string)row["OrderRef"]) { return(true); } else { return(false); } })); })); }
void trader_QueryTradingAccountResponse(object sender, CTPEventArgs <CThostFtdcTradingAccountField> e) { PrintObject(e.Value); BindObjectList(this.idAmountDataGridView, new List <CThostFtdcTradingAccountField>() { e.Value }); }
void trader_ReturnTradeResponse(object sender, CTPEventArgs <CThostFtdcTradeField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idTradeDataGridView, e.Value); })); }
void trader_QueryDepthMarketDataResponse(object sender, CTPEventArgs <CThostFtdcDepthMarketDataField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { this.idPriceNumericUpDown.Value = Convert.ToDecimal(e.Value.LastPrice); })); }
void trader_UserLoginResponse(object sender, CTPEventArgs <CThostFtdcRspUserLoginField> e) { if (e.ResponseInfo.ErrorID != 0) { Debug.Write(e.ResponseInfo.Message); ShowMessage(e.ResponseInfo.Message); } PrintObject(e.Value); }
void quote_DepthMarketDataResponse(object sender, CTPEventArgs <CThostFtdcDepthMarketDataField> e) { CThostFtdcDepthMarketDataField newValue = e.Value; UpdateBindTable(this.idQuoteDataGridView, e.Value, (DataRow row, Object obj) => { CThostFtdcDepthMarketDataField data = (CThostFtdcDepthMarketDataField)obj; return(row["InstrumentID"].ToString() == data.InstrumentID); }); //this.idQuoteDataGridView.InvalidateRow(index); }
void trader_UserLoginResponse(object sender, CTPEventArgs <CThostFtdcRspUserLoginField> e) { if (e.ResponseInfo.ErrorID != 0) { //中止登录 loginWorker.CancelAsync(); //显示错误信息 ShowMessage(e.ResponseInfo.Message); } else { //通知交易登录 OnTradeServerLogged(sender); } }
void trader_QueryInstrumentResponse(object sender, CTPEventArgs <List <CTPInstrument> > e) { PrintObjectList(e.Value); BindObjectList(this.idSymbolDataGridView, e.Value); //添加合约到下拉列表 this.Invoke(new Action(() => { string[] symbols = (from s in e.Value orderby s.ID select s.ID).ToArray(); this.idSymbolCodeComboBox.Items.Clear(); this.idSymbolCodeComboBox.Items.AddRange(symbols); this.idSymbolCodeComboBox.AutoCompleteCustomSource.Clear(); this.idSymbolCodeComboBox.AutoCompleteCustomSource.AddRange(symbols); })); }
void trader_ErrorReturnOrderInsertResponse(object sender, CTPEventArgs <CThostFtdcInputOrderField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idOrderDataGridView, e.Value, new Func <DataRow, object, bool>( (DataRow row, object obj) => { CThostFtdcInputOrderField order = (CThostFtdcInputOrderField)obj; if (order.OrderRef == (string)row["OrderRef"]) { return(true); } else { return(false); } })); })); }
void quote_DepthMarketDataResponse(object sender, CTPEventArgs<CThostFtdcDepthMarketDataField> e) { CThostFtdcDepthMarketDataField newValue = e.Value; UpdateBindTable(this.idQuoteDataGridView, e.Value, (DataRow row, Object obj) => { CThostFtdcDepthMarketDataField data = (CThostFtdcDepthMarketDataField)obj; return (row["InstrumentID"].ToString() == data.InstrumentID); }); //this.idQuoteDataGridView.InvalidateRow(index); }
void trader_OrderInsertResponse(object sender, CTPEventArgs <CThostFtdcInputOrderField> e) { ShowMessage(e.ResponseInfo.Message); PrintObject(e.Value); }
void trader_UserLoginResponse(object sender, CTPEventArgs<CThostFtdcRspUserLoginField> e) { if (e.ResponseInfo.ErrorID != 0) { //中止登录 loginWorker.CancelAsync(); //显示错误信息 ShowMessage(e.ResponseInfo.Message); } else { //通知交易登录 OnTradeServerLogged(sender); } }
void trader_QueryTradingAccountResponse(object sender, CTPEventArgs<CThostFtdcTradingAccountField> e) { PrintObject(e.Value); BindObjectList(this.idAmountDataGridView, new List<CThostFtdcTradingAccountField>() { e.Value }); }
void trader_ReturnOrderResponse(object sender, CTPEventArgs<CThostFtdcOrderField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idOrderDataGridView, e.Value, new Func<DataRow, object, bool>( (DataRow row, object obj) => { CThostFtdcOrderField order = (CThostFtdcOrderField)obj; if (row["OrderSysID"] != null && string.IsNullOrWhiteSpace(row["OrderSysID"].ToString()) == false) { return order.OrderSysID == (string)row["OrderSysID"]; } else if (order.FrontID == (int)row["FrontID"] && order.SessionID == (int)row["SessionID"] && order.OrderRef == (string)row["OrderRef"]) { return true; } else { return false; } })); })); }
protected override void ProcessBusinessResponse(CTPStockResponseType responseType, IntPtr pData, CTPResponseInfo rspInfo, int requestID) { switch (responseType) { #region 当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 case CTPStockResponseType.FrontConnectedResponse: { this.isConnect = true; this.UserLogin(); //调用事件 OnEventHandler(CTPStockResponseType.FrontConnectedResponse, new CTPEventArgs()); break; } #endregion #region 用户登录 case CTPStockResponseType.UserLoginResponse: { CTPEventArgs<CZQThostFtdcRspUserLoginField> args = CreateEventArgs<CZQThostFtdcRspUserLoginField>(requestID, rspInfo); this.isLogin = true; this.OnEventHandler(CTPStockResponseType.UserLoginResponse, args); } break; #endregion case CTPStockResponseType.DepthMarketDataResponse: { if (this == null || this.isDispose == true) { return; } CTPEventArgs<CZQThostFtdcDepthMarketDataField> args = CreateEventArgs<CZQThostFtdcDepthMarketDataField>(pData, rspInfo); OnEventHandler(CTPStockResponseType.DepthMarketDataResponse, args); break; } case CTPStockResponseType.ErrorResponse: { CTPEventArgs args = new CTPEventArgs(rspInfo); OnEventHandler(CTPStockResponseType.ErrorResponse, args); break; } } }
void trader_QueryInvestorResponse(object sender, CTPEventArgs<CThostFtdcInvestorField> e) { PrintObject(e.Value, true); }
void trader_ErrorReturnOrderInsertResponse(object sender, CTPEventArgs<CThostFtdcInputOrderField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idOrderDataGridView, e.Value, new Func<DataRow, object, bool>( (DataRow row, object obj) => { CThostFtdcInputOrderField order = (CThostFtdcInputOrderField)obj; if (order.OrderRef == (string)row["OrderRef"]) { return true; } else { return false; } })); })); }
void trader_OrderInsertResponse(object sender, CTPEventArgs<CThostFtdcInputOrderField> e) { ShowMessage(e.ResponseInfo.Message); PrintObject(e.Value); }
void trader_QueryExchangeResponse(object sender, CTPEventArgs <CTPExchange> e) { PrintObject(e.Value); }
void trader_ReturnInstrumentStatusResponse(object sender, CTPEventArgs <CThostFtdcInstrumentStatusField> e) { PrintObject(e.Value, true); }
void trader_QueryInvestorResponse(object sender, CTPEventArgs <CThostFtdcInvestorField> e) { PrintObject(e.Value, true); }
void trader_QueryInvestorPositionResponse(object sender, CTPEventArgs <List <CThostFtdcInvestorPositionField> > e) { PrintObjectList(e.Value); //BindObjectList(idPositionDetailDataGridView, e.Value); }
void trader_QueryOrderResponse(object sender, CTPEventArgs <List <CThostFtdcOrderField> > e) { PrintObjectList(e.Value); BindObjectList(idOrderDataGridView, e.Value); }
void trader_OrderActionResponse(object sender, CTPEventArgs<CThostFtdcInputOrderActionField> e) { Debug.WriteLine(e.ResponseInfo.Message); PrintObject(e.Value); }
void trader_QueryExchangeResponse(object sender, CTPEventArgs<CTPExchange> e) { PrintObject(e.Value); }
void trader_QueryDepthMarketDataResponse(object sender, CTPEventArgs<CThostFtdcDepthMarketDataField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { this.idPriceNumericUpDown.Value = Convert.ToDecimal(e.Value.LastPrice); })); }
void trader_QueryInvestorPositionDetailResponse(object sender, CTPEventArgs<List<CThostFtdcInvestorPositionDetailField>> e) { PrintObjectList(e.Value); BindObjectList(this.idPositionDetailDataGridView, e.Value); //订阅行情 List<string> symbols = new List<string>(); //筛选持仓合约 foreach (var item in e.Value) { CTPInstrument inst = this.trader.GetInstrument(item.InstrumentID); if (inst != null) { if (symbols.Contains(inst.ID) == false) { symbols.Add(inst.ID); } } } //订阅行情 this.quote.SubscribeMarketData(symbols.ToArray()); }
void trader_QueryInstrumentResponse(object sender, CTPEventArgs<List<CTPInstrument>> e) { PrintObjectList(e.Value); BindObjectList(this.idSymbolDataGridView,e.Value); }
void trader_SettlementInfoConfirmResponse(object sender, CTPEventArgs <CThostFtdcSettlementInfoConfirmField> e) { ShowMessage("初始化完成"); }
void trader_QueryInvestorPositionResponse(object sender, CTPEventArgs<List<CThostFtdcInvestorPositionField>> e) { PrintObjectList(e.Value); //BindObjectList(idPositionDetailDataGridView, e.Value); }
void trader_SettlementInfoConfirmResponse(object sender, CTPEventArgs<CThostFtdcSettlementInfoConfirmField> e) { ShowMessage("初始化完成"); }
void trader_QueryTradeResponse(object sender, CTPEventArgs<List<CThostFtdcTradeField>> e) { PrintObjectList(e.Value); BindObjectList(idTradeDataGridView,e.Value); }
protected override void ProcessBusinessResponse(CTPStockResponseType 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 CTPStockResponseType.FrontConnectedResponse: { this.isConnect = true; this.UserLogin(); //调用事件 OnEventHandler(CTPStockResponseType.FrontConnectedResponse, new CTPEventArgs()); break; } #endregion #region 通信中断 case CTPStockResponseType.FrontDisconnectedResponse: /// 当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 ///@param nReason 错误原因 /// 0x1001 网络读失败 /// 0x1002 网络写失败 /// 0x2001 接收心跳超时 /// 0x2002 发送心跳失败 /// 0x2003 收到错误报文 { this.isConnect = false; //调用事件 OnEventHandler(CTPStockResponseType.FrontDisconnectedResponse, new CTPEventArgs()); } break; #endregion #region 心跳超时警告 case CTPStockResponseType.HeartBeatWarningResponse: { /// <summary> ///心跳超时警告。当长时间未收到报文时,该方法被调用。 ///@param nTimeLapse 距离上次接收报文的时间 /// </summary> /// <param name="nTimeLapse"></param> Trace.WriteLine("CTPTrader:OnHeartBeatWarning!! " + pData.ToString()); break; } #endregion #region 客户端认证响应 case CTPStockResponseType.AuthenticateResponse: { CTPEventArgs<CZQThostFtdcRspAuthenticateField> args = CreateEventArgs<CZQThostFtdcRspAuthenticateField>(requestID, rspInfo); this.OnEventHandler(CTPStockResponseType.AuthenticateResponse, args); break; } #endregion #region 用户登录 case CTPStockResponseType.UserLoginResponse: { CTPEventArgs<CZQThostFtdcRspUserLoginField> args = CreateEventArgs<CZQThostFtdcRspUserLoginField>(requestID, rspInfo); CZQThostFtdcRspUserLoginField 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.currentOrderRef = orderRef; //this.currentOrderRef++; DateTime.TryParseExact(userLogin.TradingDay, "yyyyMMdd", null, System.Globalization.DateTimeStyles.AllowWhiteSpaces, out this.tradingDate); TimeSpan.TryParse(userLogin.DCETime, out this.loginTimeDCE); TimeSpan.TryParse(userLogin.CZCETime, out this.loginTimeCZCE); TimeSpan.TryParse(userLogin.SHFETime, out this.loginTimeSHFE); //TimeSpan.TryParse(userLogin.DCETime, out this.currentTimeDCE); this.wallTimeStopwatch.Start(); this.timer.Change(0, 1000); } this.OnEventHandler(CTPStockResponseType.UserLoginResponse, args); } break; #endregion #region 登出请求响应 case CTPStockResponseType.UserLogoutResponse: { this.isLogin = false; //调用事件 OnEventHandler(CTPStockResponseType.UserLogoutResponse, new CTPEventArgs()); break; } #endregion #region 用户口令更新请求响应 case CTPStockResponseType.UserPasswordUpdateResponse: /// <summary> /// 用户口令更新请求响应 /// </summary> { CTPEventArgs<CZQThostFtdcUserPasswordUpdateField> args = CreateEventArgs<CZQThostFtdcUserPasswordUpdateField>(requestID, rspInfo); this.OnEventHandler(CTPStockResponseType.UserPasswordUpdateResponse, args); break; } #endregion #region 报单录入请求响应 case CTPStockResponseType.OrderInsertResponse: { CTPEventArgs<CZQThostFtdcInputOrderField> args = CreateEventArgs<CZQThostFtdcInputOrderField>(requestID, rspInfo); //调用事件 OnEventHandler(CTPStockResponseType.OrderInsertResponse, args); break; } #endregion #region 改单响应 case CTPStockResponseType.OrderActionResponse: { CTPEventArgs<CZQThostFtdcInputOrderActionField> args = CreateEventArgs<CZQThostFtdcInputOrderActionField>(requestID, rspInfo); //调用事件 OnEventHandler(CTPStockResponseType.OrderActionResponse, args); break; } #endregion #region 查询最大报单数量响应 case CTPStockResponseType.QueryMaxOrderVolumeResponse: { CTPEventArgs<CZQThostFtdcQueryMaxOrderVolumeField> args = CreateEventArgs<CZQThostFtdcQueryMaxOrderVolumeField>(requestID, rspInfo); this.OnEventHandler(CTPStockResponseType.QueryMaxOrderVolumeResponse, args); break; } #endregion #region 查询报单响应 case CTPStockResponseType.QueryOrderResponse: { CTPEventArgs<List<CZQThostFtdcOrderField>> args = CreateListEventArgs<CZQThostFtdcOrderField>(requestID, rspInfo); lock (this.OrderList) { this.OrderList.Clear(); this.OrderList.AddRange(args.Value); } //调用事件 OnEventHandler(CTPStockResponseType.QueryOrderResponse, args); break; } #endregion #region 查询成交单响应 case CTPStockResponseType.QueryTradeResponse: { CTPEventArgs<List<CZQThostFtdcTradeField>> args = CreateListEventArgs<CZQThostFtdcTradeField>(requestID, rspInfo); this.TradeList = args.Value; //调用事件 OnEventHandler(CTPStockResponseType.QueryTradeResponse, args); break; } #endregion #region 查询投资者持仓响应 case CTPStockResponseType.QueryInvestorPositionResponse: { CTPEventArgs<List<CZQThostFtdcInvestorPositionField>> args = CreateListEventArgs<CZQThostFtdcInvestorPositionField>(requestID, rspInfo); this.PositionList = args.Value; //调用事件 OnEventHandler(CTPStockResponseType.QueryInvestorPositionResponse, args); break; } #endregion #region 查询资金账户响应 case CTPStockResponseType.QueryTradingAccountResponse: { /// 查询资金账户响应 CTPEventArgs<CZQThostFtdcTradingAccountField> args = CreateEventArgs<CZQThostFtdcTradingAccountField>(requestID, rspInfo); this.tradingAccount = args.Value; this.OnEventHandler(CTPStockResponseType.QueryTradingAccountResponse, args); break; } #endregion #region 查询投资者响应 case CTPStockResponseType.QueryInvestorResponse: { CTPEventArgs<CZQThostFtdcInvestorField> args = CreateEventArgs<CZQThostFtdcInvestorField>(requestID, rspInfo); this.investor = args.Value; this.OnEventHandler(CTPStockResponseType.QueryInvestorResponse, args); break; } #endregion #region 请求查询交易编码响应 case CTPStockResponseType.QueryTradingCodeResponse: { CTPEventArgs<CZQThostFtdcTradingCodeField> args = CreateEventArgs<CZQThostFtdcTradingCodeField>(requestID, rspInfo); this.OnEventHandler(CTPStockResponseType.QueryTradingCodeResponse, args); break; } #endregion #region 查询手续费响应 case CTPStockResponseType.QueryInstrumentCommissionRateResponse: { CTPEventArgs<CZQThostFtdcInstrumentCommissionRateField> args = CreateEventArgs<CZQThostFtdcInstrumentCommissionRateField>(requestID, rspInfo); this.SetInstrumentRate(args.Value); //调用事件 OnEventHandler(CTPStockResponseType.QueryInstrumentCommissionRateResponse, args); break; } #endregion #region 查询交易所响应 case CTPStockResponseType.QueryExchangeResponse: { CTPEventArgs<CZQThostFtdcExchangeField> args = CreateEventArgs<CZQThostFtdcExchangeField>(requestID, rspInfo); //保存市场信息 //CTPExchange ctpExchange = new CTPExchange(); //ctpExchange.SetNativeValue(args.Value); //this.Exchanges.Add(args.Value.ExchangeID, ctpExchange); //调用事件 OnEventHandler(CTPStockResponseType.QueryExchangeResponse, args); break; } #endregion #region 查询合约响应 case CTPStockResponseType.QueryInstrumentResponse: { CTPEventArgs<List<CZQThostFtdcInstrumentField>> values = CreateListEventArgs<CZQThostFtdcInstrumentField>(requestID, rspInfo); foreach (var instrument in values.Value) { if (instrument.ProductClass == CTPStockProductClassType.EFP || instrument.ProductClass == CTPStockProductClassType.Futures || instrument.ProductClass == CTPStockProductClassType.Options) { continue; } CTPStockInstrument ctpInstrument = new CTPStockInstrument(); 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<CTPStockInstrument> list = new List<CTPStockInstrument>(this.InstrumentDictionary.Values); CTPEventArgs<List<CTPStockInstrument>> args = new CTPEventArgs<List<CTPStockInstrument>>(list); //调用事件 //OnEventHandler(CTPStockResponseType.QueryInstrumentResponse, args); OnEventHandler(CTPStockResponseType.QueryInstrumentResponse, values); break; } #endregion #region 查询行情响应 case CTPStockResponseType.QueryDepthMarketDataResponse: { CTPEventArgs<CZQThostFtdcDepthMarketDataField> args = CreateEventArgs<CZQThostFtdcDepthMarketDataField>(requestID, rspInfo); //调用事件 OnEventHandler(CTPStockResponseType.QueryDepthMarketDataResponse, args); break; } #endregion #region 查询投资者持仓明细响应 case CTPStockResponseType.QueryInvestorPositionDetailResponse: { CTPEventArgs<List<CZQThostFtdcInvestorPositionDetailField>> args = CreateListEventArgs<CZQThostFtdcInvestorPositionDetailField>(requestID, rspInfo); this.PositionDetailList = args.Value; //调用事件 OnEventHandler(CTPStockResponseType.QueryInvestorPositionDetailResponse, args); break; } #endregion #region 错误回报 case CTPStockResponseType.ErrorResponse: { this.OnEventHandler(CTPStockResponseType.ErrorResponse, new CTPEventArgs(rspInfo)); break; } #endregion #region 报单回报 case CTPStockResponseType.ReturnOrderResponse: { CTPEventArgs<CZQThostFtdcOrderField> args = CreateEventArgs<CZQThostFtdcOrderField>(pData, rspInfo); lock (this.orderList) { CTPStockOrderConvert.AppendOrReplaceOrder(this.orderList, args.Value); } if (this.filterRestart == true && this.isInitialized == false) { } else { //调用事件 OnEventHandler(CTPStockResponseType.ReturnOrderResponse, args); } break; } #endregion #region 成交回报 case CTPStockResponseType.ReturnTradeResponse: { CTPEventArgs<CZQThostFtdcTradeField> args = CreateEventArgs<CZQThostFtdcTradeField>(pData, rspInfo); //插入到列表中 CTPStockOrderConvert.AppendOrReplaceOrder(this.tradeList, args.Value); if (this.filterRestart == true && this.isInitialized == false) { } else { //调用事件 OnEventHandler(CTPStockResponseType.ReturnTradeResponse, args); } break; } #endregion #region 错单回报 case CTPStockResponseType.ErrorReturnOrderInsertResponse: { if (this.filterRestart == true && this.isInitialized == false) { } else { CTPEventArgs<CZQThostFtdcInputOrderField> args = CreateEventArgs<CZQThostFtdcInputOrderField>(pData, rspInfo); //调用事件 OnEventHandler(CTPStockResponseType.ErrorReturnOrderInsertResponse, args); } break; } #endregion #region 报单操作错误回报 case CTPStockResponseType.ErrorReturnOrderActionResponse: { if (this.filterRestart == true && this.isInitialized == false) { } else { CTPEventArgs<CZQThostFtdcOrderActionField> args = CreateEventArgs<CZQThostFtdcOrderActionField>(pData, rspInfo); //调用事件 OnEventHandler(CTPStockResponseType.ErrorReturnOrderActionResponse, args); } break; } #endregion #region 合约交易状态通知 case CTPStockResponseType.ReturnInstrumentStatusResponse: { CTPEventArgs<CZQThostFtdcInstrumentStatusField> args = CreateEventArgs<CZQThostFtdcInstrumentStatusField>(pData, rspInfo); CZQThostFtdcInstrumentStatusField instrumentStatus = args.Value; Trace.WriteLine(string.Format("{0}:{1}", instrumentStatus.ExchangeID, instrumentStatus.InstrumentStatus)); //交易所状态 if (this.exchangeStatus.ContainsKey(instrumentStatus.ExchangeID) == false) { this.exchangeStatus.Add(instrumentStatus.ExchangeID, instrumentStatus.InstrumentStatus); } //更新交易所状态 this.exchangeStatus[instrumentStatus.ExchangeID] = instrumentStatus.InstrumentStatus; this.tradingStatus = instrumentStatus.InstrumentStatus; //调用事件 OnEventHandler(CTPStockResponseType.ReturnInstrumentStatusResponse, args); break; } #endregion default: break; } }
void trader_ReturnInstrumentStatusResponse(object sender, CTPEventArgs<CThostFtdcInstrumentStatusField> e) { PrintObject(e.Value,true); }
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; } }
void trader_ReturnTradeResponse(object sender, CTPEventArgs<CThostFtdcTradeField> e) { PrintObject(e.Value); this.Invoke(new Action(() => { UpdateBindTable(this.idTradeDataGridView, e.Value); })); }
void trader_OrderActionResponse(object sender, CTPEventArgs <CThostFtdcInputOrderActionField> e) { Debug.WriteLine(e.ResponseInfo.Message); PrintObject(e.Value); }
void trader_UserLoginResponse(object sender, CTPEventArgs<CThostFtdcRspUserLoginField> e) { if (e.ResponseInfo.ErrorID != 0) { Debug.Write(e.ResponseInfo.Message); ShowMessage(e.ResponseInfo.Message); } PrintObject(e.Value); }
void trader_QueryInstrumentResponse(object sender, CTPEventArgs<List<CTPInstrument>> e) { PrintObjectList(e.Value); BindObjectList(this.idSymbolDataGridView,e.Value); //添加合约到下拉列表 this.Invoke(new Action(() => { string[] symbols = (from s in e.Value orderby s.ID select s.ID).ToArray(); this.idSymbolCodeComboBox.Items.Clear(); this.idSymbolCodeComboBox.Items.AddRange(symbols); this.idSymbolCodeComboBox.AutoCompleteCustomSource.Clear(); this.idSymbolCodeComboBox.AutoCompleteCustomSource.AddRange(symbols); })); }