Beispiel #1
0
        private unsafe void CTPOnRspUserLogin(ref CThostFtdcRspUserLoginField pRspUserLogin, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            //Console.WriteLine("on CTPOnRspUserLogin    result");

            //Console.WriteLine("CThostFtdcRspUserLoginField    {0}", Marshal.SizeOf(pRspUserLogin));
            //Console.WriteLine("CThostFtdcRspInfoField    {0}", Marshal.SizeOf(pRspInfo));

            //避免登录错误后不断重连
            if (pRspInfo.ErrorID != 0)
            {
                _t.SetOnFrontDisconnected(null);
            }
            //else //正常登录时注册连接事件(后续自动重连时可自行登录)
            //_t.SetOnFrontConnected(CTPOnFrontConnected);

            if (pRspInfo.ErrorID == 0)
            {
                //IsLogin = true; //position中完成
                this.TradingDay = pRspUserLogin.TradingDay; // Marshal.PtrToStringAnsi(_t.GetTradingDay());
                _session        = pRspUserLogin.SessionID;
                _front          = pRspUserLogin.FrontID;
                //_orderref = pRspUserLogin.MaxOrderRef;
                _broker   = pRspUserLogin.BrokerID;
                _investor = pRspUserLogin.UserID;

                //Console.WriteLine("_session: " + _session);
                //Console.WriteLine("_front: " + _front);
                //Console.WriteLine("_broker: " + _broker);
                //Console.WriteLine("_investor: " + _investor);
                //Console.WriteLine("_session: " + _session);
                //Console.WriteLine("TradingDay: " + TradingDay);

                //Console.WriteLine("ErrorMsg" + pRspInfo.ErrorMsg);

                _t.ReqSettlementInfoConfirm(_broker, _investor);
                // _t.ReqQryInstrument();
            }
            else
            {
                _OnRspUserLogin?.Invoke(this, new IntEventArgs {
                    Value = pRspInfo.ErrorID
                });
            }
        }