Esempio n. 1
0
        /// <summary>
        /// Method to add Securites only present in Benchmark_Holdings to result set
        /// </summary>
        /// <param name="result">Collection of PortfolioDetailsData containing data of Securities held by Portfolio</param>
        /// <param name="onlyBenchmarkSecurities">Collection of GF_BENCHMARK_HOLDINGS, contains securities only held by Benchmark & not by Portfolio</param>
        /// <returns>Collection of PortfolioDetailsData</returns>
        public static List <PortfolioDetailsData> AddBenchmarkSecurities(List <PortfolioDetailsData> result, List <GreenField.DAL.GF_BENCHMARK_HOLDINGS> onlyBenchmarkSecurities, Boolean isFiltered, decimal?sumBenchmarkWeight)
        {
            if (onlyBenchmarkSecurities == null)
            {
                return(result);
            }
            if (onlyBenchmarkSecurities.Count == 0)
            {
                return(result);
            }
            if (result == null)
            {
                return(new List <PortfolioDetailsData>());
            }

            Debug.WriteLine(onlyBenchmarkSecurities.Count());
            foreach (GreenField.DAL.GF_BENCHMARK_HOLDINGS item in onlyBenchmarkSecurities)
            {
                PortfolioDetailsData benchmarkResult = new PortfolioDetailsData();
                benchmarkResult.AsecSecShortName      = item.ASEC_SEC_SHORT_NAME;
                benchmarkResult.IssueName             = item.ISSUE_NAME;
                benchmarkResult.Ticker                = item.TICKER;
                benchmarkResult.ProprietaryRegionCode = item.ASHEMM_PROP_REGION_CODE;
                benchmarkResult.IsoCountryCode        = item.ISO_COUNTRY_CODE;
                benchmarkResult.SectorName            = item.GICS_SECTOR_NAME;
                benchmarkResult.IndustryName          = item.GICS_INDUSTRY_NAME;
                benchmarkResult.SubIndustryName       = item.GICS_SUB_INDUSTRY_NAME;
                benchmarkResult.MarketCapUSD          = item.MARKET_CAP_IN_USD;
                benchmarkResult.SecurityType          = item.SECURITY_TYPE;
                benchmarkResult.BalanceNominal        = item.BALANCE_NOMINAL;
                benchmarkResult.DirtyValuePC          = item.DIRTY_VALUE_PC;
                //  benchmarkResult.BenchmarkWeight = item.BENCHMARK_WEIGHT;
                benchmarkResult.AshEmmModelWeight = item.ASH_EMM_MODEL_WEIGHT;
                benchmarkResult.Type     = "BENCHMARK";
                benchmarkResult.IssuerId = item.ISSUER_ID;
                if (isFiltered)
                {
                    if (sumBenchmarkWeight != 0)
                    {
                        //benchmarkResult.BenchmarkWeight = ((dimensionBenchmarkHoldingsData.
                        //            Where(a => a.ASEC_SEC_SHORT_NAME == portfolioResult.AsecSecShortName).FirstOrDefault() == null) ? 0 : dimensionBenchmarkHoldingsData.
                        //            Where(a => a.ASEC_SEC_SHORT_NAME == portfolioResult.AsecSecShortName).FirstOrDefault().BENCHMARK_WEIGHT) / sumBenchmarkWeight;
                        benchmarkResult.BenchmarkWeight = (item.BENCHMARK_WEIGHT == null?0:item.BENCHMARK_WEIGHT) * 100 / sumBenchmarkWeight;
                    }
                    else
                    {
                        benchmarkResult.BenchmarkWeight = 0;
                    }
                }
                else
                {
                    //benchmarkResult.BenchmarkWeight = ((dimensionBenchmarkHoldingsData.
                    //                Where(a => a.ASEC_SEC_SHORT_NAME == portfolioResult.AsecSecShortName).FirstOrDefault() == null) ? 0 : dimensionBenchmarkHoldingsData.
                    //                Where(a => a.ASEC_SEC_SHORT_NAME == portfolioResult.AsecSecShortName).FirstOrDefault().BENCHMARK_WEIGHT);
                    benchmarkResult.BenchmarkWeight = (item.BENCHMARK_WEIGHT == null ? 0 : item.BENCHMARK_WEIGHT);
                }
                result.Add(benchmarkResult);
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Getting the currently filtered/grouped items from the DataGrid
        /// </summary>
        private void SetGroupedData()
        {
            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);

            Logging.LogBeginMethod(this.DataContextPortfolioDetails.Logger, methodNamespace);
            try
            {
                RangeObservableCollection <PortfolioDetailsData> collection = new RangeObservableCollection <PortfolioDetailsData>();
                foreach (PortfolioDetailsData item in dgPortfolioDetails.Items)
                {
                    PortfolioDetailsData data = new PortfolioDetailsData();
                    data.ActivePosition        = item.ActivePosition;
                    data.AsecSecShortName      = item.AsecSecShortName;
                    data.AshEmmModelWeight     = item.AshEmmModelWeight;
                    data.BalanceNominal        = item.BalanceNominal;
                    data.BenchmarkWeight       = item.BenchmarkWeight;
                    data.DirtyValuePC          = item.DirtyValuePC;
                    data.IndustryName          = item.IndustryName;
                    data.IsoCountryCode        = item.IsoCountryCode;
                    data.IssueName             = item.IssueName;
                    data.MarketCapUSD          = item.MarketCapUSD;
                    data.PortfolioDirtyValuePC = item.PortfolioDirtyValuePC;
                    data.PortfolioWeight       = item.PortfolioWeight;
                    data.ProprietaryRegionCode = item.ProprietaryRegionCode;
                    data.ReAshEmmModelWeight   = item.ReAshEmmModelWeight;
                    data.ReBenchmarkWeight     = item.ReBenchmarkWeight;
                    data.RePortfolioWeight     = item.RePortfolioWeight;
                    data.SectorName            = item.SectorName;
                    data.SecurityType          = item.SecurityType;
                    data.SubIndustryName       = item.SubIndustryName;
                    data.Ticker                     = item.Ticker;
                    data.MarketCap                  = item.MarketCap;
                    data.Upside                     = item.Upside;
                    data.ForwardPE                  = item.ForwardPE;
                    data.ForwardPBV                 = item.ForwardPBV;
                    data.ForwardEB_EBITDA           = item.ForwardEB_EBITDA;
                    data.RevenueGrowthCurrentYear   = item.RevenueGrowthCurrentYear;
                    data.RevenueGrowthNextYear      = item.RevenueGrowthNextYear;
                    data.NetIncomeGrowthCurrentYear = item.NetIncomeGrowthCurrentYear;
                    data.NetIncomeGrowthNextYear    = item.NetIncomeGrowthNextYear;
                    data.ROE                = item.ROE;
                    data.NetDebtEquity      = item.NetDebtEquity;
                    data.FreecashFlowMargin = item.FreecashFlowMargin;
                    collection.Add(data);
                }
                DataContextPortfolioDetails.GroupedFilteredPortfolioDetailsData = collection;
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                Logging.LogException(this.DataContextPortfolioDetails.Logger, ex);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Add Data returned from View(GF_PORTFOLIO_LTHOLDINGS) to resultSet
        /// </summary>
        /// <param name="dimensionPortfolioLTHoldingsData">List of type GF_PORTFOLIO_LTHOLDINGS returned from GF_PORTFOLIO_LTHOLDINGS</param>
        /// <param name="dimensionBenchmarkHoldingsData">List of type GF_BENCHMARK_HOLDINGS returned from GF_BENCHMARK_HOLDINGS</param>
        /// <returns>List of PortfolioDetailsData</returns>
        public static List <PortfolioDetailsData> AddPortfolioLTSecurities(List <GreenField.DAL.GF_PORTFOLIO_LTHOLDINGS> dimensionPortfolioLTHoldingsData, List <GreenField.DAL.GF_BENCHMARK_HOLDINGS> dimensionBenchmarkHoldingsData, Boolean isFiltered)
        {
            List <PortfolioDetailsData> result = new List <PortfolioDetailsData>();

            if (dimensionPortfolioLTHoldingsData == null)
            {
                return(result);
            }
            if (dimensionPortfolioLTHoldingsData.Count == 0)
            {
                return(result);
            }
            if (dimensionBenchmarkHoldingsData == null)
            {
                return(result);
            }
            decimal?sumBenchmarkWeight = 0;

            sumBenchmarkWeight = dimensionBenchmarkHoldingsData.Sum(a => a.BENCHMARK_WEIGHT);
            foreach (GreenField.DAL.GF_PORTFOLIO_LTHOLDINGS item in dimensionPortfolioLTHoldingsData)
            {
                PortfolioDetailsData portfolioResult = new PortfolioDetailsData();
                portfolioResult.AsecSecShortName    = item.ASEC_SEC_SHORT_NAME;
                portfolioResult.IssueName           = item.ISSUE_NAME;
                portfolioResult.Ticker              = item.TICKER;
                portfolioResult.PfcHoldingPortfolio = item.A_PFCHOLDINGS_PORLT;
                portfolioResult.PortfolioId         = item.PORTFOLIO_ID;

                portfolioResult.PortfolioPath         = item.PORPATH;
                portfolioResult.ProprietaryRegionCode = item.ASHEMM_PROP_REGION_CODE;
                portfolioResult.IsoCountryCode        = item.ISO_COUNTRY_CODE;
                portfolioResult.SectorName            = item.GICS_SECTOR_NAME;
                portfolioResult.IndustryName          = item.GICS_INDUSTRY_NAME;
                portfolioResult.SubIndustryName       = item.GICS_SUB_INDUSTRY_NAME;
                portfolioResult.MarketCapUSD          = item.MARKET_CAP_IN_USD;
                portfolioResult.SecurityType          = item.SECURITY_TYPE;
                portfolioResult.BalanceNominal        = item.BALANCE_NOMINAL;
                portfolioResult.DirtyValuePC          = item.DIRTY_VALUE_PC;

                if (isFiltered)
                {
                    if (sumBenchmarkWeight != 0)
                    {
                        portfolioResult.BenchmarkWeight = ((dimensionBenchmarkHoldingsData.
                                                            Where(a => a.ISSUE_NAME == portfolioResult.IssueName).FirstOrDefault() == null) ? 0 : dimensionBenchmarkHoldingsData.
                                                           Where(a => a.ISSUE_NAME == portfolioResult.IssueName).FirstOrDefault().BENCHMARK_WEIGHT) * 100 / sumBenchmarkWeight;
                    }
                    else
                    {
                        portfolioResult.BenchmarkWeight = 0;
                    }
                }
                else
                {
                    portfolioResult.BenchmarkWeight = ((dimensionBenchmarkHoldingsData.
                                                        Where(a => a.ISSUE_NAME == portfolioResult.IssueName).FirstOrDefault() == null) ? 0 : dimensionBenchmarkHoldingsData.
                                                       Where(a => a.ISSUE_NAME == portfolioResult.IssueName).FirstOrDefault().BENCHMARK_WEIGHT);
                }


                portfolioResult.AshEmmModelWeight = item.ASH_EMM_MODEL_WEIGHT;
                portfolioResult.IssuerId          = item.ISSUER_ID;
                result.Add(portfolioResult);
            }
            return(result);
        }
Esempio n. 4
0
        private List <PortfolioDetailsData> GetGroupedPortfolios(string portfolioId, List <PortfolioDetailsData> list)
        {
            var result = new List <PortfolioDetailsData>();
            var query  = from d in list
                         group d by d.AsecSecShortName into grp
                         select grp;
            var groups = query.ToList();

            foreach (var group in groups)
            {
                var main = group.Where(x => x.PortfolioPath == portfolioId).FirstOrDefault();
                if (main == null || group.Count() == 1)
                {
                    result.AddRange(group.AsEnumerable());
                }
                else
                {
                    decimal?sumBenchmarkWeight = sumBenchmarkWeightWhenGrouped(group);
                    var     holding            = new PortfolioDetailsData
                    {
                        A_Sec_Instr_Type           = group.First().A_Sec_Instr_Type,
                        ActivePosition             = group.Sum(x => x.RePortfolioWeight ?? 0.0m) - sumBenchmarkWeight,
                        AsecSecShortName           = group.Key,
                        AshEmmModelWeight          = group.Sum(x => x.AshEmmModelWeight ?? 0.0m),
                        BalanceNominal             = group.Sum(x => x.BalanceNominal ?? 0.0m),
                        BenchmarkWeight            = group.Sum(x => x.BenchmarkWeight), //main.BenchmarkWeight,
                        DirtyValuePC               = group.Sum(x => x.DirtyValuePC ?? 0.0m),
                        ForwardEB_EBITDA           = main.ForwardEB_EBITDA,
                        ForwardPE                  = main.ForwardPE,
                        ForwardPBV                 = main.ForwardPBV,
                        FreecashFlowMargin         = main.FreecashFlowMargin,
                        FromDate                   = main.FromDate,
                        IndustryName               = main.IndustryName,
                        IsoCountryCode             = main.IsoCountryCode,
                        IssueName                  = main.IssueName,
                        IssuerId                   = main.IssuerId,
                        MarketCap                  = main.MarketCap,
                        MarketCapUSD               = main.MarketCapUSD,
                        NetDebtEquity              = main.NetDebtEquity,
                        NetIncomeGrowthCurrentYear = main.NetIncomeGrowthCurrentYear,
                        NetIncomeGrowthNextYear    = main.NetIncomeGrowthNextYear,
                        PfcHoldingPortfolio        = String.Join(", ", group.Select(x => x.PfcHoldingPortfolio).ToArray()),
                        PortfolioDirtyValuePC      = group.Sum(x => x.PortfolioDirtyValuePC),
                        PortfolioPath              = null,
                        PortfolioWeight            = group.Sum(x => x.PortfolioWeight ?? 0.0m),
                        ProprietaryRegionCode      = main.ProprietaryRegionCode,
                        ReAshEmmModelWeight        = group.Sum(x => x.ReAshEmmModelWeight ?? 0.0m),
                        RePortfolioWeight          = group.Sum(x => x.RePortfolioWeight ?? 0.0m),
                        ReBenchmarkWeight          = sumBenchmarkWeight, //main.ReBenchmarkWeight,sum benchmark weight,
                        RevenueGrowthCurrentYear   = main.RevenueGrowthCurrentYear,
                        RevenueGrowthNextYear      = main.RevenueGrowthNextYear,
                        ROE               = main.ROE,
                        SectorName        = main.SectorName,
                        SecurityId        = main.SecurityId,
                        SecurityThemeCode = main.SecurityThemeCode,
                        SecurityType      = main.SecurityType,
                        SubIndustryName   = main.SubIndustryName,
                        Ticker            = main.Ticker,
                        TradingCurrency   = main.TradingCurrency,
                        Type              = main.Type,
                        Upside            = main.Upside,
                        IsExpanded        = true,
                        Children          = group.ToList()
                    };
                    result.Add(holding);
                }
            }

            return(result);
        }
Esempio n. 5
0
        private List <PortfolioDetailsData> GetGroupedPortfoliosByIssuer(string portfolioId, List <PortfolioDetailsData> list)
        {
            var result = new List <PortfolioDetailsData>();
            var query  = from d in list
                         group d by d.IssuerName into grp
                         select grp;
            var groups = query.ToList();

            foreach (var group in groups)
            {
                if (group.Key == "Petroleo Brasileiro SA")
                {
                    Console.WriteLine("Hello");
                }

                var main = group.Where(x => x.PortfolioPath == portfolioId).FirstOrDefault();
                if (main == null || group.Count() == 1)
                {
                    result.AddRange(group.AsEnumerable());
                }
                else
                {
                    if (group.Count() > 1 && group.Key == null)
                    {
                        foreach (var nullissuergrp in group)
                        {
                            result.Add(nullissuergrp);
                        }
                    }
                    else
                    {
                        decimal?sumBenchmarkWeight = sumBenchmarkWeightWhenGrouped(group);
                        var     holding            = new PortfolioDetailsData
                        {
                            A_Sec_Instr_Type           = group.First().A_Sec_Instr_Type,
                            ActivePosition             = group.Sum(x => x.RePortfolioWeight ?? 0.0m) - sumBenchmarkWeight,
                            AsecSecShortName           = null,                                                                                                //group.Key  -do not display anything in the grouped line
                            AshEmmModelWeight          = group.Sum(x => x.AshEmmModelWeight ?? 0.0m),
                            BalanceNominal             = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.BalanceNominal).FirstOrDefault(),     //display  values from issuer_proxy securities
                            BenchmarkWeight            = group.Sum(x => x.BenchmarkWeight),                                                                   //main.BenchmarkWeight, sum benchmark weight
                            DirtyValuePC               = group.Sum(x => x.DirtyValuePC ?? 0.0m),
                            ForwardEB_EBITDA           = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.ForwardEB_EBITDA).FirstOrDefault(),   //display  values from issuer_proxy securities
                            ForwardPE                  = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.ForwardPE).FirstOrDefault(),          //display  values from issuer_proxy securities
                            ForwardPBV                 = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.ForwardPBV).FirstOrDefault(),         //display  values from issuer_proxy securities
                            FreecashFlowMargin         = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.FreecashFlowMargin).FirstOrDefault(), //display  values from issuer_proxy securities
                            FromDate                   = main.FromDate,
                            IndustryName               = main.IndustryName,
                            IsoCountryCode             = main.IsoCountryCode,
                            IssueName                  = main.IssuerName,//group.Key.ToUpper(),  //main.IssueName  - display issuer name in the grouped line
                            IssuerId                   = main.IssuerId,
                            MarketCap                  = main.MarketCap,
                            MarketCapUSD               = main.MarketCapUSD,
                            NetDebtEquity              = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.NetDebtEquity).FirstOrDefault(), //display  values from issuer_proxy securities
                            NetIncomeGrowthCurrentYear = main.NetIncomeGrowthCurrentYear,
                            NetIncomeGrowthNextYear    = main.NetIncomeGrowthNextYear,
                            PfcHoldingPortfolio        = String.Join(", ", group.Select(x => x.PfcHoldingPortfolio).ToArray()),
                            PortfolioDirtyValuePC      = group.Sum(x => x.PortfolioDirtyValuePC),
                            PortfolioPath              = null,
                            PortfolioWeight            = group.Sum(x => x.PortfolioWeight ?? 0.0m),
                            ProprietaryRegionCode      = main.ProprietaryRegionCode,
                            ReAshEmmModelWeight        = group.Sum(x => x.ReAshEmmModelWeight ?? 0.0m),
                            RePortfolioWeight          = group.Sum(x => x.RePortfolioWeight ?? 0.0m),
                            ReBenchmarkWeight          = sumBenchmarkWeight, //main.ReBenchmarkWeight,sum benchmark weight
                            RevenueGrowthCurrentYear   = main.RevenueGrowthCurrentYear,
                            RevenueGrowthNextYear      = main.RevenueGrowthNextYear,
                            ROE               = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.ROE).FirstOrDefault(), //display  values from issuer_proxy securities
                            SectorName        = main.SectorName,
                            SecurityId        = main.SecurityId,
                            SecurityThemeCode = main.SecurityThemeCode,
                            SecurityType      = main.SecurityType,
                            SubIndustryName   = main.SubIndustryName,
                            Ticker            = group.Where(x => x.SecurityId == x.Issuer_Proxy).Select(x => x.Ticker).FirstOrDefault(), //display  values from issuer_proxy securities
                            TradingCurrency   = main.TradingCurrency,
                            Type              = main.Type,
                            Upside            = main.Upside,
                            IsExpanded        = true,
                            Children          = group.ToList()
                        };
                        result.Add(holding);
                    }
                }
            }

            return(result);
        }