public async Task GetMultipleBalancesUDTValue_BTC_BNB()
        {
            // Arrange
            var exchangeApi     = ExchangeServiceHelper.GetExchangeService(ExchangeServiceType.Standard);
            var exchangeService = new WpfExchangeService(exchangeApi);
            var symbolsCache    = SymbolsCacheHelper.GetSymbolsCache(exchangeService);
            var symbols         = await symbolsCache.GetSymbols();

            var balances = new List <Interface.AccountBalance>();

            balances.Add(new Interface.AccountBalance {
                Asset = "BTC", Free = 0.00396715m
            });
            balances.Add(new Interface.AccountBalance {
                Asset = "BNB", Free = 0.94444141m
            });

            var accountInfo = new Interface.AccountInfo
            {
                Balances = balances
            };

            var account = new Account(accountInfo);

            // Act
            symbolsCache.ValueAccount(account);

            // Assert
            Assert.AreEqual(account.USDTValue, 64.74m);
            Assert.AreEqual(account.BTCValue, 0.00793522m);
        }
Example #2
0
        public Account(Interface.AccountInfo accountInfo)
        {
            AccountInfo = accountInfo;

            if (!string.IsNullOrWhiteSpace(AccountInfo?.User?.ApiSecret))
            {
                apiSecret = secretText;
            }

            Balances = new ObservableCollection <AccountBalance>();

            if (accountInfo.Balances != null)
            {
                foreach (var balance in AccountInfo.Balances)
                {
                    Balances.Add(new AccountBalance {
                        Asset = balance.Asset, Free = balance.Free, Locked = balance.Locked
                    });
                }
            }

            OnPropertyChanged("ApiKey");
            OnPropertyChanged("Balances");
        }