protected override void OnLoad(EventArgs e) { base.OnLoad(e); callbackUpdateComboboxInstrument += new CallbackUpdateComboboxInstrument(UpdateComboboxInstrument); callbackUpdateDelegate += new CallbackUpdateDelegate(FillDelegateDataGrid); callbackUpdateTradeData += new CallbackUpdateTradeData(FillTradeDataGrid); LoginWin loginWin = new LoginWin(this); Init(loginWin); DialogResult result = loginWin.ShowDialog(); if (result == DialogResult.Cancel) { this.Close(); } //DataSet ds = GetMarkDataInfo2Client(); //FillMarketDataGrid(ds.Tables["MarketData"]); DataSet ds3 = GetDelegateInfo2Client(); FillDelegateDataGrid(ds3.Tables["Delegate"]); DataSet ds4 = GetTradeInfo2Client(); FillTradeDataGrid(ds4.Tables["Trade"]); //DataSet ds5 = GetFundInfo2Client(); //FillFundDataGrid(ds5.Tables["Fund"]); //明细 //SecurityFtdcQryInvestorPositionDetailField positionField = new SecurityFtdcQryInvestorPositionDetailField(); //positionField.BrokerID = SysConst.BrokerID; //positionField.InstrumentID = "000002"; //positionField.InvestorID = SysConst.User.UserID; //int r = SysConst.TraderApi.ReqQryInvestorPositionDetail(positionField, SysConst.GetRequestID()); //SubscribeMarketData(); // FillMarketDataGrid(new DataTable()); //MarketDataTimer.Enabled = true; //MarketDataTimer.Start(); }
/// <summary> /// 初始化API /// </summary> /// <param name="loginWin"></param> public void Init(LoginWin loginWin) { if (SysConst.TraderApi == null) { SysConst.TraderApi = new LTSTraderAdapter(); SysConst.MarketDataApi = new LTSMDAdapter(); try { SysConst.TraderApi.OnFrontConnected += new FrontConnected(OnFrontConnected); SysConst.TraderApi.OnRspUserLogin += new RspUserLogin(loginWin.OnRspUserLogin); ///客户持仓信息 SysConst.TraderApi.OnRspQryInvestorPosition += new RspQryInvestorPosition(OnRspQryInvestorPosition); //资金信息 SysConst.TraderApi.OnRspQryTradingAccount += new RspQryTradingAccount(OnRspQryTradingAccount); //合约信息 SysConst.TraderApi.OnRspQryInstrument += new RspQryInstrument(OnRspQryInstrument); SysConst.TraderApi.OnRspOrderInsert += new RspOrderInsert(OnRspOrderInsert); SysConst.TraderApi.OnRtnOrder += new RtnOrder(OnRtnOrder); SysConst.TraderApi.OnRtnTrade += new RtnTrade(OnRtnTrade); // 注册一事件处理的实例 //m_pTdApi->RegisterSpi(this); // 订阅私有流 // TERT_RESTART:从本交易日开始重传 // TERT_RESUME:从上次收到的续传 // TERT_QUICK:只传送登录后私有流的内容 SysConst.TraderApi.SubscribePrivateTopic(EnumRESUMETYPE.TERT_RESTART); // 订阅公共流 // TERT_RESTART:从本交易日开始重传 // TERT_RESUME:从上次收到的续传 // TERT_QUICK:只传送登录后公共流的内容 SysConst.TraderApi.SubscribePublicTopic(EnumRESUMETYPE.TERT_RESTART); SysConst.TraderApi.RegisterFront(SysConst.TradeFrontAddress); SysConst.TraderApi.Init(); } catch (Exception ex) { } try { SysConst.MarketDataApi.OnFrontConnected += new FrontConnected(OnFrontConnectedMarket); SysConst.MarketDataApi.OnRspSubMarketData += new RspSubMarketData(OnRspSubMarketData); SysConst.MarketDataApi.OnRspUnSubMarketData += new RspUnSubMarketData(OnRspUnSubMarketData); SysConst.MarketDataApi.OnRtnDepthMarketData += new RtnDepthMarketData(OnRtnDepthMarketData); SysConst.MarketDataApi.OnHeartBeatWarning += new HeartBeatWarning(OnHeartBeatWarning); SysConst.MarketDataApi.OnRspError += new RspError(OnRspError); SysConst.MarketDataApi.OnRspUserLogin += new RspUserLogin(OnRspUserLogin); SysConst.MarketDataApi.RegisterFront(SysConst.MarketDataFrontAddress); SysConst.MarketDataApi.Init(); } catch (Exception ex) { } } }