public TotalDataVm <TotalAccountEnum> GetTotals(IEnumerable <TotalAccountEnum> toDashboardEnumTypes, Period period, IEnumerable <long> idMasterAccounts, IEnumerable <long> idTradeAccounts) { var totalData = new TotalDataVm <TotalAccountEnum>(); var idMasterAccountsArr = idMasterAccounts.ToArray(); var idTradeAccountsArr = idTradeAccounts.ToArray(); toDashboardEnumTypes.ToList().ForEach(type => { switch (type) { case TotalAccountEnum.TotalClients: totalData[(int)TotalAccountEnum.TotalClients] = NewClientsTableData("ALL", idMasterAccountsArr, idTradeAccountsArr, false); break; case TotalAccountEnum.NewClientsLd: totalData[(int)TotalAccountEnum.NewClientsLd] = NewClientsTableData("LD", idMasterAccountsArr, idTradeAccountsArr, false); break; case TotalAccountEnum.NewClientsMtd: totalData[(int)TotalAccountEnum.NewClientsMtd] = NewClientsTableData("MTD", idMasterAccountsArr, idTradeAccountsArr, false); break; } }); return(totalData); }
public TotalDataVm <PortfolioChartType> GetPortfolioTotals(PortfolioTotalsParamQuery paramQuery) { var result = new TotalDataVm <PortfolioChartType>(); var period = paramQuery.PeriodString.ToPeriod(); var accountId = _tradeAccountRepository.GetBySearchName(paramQuery.AccountName).Id; result[(int)PortfolioChartType.Nav] = _tradeAccountRepository.QueryTradeNav() .Where(nav => nav.TradeAccountId == accountId && nav.ReportDate >= period.FromDate && nav.ReportDate < period.ToDate) .OrderByDescending(nav => nav.ReportDate) .FirstOrDefault()?.Total ?? 0; result[(int)PortfolioChartType.OpenPositions] = _tradeAccountRepository.QueryTradeNav() .Where(nav => nav.TradeAccountId == accountId && nav.ReportDate >= period.FromDate && nav.ReportDate < period.ToDate) .OrderByDescending(nav => nav.ReportDate) .Sum(nav => (decimal?)nav.StockLong + (decimal?)nav.StockShort + (decimal?)nav.OptionsLong + (decimal?)nav.OptionsShort + (decimal?)nav.CommoditiesLong + (decimal?)nav.CommoditiesShort) ?? 0; result[(int)PortfolioChartType.TotalUn] = _tradeAccountRepository.QueryOpenPositions() .Where(nav => nav.TradeAccountId == accountId && nav.ReportDate >= period.FromDate && nav.ReportDate < period.ToDate) .OrderByDescending(nav => nav.ReportDate) .Sum(nav => (decimal?)nav.FifoPnlUnrealized) ?? 0; return(result); }
public TotalDataVm <DashboardEnum> GetTotals(IEnumerable <DashboardEnum> toDashboardEnumTypes, Period period, IEnumerable <long> idMasterAccounts, IEnumerable <long> idTradeAccounts) { var totalData = new TotalDataVm <DashboardEnum>(); var dashboardTypes = toDashboardEnumTypes == null ? new List <DashboardEnum>() : toDashboardEnumTypes.ToList(); dashboardTypes.ForEach(type => { switch (type) { case DashboardEnum.TotalIncome: totalData[(int)DashboardEnum.TotalIncome] = LoadTotalIncomeTotal(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.TotalClients: totalData[(int)DashboardEnum.TotalClients] = LoadTotalClientsTotal(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.TotalAum: totalData[(int)DashboardEnum.TotalAum] = LoadTotalAumTotal(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.AvgIncomeClient: totalData[(int)DashboardEnum.AvgIncomeClient] = LoadAvgIncomeClient(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray(), totalData.Totals); break; case DashboardEnum.AvgAccountSize: totalData[(int)DashboardEnum.AvgAccountSize] = LoadAvgAccountSize(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray(), totalData.Totals); break; case DashboardEnum.AvgDailyIncome: totalData[(int)DashboardEnum.AvgDailyIncome] = LoadAvgDailyIncome(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray(), totalData.Totals); break; case DashboardEnum.Deposits: totalData[(int)DashboardEnum.Deposits] = LoadDeposits(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.Withdrawals: totalData[(int)DashboardEnum.Withdrawals] = LoadWithdrawals(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.DwBalance: totalData[(int)DashboardEnum.DwBalance] = totalData[(int)DashboardEnum.Deposits] - totalData[(int)DashboardEnum.Withdrawals]; break; case DashboardEnum.TotalStocks: totalData[(int)DashboardEnum.TotalStocks] = LoadTotalStocks(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()) ?? 0; break; case DashboardEnum.TotalOptions: totalData[(int)DashboardEnum.TotalOptions] = LoadTotalOptions(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()) ?? 0; break; case DashboardEnum.TotalFutures: totalData[(int)DashboardEnum.TotalFutures] = LoadTotalFutures(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()) ?? 0; break; case DashboardEnum.TotalNewClients: totalData[(int)DashboardEnum.TotalNewClients] = LoadTotalNewClients(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.TotalAbandoment: totalData[(int)DashboardEnum.TotalAbandoment] = LoadTotalAbandoment(period, idMasterAccounts.ToArray(), idTradeAccounts.ToArray()); break; case DashboardEnum.NetChangeInClients: totalData[(int)DashboardEnum.NetChangeInClients] = totalData[(int)DashboardEnum.TotalNewClients] - totalData[(int)DashboardEnum.TotalAbandoment]; break; } }); return(totalData); }