public BasketSecurityPortfolioTargetRepository CreateRepository(IDataManager manager)
        {
            var targets = manager.GetBasketProtfolioSecurityTargets();
            var result  = new BasketSecurityPortfolioTargetRepository(targets);

            return(result);
        }
        public BasketSecurityPortfolioTargetRepository CreateRepository(
            IEnumerable <BasketPortfolioSecurityTargetInfo> targetInfos
            )
        {
            var result = new BasketSecurityPortfolioTargetRepository(targetInfos);

            return(result);
        }
Example #3
0
        public SecurityModel CreateSecurity(
            TargetingTypeGroup targetingTypeGroup,
            IBasket basket,
            ISecurity security,
            IEnumerable <BroadGlobalActivePortfolio> bgaPortfolios,
            TargetingTypeGroupBasketSecurityBaseValueRepository ttgbsbvRepository,
            BasketSecurityPortfolioTargetRepository bsptRepository,
            PortfolioRepository portfolioRepository
            )
        {
            var portfolioTargets = new List <PortfolioTargetModel>();

            var targetsOfSecurity  = bsptRepository.GetTargets(basket, security);
            var targetsByPortfolio = targetsOfSecurity.ToDictionary(x => x.PortfolioId);

            foreach (var bgaPortfolio in bgaPortfolios)
            {
                var portfolioTargetExpression = this.modelBuilder.CreatePortfolioTargetExpression(bgaPortfolio.Name);
                var portfolioModel            = new PortfolioTargetModel(bgaPortfolio, portfolioTargetExpression);

                BasketPortfolioSecurityTargetInfo target;
                if (targetsByPortfolio.TryGetValue(bgaPortfolio.Id, out target))
                {
                    // there is a target for the given portfolio
                    portfolioModel.Target.InitialValue = target.Target;
                }

                portfolioTargets.Add(portfolioModel);
            }

            var baseExpression = this.modelBuilder.CreateBaseExpression();

            var baseInfoOpt = ttgbsbvRepository.TryGetBaseValue(targetingTypeGroup, basket, security);

            if (baseInfoOpt != null)
            {
                // there is a base value for this security already defined
                baseExpression.InitialValue = baseInfoOpt.BaseValue;
            }
            else
            {
                // it will have a default base value which is null)
            }

            var benchmarkExpression  = this.modelBuilder.CreateBenchmarkExpression();
            var baseActiveExpression = this.modelBuilder.CreateBaseActiveExpression(baseExpression, benchmarkExpression);
            var securityModel        = new SecurityModel(
                security,
                baseExpression,
                benchmarkExpression,
                portfolioTargets,
                baseActiveExpression
                );

            return(securityModel);
        }
Example #4
0
        public CoreModel GetCoreModel(
            TargetingTypeGroup targetingTypeGroup,
            IBasket basket,
            SecurityRepository securityRepository,
            TargetingTypeGroupBasketSecurityBaseValueRepository ttgbsbvRepository,
            BasketSecurityPortfolioTargetRepository bpstRepository,
            PortfolioRepository portfolioRepository
            )
        {
            var bgaPortfolios = targetingTypeGroup.GetBgaPortfolios();

            // both base values and target values can contribute to the list of securities
            var securityIds = ttgbsbvRepository
                              .GetBaseValues(targetingTypeGroup, basket).Select(x => x.SecurityId)
                              .Union(bpstRepository.GetTargets(basket).Select(x => x.SecurityId));

            var securityModels = new List <SecurityModel>();

            foreach (var securityId in securityIds)
            {
                var security      = securityRepository.GetSecurity(securityId);
                var securityModel = this.CreateSecurity(
                    targetingTypeGroup,
                    basket,
                    security,
                    bgaPortfolios,
                    ttgbsbvRepository,
                    bpstRepository,
                    portfolioRepository
                    );
                securityModels.Add(securityModel);
            }

            var portfolios = bgaPortfolios.Select(portfolio => {
                return(new PortfolioModel(
                           portfolio,
                           this.modelBuilder.CreatePortfolioTargetTotalExpression(portfolio, securityModels)
                           ));
            }
                                                  ).ToArray();

            var baseTotalExpression       = this.modelBuilder.CreateBaseTotalExpression(securityModels);
            var benchmarkTotalExpression  = this.modelBuilder.CreateBenchmarkTotalExpression(securityModels);
            var baseActiveTotalExpression = this.modelBuilder.CreateBaseActiveTotalExpression(securityModels);
            var core = new CoreModel(
                targetingTypeGroup,
                basket,
                portfolios,
                securityModels,
                baseTotalExpression,
                benchmarkTotalExpression,
                baseActiveTotalExpression
                );

            return(core);
        }