Exemplo n.º 1
0
        public void Connect(ServerItem server, AccountItem account)
        {
            tempPath = System.IO.Path.GetTempPath() + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(tempPath);

            Disconnect_MD();

            Connect_MsgQueue();
            Connect_MD();
        }
Exemplo n.º 2
0
        public void Connect(ServerItem server, AccountItem account)
        {
            tempPath = Framework.Installation.TempDir.FullName + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(tempPath);

            Disconnect_MD();

            Connect_MsgQueue();
            Connect_MD();
        }
Exemplo n.º 3
0
        public void Connect(ServerItem server, AccountItem account,THOST_TE_RESUME_TYPE resumeType)
        {
            tempPath = System.IO.Path.GetTempPath() + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(tempPath);
            ResumeType = resumeType;

            Disconnect_TD();

            Connect_MsgQueue();
            Connect_TD();
        }
Exemplo n.º 4
0
        public void Connect(ServerItem server, AccountItem account, THOST_TE_RESUME_TYPE resumeType)
        {
            tempPath = Framework.Installation.TempDir.FullName + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(tempPath);
            ResumeType = resumeType;

            Disconnect_TD();

            Connect_MsgQueue();
            Connect_TD();
        }
Exemplo n.º 5
0
        public void Connect(ServerItem server, AccountItem account,THOST_TE_RESUME_TYPE resumeType)
        {
            tempPath = Framework.Installation.TempDir.FullName + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(tempPath);
            ResumeType = resumeType;

            Disconnect_TD();

            Connect_MsgQueue();
            Connect_TD();
        }
Exemplo n.º 6
0
 void LoadAccounts()
 {
     try
     {
         var accounts = from c in XElement.Load(accountsFile).Elements("Account")
                        select c;
         foreach (var account in accounts)
         {
             AccountItem ai = new AccountItem();
             ai.Label      = account.Attribute("Label").Value;
             ai.InvestorId = account.Attribute("InvestorId").Value;
             ai.Password   = account.Attribute("Password").Value;
             accountsList.Add(ai);
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 7
0
        private void _Connect()
        {
            server = null;
            account = null;

            bool bCheckOk = false;

            do
            {
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置 服务器 信息,目前只选择第一条进行连接");
                    break;
                }
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置 账号 信息,目前只选择第一条进行连接");
                    break;
                }

                server = serversList[0];
                account = accountsList[0];

                if (string.IsNullOrEmpty(server.BrokerID)
                || 0 == server.Trading.Count()
                || 0 == server.MarketData.Count())
                {
                    MessageBox.Show("服务器信息不全");
                    break;
                }

                if (string.IsNullOrEmpty(account.InvestorId)
                || string.IsNullOrEmpty(account.Password))
                {
                    MessageBox.Show("账号信息不全");
                    break;
                }

                bCheckOk = true;

            } while (false);

            if (false == bCheckOk)
            {
                ChangeStatus(ProviderStatus.Disconnected);
                EmitDisconnectedEvent();
                return;
            }

            //新建目录
            _newTempPath = ApiTempPath + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(_newTempPath);

            ChangeStatus(ProviderStatus.Connecting);
            //如果前面一次连接一直连不上,新改地址后也会没响应,所以先删除
            Disconnect_MD();
            Disconnect_TD();

            Connect_MsgQueue();
            if (_bWantMdConnect)
            {
                Connect_MD();
            }
            if (_bWantTdConnect)
            {
                Connect_TD();
            }

            if (_bWantMdConnect||_bWantTdConnect)
            {
                //建立消息队列读取线程
                if (null == _thread)
                {
                    _runThread = true;
                    _thread = new Thread(new ThreadStart(ThreadProc));
                    _thread.Start();
                }
            }
        }
Exemplo n.º 8
0
        private void _Connect()
        {
            CTPAPI.GetInstance().__RegInstrumentDictionary(_dictInstruments);
            CTPAPI.GetInstance().__RegInstrumentCommissionRateDictionary(_dictCommissionRate);
            CTPAPI.GetInstance().__RegInstrumentMarginRateDictionary(_dictMarginRate);
            CTPAPI.GetInstance().__RegDepthMarketDataDictionary(_dictDepthMarketData);

            server = null;
            account = null;

            bool bCheckOk = false;

            do
            {
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置 服务器 信息,目前只选择第一条进行连接");
                    break;
                }
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置 账号 信息,目前只选择第一条进行连接");
                    break;
                }

                server = serversList[0];
                account = accountsList[0];

                if (string.IsNullOrEmpty(server.BrokerID))
                {
                    MessageBox.Show("BrokerID不能为空");
                    break;
                }

                if (_bWantTdConnect &&0 == server.Trading.Count())
                {
                    MessageBox.Show("交易服务器地址不全");
                    break;
                }

                if (_bWantMdConnect &&0 == server.MarketData.Count())
                {
                    MessageBox.Show("行情服务器信息不全");
                    break;
                }

                if (string.IsNullOrEmpty(account.InvestorId)
                || string.IsNullOrEmpty(account.Password))
                {
                    MessageBox.Show("账号信息不全");
                    break;
                }

                bCheckOk = true;

            } while (false);

            if (false == bCheckOk)
            {
                ChangeStatus(ProviderStatus.Disconnected);
                isConnected = false;
                return;
            }

            //新建目录
            _newTempPath = ApiTempPath + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(_newTempPath);

            ChangeStatus(ProviderStatus.Connecting);
            //如果前面一次连接一直连不上,新改地址后也会没响应,所以先删除
            Disconnect_MD();
            Disconnect_TD();

            if (_bWantMdConnect || _bWantTdConnect)
            {
                timerDisconnect.Enabled = true;
                timerAccount.Enabled = true;
                timerPonstion.Enabled = true;
                Connect_MsgQueue();
            }
            if (_bWantMdConnect)
            {
                Connect_MD();
            }
            if (_bWantTdConnect)
            {
                Connect_TD();
            }
        }
Exemplo n.º 9
0
 void LoadAccounts()
 {
     try
     {
         var accounts = from c in XElement.Load(accountsFile).Elements("Account")
                        select c;
         foreach (var account in accounts)
         {
             AccountItem ai = new AccountItem();
             ai.Label = account.Attribute("Label").Value;
             ai.InvestorId = account.Attribute("InvestorId").Value;
             ai.Password = account.Attribute("Password").Value;
             accountsList.Add(ai);
         }
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 10
0
        private void _Connect()
        {
            server  = null;
            account = null;

            bool bCheckOk = false;

            do
            {
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置服务器信息,目前只选择第一条进行连接");
                    break;
                }
                if (0 == serversList.Count)
                {
                    MessageBox.Show("您还没有设置账号信息,目前只选择第一条进行连接");
                    break;
                }

                server  = serversList[0];
                account = accountsList[0];

                if (string.IsNullOrEmpty(server.BrokerID) ||
                    0 == server.Trading.Count() ||
                    0 == server.MarketData.Count())
                {
                    MessageBox.Show("服务器信息不全");
                    break;
                }

                if (string.IsNullOrEmpty(account.InvestorId) ||
                    string.IsNullOrEmpty(account.Password))
                {
                    MessageBox.Show("账号信息不全");
                    break;
                }

                bCheckOk = true;
            } while (false);

            if (false == bCheckOk)
            {
                ChangeStatus(ProviderStatus.Disconnected);
                EmitDisconnectedEvent();
                return;
            }

            _bWantMdConnect = true;
            _bWantTdConnect = true;

            //新建目录
            _newTempPath = ApiTempPath + Path.DirectorySeparatorChar + server.BrokerID + Path.DirectorySeparatorChar + account.InvestorId;
            Directory.CreateDirectory(_newTempPath);

            ChangeStatus(ProviderStatus.Connecting);
            //如果前面一次连接一直连不上,新改地址后也会没响应,所以先删除
            Disconnect_MD();
            Disconnect_TD();

            Connect_MsgQueue();
            Connect_MD();
            Connect_TD();

            //建立消息队列读取线程
            if (null == _thread)
            {
                _runThread = true;
                _thread    = new Thread(new ThreadStart(ThreadProc));
                _thread.Start();
            }
        }