public InvestmentBalanceStatistic ComputeInvestmentBalance(CurrencyInvestmentStatistic statistic) { var total = statistic.Symbols.Sum(s => s.InvestedNowPrice); var symbolRisks = GetRiskForSymbols(); var riskColors = GetRiskColors(); return(new InvestmentBalanceStatistic { Symbols = statistic.Symbols.Select(s => { var risk = symbolRisks.ContainsKey(s.Name) ? symbolRisks[s.Name] : Risk.Low; return new SymbolBalance { Name = s.Name, Percentage = total == 0 ? 0 : s.InvestedNowPrice / total * 100, Risk = risk, RiskColor = riskColors[risk] }; }) .OrderBy(s => s.Risk) .ToList(), TotalInvestment = total }); }
public TotalInvestmentStatistic ComputeTotalInvestment(CurrencyInvestmentStatistic statistic) { return(new TotalInvestmentStatistic { InvestedNowPrice = statistic.Symbols.Sum(sb => sb.InvestedNowPrice), InvestedNow = statistic.Symbols.Sum(sb => sb.InvestedNow), InvestedAllTime = statistic.Symbols.Sum(sb => sb.InvestedAllTime) + statistic.Fees, RealizedGains = statistic.Symbols.Sum(sb => sb.RealizedGains) }); }