private void TraderAdapter_OnRspSettlementInfoConfirm( ThostFtdcSettlementInfoConfirmField pSettlementInfoConfirm, ThostFtdcRspInfoField pRspInfo, int nRequestId, bool bIsLast) { try { if (MyUtils.IsWrongRspInfo(pRspInfo)) { MyUtils.ReportError(pRspInfo, "结算信息确认错误"); return; } if (pSettlementInfoConfirm != null) { var temp = string.Format("结算信息确认回报:经纪公司代码:{0},确认日期:{1},确认时间:{2},投资者代码:{3}", pSettlementInfoConfirm.BrokerID, pSettlementInfoConfirm.ConfirmDate, pSettlementInfoConfirm.ConfirmTime, pSettlementInfoConfirm.InvestorID); } if (bIsLast) { Thread.Sleep(1000); ReqQryAllInstruments(); //查询所有合约 } } catch (Exception ex) { MessageBox.Show("结算确认发生异常,异常信息:" + ex.Message); } }
private void TraderAdapter_OnRspQryInstrument(ThostFtdcInstrumentField pInstrument, ThostFtdcRspInfoField pRspInfo, int nRequestId, bool bIsLast) { try { if (MyUtils.IsWrongRspInfo(pRspInfo)) { MyUtils.ReportError(pRspInfo, "查询合约错误"); return; } if (pInstrument != null) { if (!pInstrument.InstrumentID.Contains("efp") && !pInstrument.InstrumentID.Contains("eof")) { if (pInstrument.InstrumentID.Contains("&")) { //套利合约 MyUtils.ComboInstrumentInfo[pInstrument.InstrumentID] = pInstrument; } else { //标准 MyUtils.StandardInstrumentInfo[pInstrument.InstrumentID] = pInstrument; } MyUtils.CategoryToExchangeId[MyUtils.GetInstrumentCategory(pInstrument.InstrumentID)] = pInstrument.ExchangeID; var temp = string.Format( "查询合约回报: 创建日:{0},交割月:{1},交割年份:{2},结束交割日:{3},交易所代码:{4},合约在交易所的代码:{5},到期日:{6},合约生命周期状态:{7},合约代码:{8},合约名称:{9},当前是否交易:{10},多头保证金率:{11},限价单最大下单量:{12},市价单最大下单量:{13},限价单最小下单量:{14},市价单最小下单量:{15},上市日:{16},持仓日期类型:{17},持仓类型:{18},最小变动价位:{19},产品类型:{20},产品代码:{21},空头保证金率:{22},开始交割日:{23},合约数量乘数:{24}", pInstrument.CreateDate, pInstrument.DeliveryMonth, pInstrument.DeliveryYear, pInstrument.EndDelivDate, pInstrument.ExchangeID, pInstrument.ExchangeInstID, pInstrument.ExpireDate, pInstrument.InstLifePhase, pInstrument.InstrumentID, pInstrument.InstrumentName, pInstrument.IsTrading, pInstrument.LongMarginRatio, pInstrument.MaxLimitOrderVolume, pInstrument.MaxMarketOrderVolume, pInstrument.MinLimitOrderVolume, pInstrument.MinMarketOrderVolume, pInstrument.OpenDate, pInstrument.PositionDateType, pInstrument.PositionType, pInstrument.PriceTick, pInstrument.ProductClass, pInstrument.ProductID, pInstrument.ShortMarginRatio, pInstrument.StartDelivDate, pInstrument.VolumeMultiple); } } if (bIsLast) { Thread.Sleep(1000); ReqQryTradingAccount(); } } catch (Exception ex) { MessageBox.Show("查询合约出错:" + ex.Message); } }
private void TraderAdapter_OnRspUserLogin(ThostFtdcRspUserLoginField pRspUserLogin, ThostFtdcRspInfoField pRspInfo, int nRequestId, bool bIsLast) { try { if (MyUtils.IsWrongRspInfo(pRspInfo)) { MyUtils.ReportError(pRspInfo, "登录回报错误"); return; } if (bIsLast) { var temp = string.Format( "登录回报:经纪公司代码:{0},郑商所时间:{1},大商所时间:{2},中金所时间:{3},前置编号:{4},登录成功时间:{5},最大报单引用:{6},会话编号:{7},上期所时间:{8},交易系统名称:{9},交易日:{10},用户代码:{11}", pRspUserLogin.BrokerID, pRspUserLogin.CZCETime, pRspUserLogin.DCETime, pRspUserLogin.FFEXTime, pRspUserLogin.FrontID, pRspUserLogin.LoginTime, pRspUserLogin.MaxOrderRef, pRspUserLogin.SessionID, pRspUserLogin.SHFETime, pRspUserLogin.SystemName, pRspUserLogin.TradingDay, pRspUserLogin.UserID); _frontId = pRspUserLogin.FrontID; _sessionId = pRspUserLogin.SessionID; _tradingDay = pRspUserLogin.TradingDay; if (string.IsNullOrEmpty(pRspUserLogin.MaxOrderRef)) { CurrentOrderRef = 0; } else { CurrentOrderRef = Convert.ToInt32(pRspUserLogin.MaxOrderRef); } //比较交易所时间和本地时间的偏移值 DateTime shfeTime; try { shfeTime = Convert.ToDateTime(pRspUserLogin.SHFETime); } catch (Exception) { try { shfeTime = Convert.ToDateTime(pRspUserLogin.CZCETime); } catch (Exception) { try { shfeTime = Convert.ToDateTime(pRspUserLogin.DCETime); } catch (Exception) { throw new Exception("交易所时间格式不正确"); } } } MyUtils.ExchangeTimeOffset = ExchangeTime.Instance.GetSecFromDateTime(shfeTime) - ExchangeTime.Instance.GetSecFromDateTime(DateTime.Now); Thread.Sleep(1000); ReqSettlementInfoConfirm(); //结算确认 MyUtils.IsTraderReady = true; } else { MessageBox.Show("登录失败"); return; } } catch (Exception ex) { MessageBox.Show("登录失败," + ex.Message); } }