Esempio n. 1
0
        public IDictionary <string, ZAccountBalance> GetAccountBalances()
        {
            var result = new Dictionary <string, ZAccountBalance>();
            var res    = m_api.AccountsService.GetAllAccountsAsync().Result;

            foreach (var acct in res)
            {
                var bal = new ZAccountBalance(acct.Currency, acct.Available, acct.Balance - acct.Available);
                result.Add(acct.Currency, bal);
            }
            return(result);
        }
Esempio n. 2
0
        private void UpdateBalances()
        {
            while (true)
            {
                Thread.Sleep(250);

                if (m_selectedPair == null)
                {
                    continue;                           // wait until the user has selected a valid symbol pair
                }
                int row = m_updateBalanceCount % ExchangeCount;
                if (row == 1 && row % (ExchangeCount * 4) != 0)
                {
                    ++m_updateBalanceCount; continue;
                }
                if (row >= ExchangeCount)
                {
                    ++m_updateBalanceCount; continue;
                }
                string exchname = gridBalances[2, row].Value.ToString();    // TODO: let's store this when we populate the grid instead

                //if (exchname == "Bitfinex") { ++m_updateOrderCount; continue; }

                if (!m_exchanges[exchname].Exchange.HasSymbol(m_selectedPair.Symbol))
                {
                    gridBalances[0, row].Value = "";
                    gridBalances[1, row].Value = "";
                    ++m_updateBalanceCount;
                    continue;
                }

                ++m_updateBalanceCount;

                IDictionary <string, ZAccountBalance> balances = null;
                ZAccountBalance lbal = null, rbal = null;
                var             exchange = m_exchanges[exchname].Exchange as IOrderExchange;

                balances = exchange.GetAccountBalances();
                balances.TryGetValue(m_selectedPair.Left, out lbal);
                balances.TryGetValue(m_selectedPair.Right, out rbal);

                if (lbal != null && rbal != null)
                {
                    gridBalances[0, row].Value = lbal.Free;
                    gridBalances[1, row].Value = rbal.Free;
                }
                else
                {
                    gridBalances[0, row].Value = "";
                    gridBalances[1, row].Value = "";
                }
            }
        }
Esempio n. 3
0
        public void GetWallets()
        {
            Guid userId  = Guid.Empty;
            Page page    = Page.Create(number: 1, size: 500);
            var  wallets = m_api.GetAllWalletsAsync(userId, page).Result;

            foreach (var w in wallets)
            {
                CurrencyCode curcode = CurrencyCode.USD;    // EUR, SGD, XBT
                var          b       = m_api.GetWalletBalanceAsync(w.Id, curcode).Result;
                var          balance = new ZAccountBalance(w.Name, b.AvailableBalance, b.TotalBalance - b.AvailableBalance);
            }
        }