Пример #1
0
 private void LoginQuote(string[] front, string _Broker, string _Investor, string _Password)
 {
     if (_q != null)
     {
         if (_q.IsLogin)
         {
             _q.ReqUserLogout();
         }
         _q = null;
     }
     _q = new QuoteExt
     {
         Broker   = _Broker,
         Investor = _Investor,
         Password = _Password,
     };
     _q.OnFrontConnected += quote_OnFrontConnected;
     _q.OnRspUserLogin   += quote_OnRspUserLogin;
     _q.OnRspUserLogout  += quote_OnRspUserLogout;
     _q.OnRtnTick        += quote_OnRtnTick;
     _q.ReqConnect(front);
 }
Пример #2
0
        //登录响应
        private void RspLogin(object sender, ErrorEventArgs e)
        {
            var t = (Trade)sender;

            ShowMsg($"[{_investor}]登录:{e.ErrorID}=={e.ErrorMsg}");

            if (e.ErrorID == 140)
            {
                _t.ReqUserPasswordUpdate(_t.Password, "Hf123456");
            }
            if (e.ErrorID == 0)
            {
                this.Invoke(new Action(() =>
                {
                    foreach (var posi in _t.DicPositionField.Values)
                    {
                        _bsPosi.Add(posi);
                    }
                }));
                FutureBroker svr = (this.comboBoxServer.DataSource as BindingSource).Current as FutureBroker;

                if (svr == null)
                {
                    ShowMsg("前置配置为空无法登录行情");
                    return;
                }
                if (_q != null)
                {
                    _q.ReqUserLogout();
                    _q = null;
                }
                if (svr.Type == ProxyType.Tdx)
                {
                    _q = new QuoteExt(); // (Quote)Activator.CreateInstance(ass.GetType($"HaiFeng.{svr.Type}Quote"));
                                         //this.Invoke(new Action(() => this.comboBoxInstrument.Items.Add("000001")));
                }
                else
                {
                    _q = new QuoteExt();// (Quote)Activator.CreateInstance(ass.GetType($"HaiFeng.{svr.Type}Quote"));
                }
                _q.Broker    = svr.Broker;
                _q.FrontAddr = svr.QuoteAddr;
                _q.Investor  = _investor;
                _q.Password  = _password;

                _q.OnFrontConnected += (snd, ea) =>
                {
                    ShowMsg($"行情连接成功");
                    _q.ReqUserLogin();
                };
                _q.OnRspUserLogin += (snd, ea) =>
                {
                    foreach (var v in _t.DicPositionField.Values)
                    {
                        ((Quote)snd).ReqSubscribeMarketData(v.InstrumentID);
                    }
                    ShowMsg($"行情登录成功");
                    LogSucceed();
                };
                _q.OnRtnTick       += this.OnTick;
                _q.OnRspUserLogout += (snd, ea) => { ShowMsg($"[{_investor}]行情退出:{ea.Value}"); };
                _q.ReqConnect();
            }
        }