Exemple #1
0
        public async Task <CompletePortfolio> GetPortfolio()
        {
            var fnResult = new CompletePortfolio();

            var stockResult = await _stocksRepository.GetStockPortfolioAsync();

            var cryptoResult = await _cryptoRepository.GetCryptoPortfolioAsync();

            fnResult.CurrentStockPortfolio  = stockResult.Data;
            fnResult.CurrentCryptoPortfolio = cryptoResult.Data;

            // loop through and pull out current values and profit amounts for fnResult.PortfolioProfit property
            foreach (var stock in fnResult.CurrentStockPortfolio.Stocks)
            {
                fnResult.PortfolioProfit.CurrentTotal  += stock.Value.CurrentValue;
                fnResult.PortfolioProfit.PurchaseTotal += stock.Value.TotalCost;
            }
            foreach (var crypto in fnResult.CurrentCryptoPortfolio.Cryptocurrencies)
            {
                fnResult.PortfolioProfit.CurrentTotal  += crypto.Value.CurrentValue;
                fnResult.PortfolioProfit.PurchaseTotal += crypto.Value.TotalCost;
            }

            fnResult.PortfolioProfit.CurrentTotal  = Math.Round(fnResult.PortfolioProfit.CurrentTotal, 2);
            fnResult.PortfolioProfit.PurchaseTotal = Math.Round(fnResult.PortfolioProfit.PurchaseTotal, 2);

            return(fnResult);
        }
Exemple #2
0
        public async Task <Response <StockPortfolio> > GetPortfolioAsync()
        {
            var result = await _stocksRepository.GetStockPortfolioAsync();

            return(result);
        }