public void GetAccountBalanceTest() { var balances = _repo.GetBalance().Result; Assert.True(balances != null); }
/// <summary> /// Get Balances for account /// </summary> /// <param name="asset">String of asset</param> /// <param name="pair">String of trading pair</param> /// <returns>Collection of Balance objects</returns> public List <Entities.Balance> GetBalance(string asset, string pair) { int i = 0; if (_thisExchange == Exchange.BINANCE) { var account = _bianceRepo.GetBalance().Result; if (account == null || account.balances == null) { return(new List <Entities.Balance>()); } return(account.balances.Where(b => b.asset.Equals(asset) || b.asset.Equals(pair)).ToList()); } else if (_thisExchange == Exchange.GDAX) { var accountList = _gdaxRepo.GetBalance().Result.ToArray(); var balances = new List <Entities.Balance>(); for (i = 0; i < accountList.Count(); i++) { if (accountList[i].Currency.Equals(asset) || accountList[i].Currency.Equals(pair)) { var balance = new Entities.Balance { asset = accountList[i].Currency, free = accountList[i].Available, locked = accountList[i].Hold }; balances.Add(balance); } } return(balances); } else if (_thisExchange == Exchange.KUCOIN) { var accountList = _kuRepo.GetBalance().Result; while (accountList == null && i < 3) { accountList = _kuRepo.GetBalance().Result; i++; } var balances = new List <Entities.Balance>(); if (accountList == null) { return(balances); } accountList = accountList.ToArray(); for (i = 0; i < accountList.Count(); i++) { if (accountList[i].coinType.ToString().Equals(asset) || accountList[i].coinType.ToString().Equals(pair)) { var balance = new Entities.Balance { asset = accountList[i].coinType.ToString(), free = accountList[i].balance, locked = accountList[i].freezeBalance }; balances.Add(balance); } } return(balances); } else { return(null); } }