Exemplo n.º 1
0
 public RootModel(
     TargetingType targetingType,
     BroadGlobalActivePortfolio portfolio,
     TargetingTypeBasketBaseValueChangesetInfo latestTtbbvChangesetInfo,
     TargetingTypeBasketPortfolioTargetChangesetInfo latestTtbptChangesetInfo,
     BgaPortfolioSecurityFactorChangesetInfo latestPstoChangesetInfo,
     BuPortfolioSecurityTargetChangesetInfo latestPstChangesetInfo,
     GlobeModel globe,
     CashModel cash,
     Overlaying.RootModel factors,
     IExpression <Decimal?> portfolioScaledGrandTotalExpression,
     IExpression <Decimal?> trueExposureGrandTotal,
     IExpression <Decimal?> trueActiveGrandTotal,
     DateTime benchmarkDate,
     Boolean isUserPermittedToSave
     )
 {
     this.TargetingType        = targetingType;
     this.Portfolio            = portfolio;
     this.LatestTtbbvChangeset = latestTtbbvChangesetInfo;
     this.LatestTtbptChangeset = latestTtbptChangesetInfo;
     this.LatestPstoChangeset  = latestPstoChangesetInfo;
     this.LatestPstChangeset   = latestPstChangesetInfo;
     this.Globe   = globe;
     this.Cash    = cash;
     this.Factors = factors;
     this.PortfolioScaledGrandTotal = portfolioScaledGrandTotalExpression;
     this.TrueExposureGrandTotal    = trueExposureGrandTotal;
     this.TrueActiveGrandTotal      = trueActiveGrandTotal;
     this.BenchmarkDate             = benchmarkDate;
     this.IsUserPermittedToSave     = isUserPermittedToSave;
 }
Exemplo n.º 2
0
        protected void RecalculateBasketCountry(
            BasketCountryModel model,
            TargetingType targetingType,
            BroadGlobalActivePortfolio portfolio,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager,
            CalculationTicket ticket
            )
        {
            var baseValue = model.Base.Value(ticket);

            if (!baseValue.HasValue)
            {
                throw new ValidationException(new ErrorIssue("There is no base value defined for the \"" + model.Basket.Country.Name + "\" country (ISO: " + model.Basket.Country.IsoCode + ")."));
            }

            var portfolioScaledValue = model.PortfolioScaled.Value(ticket);

            if (!portfolioScaledValue.HasValue)
            {
                throw new ValidationException(new ErrorIssue("There is no portfolio scaled value defined for the \"" + model.Basket.Country.Name + "\" country (ISO: " + model.Basket.Country.IsoCode + ")."));
            }

            this.RecalculateSecurityTargets(
                portfolioScaledValue.Value,
                model.Basket,
                targetingType,
                portfolio,
                result,
                manager,
                ticket
                );
        }
Exemplo n.º 3
0
        protected Decimal ResolveToUnscaledTarget(BroadGlobalActivePortfolio portfolio, SecurityModel model, CalculationTicket ticket)
        {
            var baseValue = model.Base.Value(ticket);

            /*if (!baseValue.HasValue) throw new ValidationException(
             *      new ValidationIssue("There is no base value assigned to the \"" + model.Security.Name + "\" security.")
             * );*/
            if (!baseValue.HasValue)
            {
#warning THE FOLLOWING IS A BUG BECAUSE EVEN THOUGH WE ASSIGN THE BASE VALUE TO 0 THIS VALUE DOESN'T GO BACK TO THE EXPRESSION IT BELONGS TO
                baseValue = 0;
            }

            var portfolioModelOpt = model.PortfolioTargets.Where(x => x.BroadGlobalActivePortfolio.Id == portfolio.Id).FirstOrDefault();
            if (portfolioModelOpt == null)
            {
                return(baseValue.Value);
            }

            var portfolioTarget = portfolioModelOpt.Target.Value(ticket);

            /*if (!portfolioTarget.HasValue) throw new ValidationException(
             *      new ValidationIssue("There is a portfolio target model which however doesn't have a value assigned.")
             * );*/
            if (!portfolioTarget.HasValue)
            {
                portfolioTarget = baseValue;
            }

            return(portfolioTarget.Value);
        }
Exemplo n.º 4
0
        public BroadGlobalActivePortfolioModel SerializeBroadGlobalActivePorfolio(BroadGlobalActivePortfolio broadGlobalActivePortfolio)
        {
            var result = new BroadGlobalActivePortfolioModel(
                broadGlobalActivePortfolio.Id,
                broadGlobalActivePortfolio.Name
                );

            return(result);
        }
Exemplo n.º 5
0
 public TargetRecord(
     BroadGlobalActivePortfolio portfolio,
     ISecurity security,
     Decimal target
     )
 {
     this.Portfolio = portfolio;
     this.Security  = security;
     this.Target    = target;
 }
Exemplo n.º 6
0
        protected void RecalculatePortfolio(
            TargetingType targetingType,
            BroadGlobalActivePortfolio portfolio,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager
            )
        {
            var portfolioRepository = this.repositoryManager.ClaimPortfolioRepository(manager);

            var root = this.bptManager.GetRootModel(
                targetingType.Id,
                portfolio.Id,
                false /* we coundn't care less about benchmarks at this point */,
                manager,
                "" /* we don't care about username here */
                );

            var ticket = new CalculationTicket();

            // let's see if computations are valid
            var issues = this.bptManager.Validate(root, ticket).ToList();

            if (issues.Any(x => x is ErrorIssue))
            {
                var issue = new CompoundValidationIssue("Unable to recalculate the \"" + portfolio.Name + "\" portfolio (ID: " + portfolio.Id + ").", issues);
                throw new ValidationException(issue);
            }

            var models = this.bptManager.Traverser.TraverseGlobe(root.Globe);

            foreach (var model in models)
            {
                try
                {
                    this.RecalculateModelOnceResolved(
                        model,
                        targetingType,
                        portfolio,
                        result,
                        manager,
                        ticket
                        );
                }
                catch (ValidationException exception)
                {
                    issues.Add(exception.Issue);
                }
            }

            if (issues.Any(x => x is ErrorIssue))
            {
                var issue = new CompoundValidationIssue("Unable to recalculate the \"" + portfolio.Name + "\" portfolio (ID: " + portfolio.Id + ").", issues);
                throw new ValidationException(issue);
            }
        }
Exemplo n.º 7
0
 public RecalculateModelOnceResolved_IModelResolver(
     Hopper hopper,
     TargetingType targetingType,
     BroadGlobalActivePortfolio portfolio,
     ICollection <BgaPortfolioSecurityTargetInfo> result,
     IDataManager manager,
     CalculationTicket ticket
     )
 {
     this.hopper        = hopper;
     this.targetingType = targetingType;
     this.portfolio     = portfolio;
     this.result        = result;
     this.manager       = manager;
     this.ticket        = ticket;
 }
Exemplo n.º 8
0
        protected void RecalculateModelOnceResolved(
            IModel model,
            TargetingType targetingType,
            BroadGlobalActivePortfolio portfolio,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager,
            CalculationTicket ticket
            )
        {
            var resolver = new RecalculateModelOnceResolved_IModelResolver(
                this,
                targetingType,
                portfolio,
                result,
                manager,
                ticket
                );

            model.Accept(resolver);
        }
Exemplo n.º 9
0
        public IExpression <Decimal?> CreatePortfolioTargetTotalExpression(
            BroadGlobalActivePortfolio portfolio,
            IEnumerable <SecurityModel> securities
            )
        {
            var expressions = securities.SelectMany(security =>
            {
                return(security
                       .PortfolioTargets
                       .Where(x => x.BroadGlobalActivePortfolio.Id == portfolio.Id)
                       .Select(portfolioModel =>
                {
                    IExpression <Decimal?> result;
                    var targetValue = portfolioModel.Target;
                    if (targetValue.EditedValue.HasValue)
                    {
                        result = targetValue;
                    }
                    else
                    {
                        var baseValue = security.Base;
                        if (baseValue.EditedValue.HasValue)
                        {
                            result = baseValue;
                        }
                        else
                        {
                            result = null;
                        }
                    }
                    return result;
                }));
            });

            return(new NullableSumExpression(
                       String.Format(ValueNames.PortfolioTargetTotalFormat, portfolio.Name),
                       expressions,
                       this.defaultValues.DefaultPortfolioTarget,
                       this.commonParts.ValidateEitheNullOr100
                       ));
        }
Exemplo n.º 10
0
        protected void RecalculateSecurityTargets(
            Decimal portfolioScaled,
            IBasket basket,
            TargetingType targetingType,
            BroadGlobalActivePortfolio portfolio,
            ICollection <BgaPortfolioSecurityTargetInfo> result,
            IDataManager manager,
            CalculationTicket ticket
            )
        {
            var securityRepositry            = this.repositoryManager.ClaimSecurityRepository(manager);
            var targetingTypeGroupRepository = this.repositoryManager.ClaimTargetingTypeGroupRepository(manager);
            var bpstRepository      = this.repositoryManager.CliamBasketPortfolioSecurityTargetRepository(manager);
            var ttgbsbvRepository   = this.repositoryManager.ClaimTargetingTypeGroupBasketSecurityBaseValueRepository(manager);
            var targetingTypeGroup  = targetingTypeGroupRepository.GetTargetingTypeGroup(targetingType.TargetingTypeGroupId);
            var portfolioRepository = this.repositoryManager.ClaimPortfolioRepository(manager);

            var core = this.bpstManager.GetCoreModel(
                targetingTypeGroup,
                basket,
                securityRepositry,
                ttgbsbvRepository,
                bpstRepository,
                portfolioRepository
                );

            this.MakeSureBpstCoreModelIsValid(core, ticket);

            foreach (var securityModel in core.Securities)
            {
                var unscaledTarget = this.ResolveToUnscaledTarget(portfolio, securityModel, ticket);
                var scaledTaget    = unscaledTarget * portfolioScaled;
                var targetInfo     = new BgaPortfolioSecurityTargetInfo(
                    portfolio.Id,
                    securityModel.Security.Id,
                    scaledTaget
                    );
                result.Add(targetInfo);
            }
        }
Exemplo n.º 11
0
 public PortfolioModel(BroadGlobalActivePortfolio portfolio, IExpression <Decimal?> portfolioTargetTotal)
 {
     this.Portfolio            = portfolio;
     this.PortfolioTargetTotal = portfolioTargetTotal;
 }
Exemplo n.º 12
0
 public PortfolioTargetModel(BroadGlobalActivePortfolio broadGlobalActivePortfolio, EditableExpression portfolioTargetExpression)
 {
     this.BroadGlobalActivePortfolio = broadGlobalActivePortfolio;
     this.Target = portfolioTargetExpression;
 }