public PortfolioRatingModel GenerateRatingsModel(List <AssetBase> assets) { List <ManagedInvestment> equityWithResearchValues = assets.OfType <ManagedInvestment>().ToList(); var weightings = equityWithResearchValues.Cast <AssetBase>().ToList().GetAssetWeightings(); double assetsSuitability = weightings.Sum(w => w.Percentage * ((ManagedInvestment)w.Weightable).GetRating().TotalScore); double percentage = equityWithResearchValues.Where(a => a.GetRating().SuitabilityRating == SuitabilityRating.Danger).Sum(a => a.GetTotalMarketValue()) / equityWithResearchValues.Sum(a => a.GetTotalMarketValue()); PortfolioRatingModel model = new PortfolioRatingModel { suitability = assetsSuitability, notSuited = percentage, data = new List <PortfolioRatingItemModel>() }; foreach (var weighting in weightings) { Equity equity = (Equity)weighting.Weightable; if (model.data.Any(m => m.name == equity.Ticker) == false) { model.data.Add(new PortfolioRatingItemModel { name = equity.Ticker, weighting = weighting.Percentage, score = equity.GetRating().TotalScore }); } } return(model); }
public CompanyProfileDataItem GetCompanyProfile(string companyId) { Equity equity = edisRepo.getEquityById(companyId); DateTime?priceDate = edisRepo.GetLastPriceDateForEquity(companyId); CompanyProfileDataItem model = new CompanyProfileDataItem { id = equity.Id, ticker = equity.Ticker, fullName = equity.Name, closingPrice = equity.LatestPrice, sector = equity.Sector, priceDate = priceDate == null? DateTime.MinValue : (DateTime)priceDate, assetClass = equity.EquityType.ToString(), changeAmount = edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.changeAmount, equity.Ticker) == null ? 0 : (double)edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.changeAmount, equity.Ticker), changeRatePercentage = edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.changeRatePercentage, equity.Ticker) == null ? 0 : (double)edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.changeRatePercentage, equity.Ticker), weeksDifferenceAmount = (double)edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.fivtyTwoWkHighPrice, equity.Ticker), weeksDifferenceRatePercentage = (double)(edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.fivtyTwoWkLowPrice, equity.Ticker) / edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.fivtyTwoWkHighPrice, equity.Ticker) == null ? 1 : edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.fivtyTwoWkHighPrice, equity.Ticker)), suitabilityScore = equity.GetRating().TotalScore, suitsTypeOfClients = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.suitsTypeOfClients, equity.Ticker), country = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.Country, equity.Ticker), exchange = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.Exchange, equity.Ticker), marketCapitalisation = edisRepo.GetResearchValueForEquitySync(ResearchValueKeys.MarketCap, equity.Ticker).ToString(), currencyType = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.Currency, equity.Ticker), reasons = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.reasons, equity.Ticker), companyBriefing = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.companyBriefing, equity.Ticker), companyStrategies = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.companyStrategies, equity.Ticker), investment = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.investment, equity.Ticker), investmentName = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.investmentName, equity.Ticker), indexData = new List <CompanyProfileIndexData>(), currentAnalysis = new CurrentAnalysisPayload { metaProperties = new List <AnalysisPayloadMetaProperty> { new AnalysisPayloadMetaProperty { propertyName = "baseInformation", displayName = "Base Information" }, new AnalysisPayloadMetaProperty { propertyName = "morningstar", displayName = "Morningstar" }, new AnalysisPayloadMetaProperty { propertyName = "brokerX", displayName = "Broker X" }, new AnalysisPayloadMetaProperty { propertyName = "ASX200Accumulation", displayName = "ASX 200 Accumulation" }, }, groups = new List <AnalysisPayloadGroupModel> { new AnalysisPayloadGroupModel { name = "Recommendation", data = new List <AnalysisPayloadGroupDataItem> { new AnalysisPayloadGroupDataItem { name = "Current Short Term Recommendation", baseInformation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.baseInformationShort, equity.Ticker), morningstar = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.morningstarShort, equity.Ticker), brokerX = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.brokerXShort, equity.Ticker), ASX200Accumulation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.ASX200AccumulationShort, equity.Ticker), }, new AnalysisPayloadGroupDataItem { name = "Current Long Term Recommendation", baseInformation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.baseInformationLong, equity.Ticker), morningstar = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.morningstarLong, equity.Ticker), brokerX = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.brokerXLong, equity.Ticker), ASX200Accumulation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.ASX200AccumulationLong, equity.Ticker), }, new AnalysisPayloadGroupDataItem { name = "Price Target", baseInformation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.baseInformationPrice, equity.Ticker), morningstar = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.morningstarPrice, equity.Ticker), brokerX = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.brokerXPrice, equity.Ticker), ASX200Accumulation = edisRepo.GetStringResearchValueForEquitySync(ResearchValueKeys.ASX200AccumulationPrice, equity.Ticker), }, } }, new AnalysisPayloadGroupModel { name = "Income", data = new List <AnalysisPayloadGroupDataItem> { new AnalysisPayloadGroupDataItem { name = "Current Short Term Recommendation", baseInformation = "base information", morningstar = "Morning star information", brokerX = "brokerX information", ASX200Accumulation = "Accumulation Details" }, new AnalysisPayloadGroupDataItem { name = "Current Long Term Recommendation", baseInformation = "base information", morningstar = "Morning star information", brokerX = "brokerX information", ASX200Accumulation = "Accumulation Details" }, new AnalysisPayloadGroupDataItem { name = "Price Target", baseInformation = "base information", morningstar = "Morning star information", brokerX = "brokerX information", ASX200Accumulation = "Accumulation Details" }, } } } }, }; List <AssetPrice> assetPrices = edisRepo.getPricesByEquityIdAndDates(companyId, Period.LastSixMonths.ToString()); foreach (var price in assetPrices) { model.indexData.Add(new CompanyProfileIndexData { company = price.Price.Value, month = price.CreatedOn.Value.Date.ToString("yy-MM-dd"), date = (DateTime)price.CreatedOn }); } return(model); //return advisorRepo.GetCompanyProfile(User.Identity.GetUserId(), companyId); }