예제 #1
0
        void RegisterTraderResponseHandler(CTPTrader trader)
        {
            //注册事件处理函数
              trader.UserLoginResponse += new EventHandler<CTPEventArgs<CThostFtdcRspUserLoginField>>(trader_UserLoginResponse);
              trader.QueryExchangeResponse += new EventHandler<CTPEventArgs<CTPExchange>>(trader_QueryExchangeResponse);
              trader.QueryInstrumentResponse += new EventHandler<CTPEventArgs<List<CTPInstrument>>>(trader_QueryInstrumentResponse);

              trader.QueryInvestorResponse += new EventHandler<CTPEventArgs<CThostFtdcInvestorField>>(trader_QueryInvestorResponse);
              trader.QueryTradingAccountResponse += new EventHandler<CTPEventArgs<CThostFtdcTradingAccountField>>(trader_QueryTradingAccountResponse);
              trader.QueryInvestorPositionResponse += new EventHandler<CTPEventArgs<List<CThostFtdcInvestorPositionField>>>(trader_QueryInvestorPositionResponse);
              trader.QueryInvestorPositionDetailResponse += new EventHandler<CTPEventArgs<List<CThostFtdcInvestorPositionDetailField>>>(trader_QueryInvestorPositionDetailResponse);
              trader.QueryOrderResponse += new EventHandler<CTPEventArgs<List<CThostFtdcOrderField>>>(trader_QueryOrderResponse);
              trader.QueryTradeResponse += new EventHandler<CTPEventArgs<List<CThostFtdcTradeField>>>(trader_QueryTradeResponse);

              trader.OrderInsertResponse += new EventHandler<CTPEventArgs<CThostFtdcInputOrderField>>(trader_OrderInsertResponse);
              trader.OrderActionResponse += new EventHandler<CTPEventArgs<CThostFtdcInputOrderActionField>>(trader_OrderActionResponse);
              trader.ErrorReturnOrderInsertResponse += new EventHandler<CTPEventArgs<CThostFtdcInputOrderField>>(trader_ErrorReturnOrderInsertResponse);
              trader.ReturnOrderResponse += new EventHandler<CTPEventArgs<CThostFtdcOrderField>>(trader_ReturnOrderResponse);
              trader.ReturnTradeResponse += new EventHandler<CTPEventArgs<CThostFtdcTradeField>>(trader_ReturnTradeResponse);

              trader.ReturnInstrumentStatusResponse += new EventHandler<CTPEventArgs<CThostFtdcInstrumentStatusField>>(trader_ReturnInstrumentStatusResponse);
              trader.QueryDepthMarketDataResponse += new EventHandler<CTPEventArgs<CThostFtdcDepthMarketDataField>>(trader_QueryDepthMarketDataResponse);

              trader.SettlementInfoConfirmResponse += new EventHandler<CTPEventArgs<CThostFtdcSettlementInfoConfirmField>>(trader_SettlementInfoConfirmResponse);
        }
예제 #2
0
        private void idLoginMenuItem_Click(object sender, EventArgs e)
        {
            LoginForm login = new LoginForm();

              login.TradeServerLogged += new EventHandler(
            (object s, EventArgs args) =>
            {
              //可增加其他监听处理
              //比如多账户:traderList.Add(s as CTPTrader);

              //处理登录成功事件
              ShowMessage("交易账户登录成功,开始初始化信息...");

              CTPTrader trader = s as CTPTrader;

              RegisterTraderResponseHandler(trader);

              trader.QueryInstrument();
              trader.QueryOrder();
              trader.QueryTrade();
              trader.QueryInvestorPositionDetail();
              trader.QueryTradingAccount();
              //确认结算单
              trader.SettlementInfoConfirm();
            });

              if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK)
              {

            this.trader = login.Trader;
            this.quote = login.Quote;

            RegisterQuoteResponseHandler(this.quote);

              }
        }