public ManagedInvestmentCompanyProfileModel GenerateProfilesModel(List <AssetBase> assets)
        {
            List <ManagedInvestmentCompanyProfileItem> itemList = new List <ManagedInvestmentCompanyProfileItem>();

            foreach (var asset in assets.OfType <ManagedInvestment>())
            {
                var itemIndex = itemList.FindIndex(i => i.ticker == asset.Ticker);

                if (itemIndex < 0)
                {
                    itemList.Add(new ManagedInvestmentCompanyProfileItem {
                        ticker                       = asset.Ticker,
                        beta                         = asset.F0Ratios.Beta,
                        company                      = asset.Name,
                        currentRatio                 = asset.F0Ratios.CurrentRatio,
                        debtEquityRatio              = asset.F0Ratios.DebtEquityRatio,
                        earningsStability            = asset.F0Ratios.EarningsStability,
                        fiveYearReturn               = asset.F0Ratios.FiveYearReturn,
                        threeYearReturn              = asset.F0Ratios.ThreeYearReturn,
                        oneYearReturn                = asset.F0Ratios.OneYearReturn,
                        franking                     = asset.F0Ratios.Frank,
                        interestCover                = asset.F0Ratios.InterestCover,
                        payoutRatio                  = asset.F0Ratios.PayoutRatio,
                        priceEarningsRatio           = asset.F0Ratios.PriceEarningRatio,
                        quickRatio                   = asset.F0Ratios.QuickRatio,
                        returnOnAsset                = asset.F0Ratios.ReturnOnAsset,
                        returnOnEquity               = asset.F0Ratios.ReturnOnEquity,
                        marketPrice                  = asset.LatestPrice,
                        marketValue                  = asset.GetTotalMarketValue(),
                        totalCostValue               = asset.GetCost().Total,
                        costValue                    = asset.GetCost().AssetCost,
                        companySuitabilityToInvestor = asset.GetRating().TotalScore
                    });
                }
                else
                {
                    itemList[itemIndex].marketValue    += asset.GetTotalMarketValue();
                    itemList[itemIndex].totalCostValue += asset.GetCost().Total;
                    itemList[itemIndex].costValue      += asset.GetCost().AssetCost;
                }
            }

            ManagedInvestmentCompanyProfileModel model = new ManagedInvestmentCompanyProfileModel {
                data = itemList,
                totalCostInvestment = assets.GetTotalCost().Total,
                totalMarketValue    = assets.GetTotalMarketValue(),
            };

            return(model);
        }
Exemple #2
0
        public EquityCompanyProfileModel GenerateProfilesModel(List <AssetBase> assets)
        {
            List <EquityCompanyProfileItemModel> itemList = new List <EquityCompanyProfileItemModel>();

            foreach (var asset in assets.OfType <AustralianEquity>())
            {
                if (itemList.All(i => i.asx != asset.Ticker))
                {
                    itemList.Add(new EquityCompanyProfileItemModel {
                        asx                          = asset.Ticker,
                        beta                         = asset.F0Ratios.Beta,
                        company                      = asset.Name,
                        currentRatio                 = asset.F0Ratios.CurrentRatio,
                        debtEquityRatio              = asset.F0Ratios.DebtEquityRatio,
                        earningsStability            = asset.F0Ratios.EarningsStability,
                        fiveYearReturn               = asset.F0Ratios.FiveYearReturn,
                        threeYearReturn              = asset.F0Ratios.ThreeYearReturn,
                        oneYearReturn                = asset.F0Ratios.OneYearReturn,
                        franking                     = asset.F0Ratios.Frank,
                        interestCover                = asset.F0Ratios.InterestCover,
                        payoutRatio                  = asset.F0Ratios.PayoutRatio,
                        priceEarningsRatio           = asset.F0Ratios.PriceEarningRatio,
                        quickRatio                   = asset.F0Ratios.QuickRatio,
                        returnOnAsset                = asset.F0Ratios.ReturnOnAsset,
                        returnOnEquity               = asset.F0Ratios.ReturnOnEquity,
                        marketPrice                  = asset.LatestPrice,
                        marketValue                  = asset.GetTotalMarketValue(),
                        totalCostValue               = asset.GetCost().Total,
                        costValue                    = asset.GetCost().AssetCost,
                        companySuitabilityToInvestor = asset.GetRating().TotalScore
                    });
                }
                else
                {
                    itemList.SingleOrDefault(i => i.asx == asset.Ticker).marketValue    += asset.GetTotalMarketValue();
                    itemList.SingleOrDefault(i => i.asx == asset.Ticker).totalCostValue += asset.GetCost().Total;
                    itemList.SingleOrDefault(i => i.asx == asset.Ticker).costValue      += asset.GetCost().AssetCost;
                }
            }

            EquityCompanyProfileModel model = new EquityCompanyProfileModel {
                data = itemList,
                totalCostInvestment = assets.GetTotalCost().Total,
                totalMarketValue    = assets.GetTotalMarketValue()
            };

            return(model);
        }
        public ManagedInvestmentCompanyProfileModel GetCompanyProfiles_Client()
        {
            Client client = edisRepo.GetClientSync(User.Identity.GetUserId(), DateTime.Now);
            ClientGroup clientGroup = edisRepo.GetClientGroupSync(client.ClientGroupId, DateTime.Now);
            if (clientGroup.MainClientId == client.Id)
            {
                List<GroupAccount> groupAccounts = edisRepo.GetAccountsForClientGroupSync(clientGroup.ClientGroupNumber, DateTime.Now);
                List<ClientAccount> clientAccounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now);

                List<ManagedInvestmentCompanyProfileItem> itemList = new List<ManagedInvestmentCompanyProfileItem>();

                List<AssetBase> assets = new List<AssetBase>();
                foreach (var account in groupAccounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<ManagedInvestment>().Cast<AssetBase>().ToList());
                }
                foreach (var account in clientAccounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<ManagedInvestment>().Cast<AssetBase>().ToList());
                }
                var managedAssets = assets.OfType<ManagedInvestment>();

                var ratios = assets.GetAverageRatiosFor<ManagedInvestment>();

                foreach (var asset in managedAssets)
                {
                    itemList.Add(new ManagedInvestmentCompanyProfileItem
                    {
                        ticker = asset.Ticker,
                        beta = ratios.Beta,
                        company = asset.Name,
                        currentRatio = ratios.CurrentRatio,
                        debtEquityRatio = ratios.DebtEquityRatio,
                        earningsStability = ratios.EarningsStability,
                        fiveYearReturn = ratios.FiveYearReturn,
                        threeYearReturn = ratios.ThreeYearReturn,
                        oneYearReturn = ratios.OneYearReturn,
                        franking = ratios.Frank,
                        interestCover = ratios.InterestCover,
                        payoutRatio = ratios.PayoutRatio,
                        priceEarningsRatio = ratios.PriceEarningRatio,
                        quickRatio = ratios.QuickRatio,
                        returnOnAsset = ratios.ReturnOnAsset,
                        returnOnEquity = ratios.ReturnOnEquity
                    });
                }

                ManagedInvestmentCompanyProfileModel model = new ManagedInvestmentCompanyProfileModel
                {
                    data = itemList,
                    totalCostInvestment = assets.GetTotalCost().Total,
                    totalMarketValue = assets.GetTotalMarketValue()
                };
                return model;
            }
            else
            {
                List<ClientAccount> accounts = edisRepo.GetAccountsForClientSync(client.ClientNumber, DateTime.Now);

                List<ManagedInvestmentCompanyProfileItem> itemList = new List<ManagedInvestmentCompanyProfileItem>();

                List<AssetBase> assets = new List<AssetBase>();
                foreach (var account in accounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<ManagedInvestment>().Cast<AssetBase>().ToList());
                }
                var managedAssets = assets.OfType<ManagedInvestment>();

                var ratios = assets.GetAverageRatiosFor<ManagedInvestment>();

                foreach (var asset in managedAssets)
                {
                    itemList.Add(new ManagedInvestmentCompanyProfileItem
                    {
                        ticker = asset.Ticker,
                        beta = ratios.Beta,
                        company = asset.Name,
                        currentRatio = ratios.CurrentRatio,
                        debtEquityRatio = ratios.DebtEquityRatio,
                        earningsStability = ratios.EarningsStability,
                        fiveYearReturn = ratios.FiveYearReturn,
                        threeYearReturn = ratios.ThreeYearReturn,
                        oneYearReturn = ratios.OneYearReturn,
                        franking = ratios.Frank,
                        interestCover = ratios.InterestCover,
                        payoutRatio = ratios.PayoutRatio,
                        priceEarningsRatio = ratios.PriceEarningRatio,
                        quickRatio = ratios.QuickRatio,
                        returnOnAsset = ratios.ReturnOnAsset,
                        returnOnEquity = ratios.ReturnOnEquity
                    });
                }

                ManagedInvestmentCompanyProfileModel model = new ManagedInvestmentCompanyProfileModel
                {
                    data = itemList,
                    totalCostInvestment = assets.GetTotalCost().Total,
                    totalMarketValue = assets.GetTotalMarketValue()
                };
                return model;
            }
        }
        public EquityCompanyProfileModel GenerateProfilesModel(List<AssetBase> assets) {
            List<EquityCompanyProfileItemModel> itemList = new List<EquityCompanyProfileItemModel>();

            foreach (var asset in assets.OfType<InternationalEquity>()) {
                var itemIndex = itemList.FindIndex(i => i.asx == asset.Ticker);

                if (itemIndex < 0) {
                    itemList.Add(new EquityCompanyProfileItemModel {
                        asx = asset.Ticker,
                        beta = asset.F0Ratios.Beta,
                        company = asset.Name,
                        currentRatio = asset.F0Ratios.CurrentRatio,
                        debtEquityRatio = asset.F0Ratios.DebtEquityRatio,
                        earningsStability = asset.F0Ratios.EarningsStability,
                        fiveYearReturn = asset.F0Ratios.FiveYearReturn,
                        threeYearReturn = asset.F0Ratios.ThreeYearReturn,
                        oneYearReturn = asset.F0Ratios.OneYearReturn,
                        franking = asset.F0Ratios.Frank,
                        interestCover = asset.F0Ratios.InterestCover,
                        payoutRatio = asset.F0Ratios.PayoutRatio,
                        priceEarningsRatio = asset.F0Ratios.PriceEarningRatio,
                        quickRatio = asset.F0Ratios.QuickRatio,
                        returnOnAsset = asset.F0Ratios.ReturnOnAsset,
                        returnOnEquity = asset.F0Ratios.ReturnOnEquity,
                        marketPrice = asset.LatestPrice,
                        marketValue = asset.GetTotalMarketValue(),
                        totalCostValue = asset.GetCost().Total,
                        costValue = asset.GetCost().AssetCost,
                        companySuitabilityToInvestor = asset.GetRating().TotalScore
                    });
                } else {
                    itemList[itemIndex].marketValue += asset.GetTotalMarketValue();
                    itemList[itemIndex].totalCostValue += asset.GetCost().Total;
                    itemList[itemIndex].costValue += asset.GetCost().AssetCost;
                }
            }

            EquityCompanyProfileModel model = new EquityCompanyProfileModel {
                data = itemList,
                totalCostInvestment = assets.GetTotalCost().Total,
                totalMarketValue = assets.GetTotalMarketValue()
            };
            return model;
        }
Exemple #5
0
 public static double GetProfitAndLoss(this List <AssetBase> assets)
 {
     return(assets.GetTotalMarketValue() + assets.GetTotalIncome() - assets.GetTotalCost().Total);
 }
        public EquityCompanyProfileModel GetCompanyProfiles_Adviser(string clientGroupId = null)
        {
            if (string.IsNullOrEmpty(clientGroupId))
            {
                //AustralianEquity australianEquity = new AustralianEquity(edisRepo);

                List<GroupAccount> groupAccounts = edisRepo.getAllClientGroupAccountsForAdviser(User.Identity.GetUserId(), DateTime.Now);
                List<ClientAccount> clientAccounts = edisRepo.getAllClientAccountsForAdviser(User.Identity.GetUserId(), DateTime.Now);

                List<EquityCompanyProfileItemModel> itemList = new List<EquityCompanyProfileItemModel>();

                List<AssetBase> assets = new List<AssetBase>();
                foreach (var account in groupAccounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<InternationalEquity>().Cast<AssetBase>().ToList());
                }
                foreach (var account in clientAccounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<InternationalEquity>().Cast<AssetBase>().ToList());
                }
                var internationalAssets = assets.OfType<InternationalEquity>();

                var ratios = assets.GetAverageRatiosFor<InternationalEquity>();

                foreach (var asset in internationalAssets)
                {
                    itemList.Add(new EquityCompanyProfileItemModel
                    {
                        asx = asset.Ticker,
                        beta = ratios.Beta,
                        company = asset.Name,
                        currentRatio = ratios.CurrentRatio,
                        debtEquityRatio = ratios.DebtEquityRatio,
                        earningsStability = ratios.EarningsStability,
                        fiveYearReturn = ratios.FiveYearReturn,
                        threeYearReturn = ratios.ThreeYearReturn,
                        oneYearReturn = ratios.OneYearReturn,
                        franking = ratios.Frank,
                        interestCover = ratios.InterestCover,
                        payoutRatio = ratios.PayoutRatio,
                        priceEarningsRatio = ratios.PriceEarningRatio,
                        quickRatio = ratios.QuickRatio,
                        returnOnAsset = ratios.ReturnOnAsset,
                        returnOnEquity = ratios.ReturnOnEquity
                    });
                }

                EquityCompanyProfileModel model = new EquityCompanyProfileModel
                {
                    data = itemList,
                    totalCostInvestment = assets.GetTotalCost().Total,
                    totalMarketValue = assets.GetTotalMarketValue()
                };
                return model;
                //return repo.AustralianEquity_GetCompanyProfiles_Adviser(User.Identity.GetUserId());
            }
            else
            {

                ClientGroup clientGroup = edisRepo.getClientGroupByGroupId(clientGroupId);
                List<GroupAccount> accounts = edisRepo.GetAccountsForClientGroupSync(clientGroup.ClientGroupNumber, DateTime.Now);
                List<EquityCompanyProfileItemModel> itemList = new List<EquityCompanyProfileItemModel>();

                List<AssetBase> assets = new List<AssetBase>();
                foreach (var account in accounts)
                {
                    assets.AddRange(account.GetAssetsSync().OfType<InternationalEquity>().Cast<AssetBase>().ToList());
                }
                var internationalAssets = assets.OfType<InternationalEquity>();

                var ratios = assets.GetAverageRatiosFor<InternationalEquity>();

                foreach (var asset in internationalAssets)
                {
                    itemList.Add(new EquityCompanyProfileItemModel
                    {
                        asx = asset.Ticker,
                        beta = ratios.Beta,
                        company = asset.Name,
                        currentRatio = ratios.CurrentRatio,
                        debtEquityRatio = ratios.DebtEquityRatio,
                        earningsStability = ratios.EarningsStability,
                        fiveYearReturn = ratios.FiveYearReturn,
                        threeYearReturn = ratios.ThreeYearReturn,
                        oneYearReturn = ratios.OneYearReturn,
                        franking = ratios.Frank,
                        interestCover = ratios.InterestCover,
                        payoutRatio = ratios.PayoutRatio,
                        priceEarningsRatio = ratios.PriceEarningRatio,
                        quickRatio = ratios.QuickRatio,
                        returnOnAsset = ratios.ReturnOnAsset,
                        returnOnEquity = ratios.ReturnOnEquity
                    });
                }

                EquityCompanyProfileModel model = new EquityCompanyProfileModel
                {
                    data = itemList,
                    totalCostInvestment = assets.GetTotalCost().Total,
                    totalMarketValue = assets.GetTotalMarketValue()
                };
                return model;

                //return repo.AustralianEquity_GetCompanyProfiles_Client(clientUserId);
            }
        }