Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private Core.PortfolioTargetModel DeserializePortfolioTarget(PortfolioTargetModel model)
        {
            var broadGlobalActivePorfolio = this.deserializer.DeserializeBroadGlobalActivePorfolio(model.BroadGlobalActivePortfolio);
            var porfolioTargetExpression  = this.modelBuilder.CreatePortfolioTargetExpression(broadGlobalActivePorfolio.Name);

            this.deserializer.PopulateEditableExpression(porfolioTargetExpression, model.PortfolioTarget);
            var result = new Core.PortfolioTargetModel(broadGlobalActivePorfolio, porfolioTargetExpression);

            return(result);
        }
        public PortfolioTargetModel DeserializePortfolioTarget(JsonReader reader, PortfolioRepository portfolioRepository)
        {
            var portfolioId  = reader.ReadAsString(JsonNames.PortfolioId);
            var bgaPortfolio = portfolioRepository.GetBroadGlobalActivePortfolio(portfolioId);
            var portfolioTargetExpression = this.modelBuilder.CreatePortfolioTargetExpression(bgaPortfolio.Name);

            reader.Read(JsonNames.Target, delegate
            {
                this.expressionDeserializer.PopulateEditableExpression(reader, portfolioTargetExpression);
            });

            var result = new PortfolioTargetModel(bgaPortfolio, portfolioTargetExpression);

            return(result);
        }
Exemplo n.º 4
0
 protected void Validate(PortfolioTargetModel portfolioTarget, List <IValidationIssue> issues)
 {
     issues.AddRange(portfolioTarget.Target.Validate());
 }
 public void SerializePortfolioTarget(EditableExpression baseExpression, PortfolioTargetModel portfolioTarget, IJsonWriter writer)
 {
     writer.Write(portfolioTarget.BroadGlobalActivePortfolio.Id, JsonNames.PortfolioId);
     this.expressionSerializer.Serialize(portfolioTarget.Target, JsonNames.Target, writer, baseExpression.EditedValue);
 }
Exemplo n.º 6
0
        private PortfolioTargetModel SerializePortfolioTarget(EditableExpression baseExpression, Core.PortfolioTargetModel model)
        {
            var result = new PortfolioTargetModel(
                this.serializer.SerializeBroadGlobalActivePorfolio(model.BroadGlobalActivePortfolio),
                this.serializer.SerializeEditableExpression(model.Target, baseExpression.EditedValue)
                );

            return(result);
        }