Example #1
0
        private void btnGetAccountsList_Click(object sender, EventArgs e)
        {
            var msgFactory = new OpenApiMessagesFactory();
            var msg        = msgFactory.CreateAccountListRequest(_token);

            Transmit(msg);

            while (_accounts == null)
            {
                Thread.Sleep(100);
            }
            _traders = new List <ProtoOATrader>();
            foreach (var account in _accounts)
            {
                if (!account.IsLive)
                {
                    var authMsg = msgFactory.CreateAccAuthorizationRequest(_token, (long)account.CtidTraderAccountId);
                    Transmit(authMsg);
                    Thread.Sleep(500);
                    var traderMsg = msgFactory.CreateTraderRequest((long)account.CtidTraderAccountId);
                    Transmit(traderMsg);
                }
            }
            Thread.Sleep(1000);
            foreach (var trader in _traders)
            {
                cbAccounts.Items.Add(trader.CtidTraderAccountId);
            }
            _accounts = null;
        }
Example #2
0
        private void BeginConnection()
        {
            //if account id is not loaded from saved then get account list - then go to load symbols
            foreach (UserConfig userConfig in Users.Values)
            {
                //create a queue of ticks to write as they are recieved
                _ticksToWrite.Add(userConfig.Token, new Queue <TickData>());

                if (userConfig.AccountId == 0)
                {
                    MessageHandler?.Invoke("Retrieving account id.");

                    //this will get all accountID's for the current Token (the token is related to a trading account that has authorised this app)
                    var msgFactory = new OpenApiMessagesFactory();
                    _trasmitQueue.Enqueue(msgFactory.CreateAccountListRequest(userConfig.Token));
                }
                else //otherwise go direct to GetSymbols
                {
                    AuthAccount(userConfig.Token);
                }
            }
        }