Пример #1
0
        public PortfolioSecurityTargetRepository ClaimRepository(
            BuPortfolioSecurityTargetChangesetInfo latestChangesetSnapshoot,
            IDataManager manager
            )
        {
            var found = this.storage[StorageKey];

            if (found != null)
            {
                var latestChangeset = manager.GetLatestPortfolioSecurityTargetChangeSet();
                if (latestChangesetSnapshoot.Id < latestChangeset.Id)
                {
                    throw new ValidationException(
                              new ErrorIssue("User \"" + latestChangeset.Username + "\" modified the bottom-up-portfolio/security/target composition on " + latestChangeset.Timestamp + ".")
                              );
                }
                else
                {
                    return(found);
                }
            }
            else
            {
                var targetInfos = manager.GetAllPortfolioSecurityTargets();
                found = new PortfolioSecurityTargetRepository(this.copier, targetInfos);
                this.storage[StorageKey] = found;
                return(found);
            }
        }
Пример #2
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;
 }
Пример #3
0
        protected BuPortfolioSecurityTargetChangesetInfo DeserializeBuPortfolioSecurityTargetChangesetInfo(ChangesetModel model)
        {
            var result = new BuPortfolioSecurityTargetChangesetInfo(
                model.Id,
                model.Username,
                model.Timestamp,
                model.CalculationId
                );

            return(result);
        }
        public BuPortfolioSecurityTargetChangesetInfo ReadLastChangeset(JsonReader reader)
        {
            var result = new BuPortfolioSecurityTargetChangesetInfo
            {
                Id        = reader.ReadAsInt32(JsonNames.Id),
                Username  = reader.ReadAsString(JsonNames.Username),
                Timestamp = reader.ReadAsDatetime(JsonNames.Timestamp),
            };

            return(result);
        }
        protected BuPortfolioSecurityTargetChangesetInfo DeserializePortfolioSecurityTargetChangeset(JsonReader reader)
        {
            var result = new BuPortfolioSecurityTargetChangesetInfo(
                reader.ReadAsInt32(JsonNames.Id),
                reader.ReadAsString(JsonNames.Username),
                reader.ReadAsDatetime(JsonNames.Timestamp),
                reader.ReadAsInt32(JsonNames.CalcualtionId)
                );

            return(result);
        }
Пример #6
0
        public ManagingPst.PortfolioSecurityTargetRepository ClaimPortfolioSecurityTargetRepository(
            BuPortfolioSecurityTargetChangesetInfo latestPstChangesetInfo,
            IDataManager manager
            )
        {
            var result = this.portfolioSecurityTargerManager.ClaimRepository(
                latestPstChangesetInfo,
                manager
                );

            return(result);
        }
Пример #7
0
 public RootModel(
     String porfolioId,
     BuPortfolioSecurityTargetChangesetInfo latestChangesetInfo,
     IEnumerable <ItemModel> items,
     NullableSumExpression targetTotalExpression,
     IExpression <Decimal?> cashExpression
     )
 {
     this.PortfolioId     = porfolioId;
     this.LatestChangeset = latestChangesetInfo;
     this.Items           = items.ToList();
     this.TargetTotal     = targetTotalExpression;
     this.Cash            = cashExpression;
 }
Пример #8
0
        public void Apply(Int32 calculationId, Changeset changeset, IDataManager manager)
        {
            var latestChangeSet = manager.GetLatestPortfolioSecurityTargetChangeSet();

            if (changeset.LatestChangeset.Id < latestChangeSet.Id)
            {
                throw new ValidationException(
                          new ErrorIssue("User \"" + latestChangeSet.Username + "\" modified the P-S-T composition on " + latestChangeSet.Timestamp + ".")
                          );
            }

            var changesetIdRange = manager.ReservePortfolioSecurityTargetChangesetIds(1);

            if (!changesetIdRange.MoveNext())
            {
                throw new ApplicationException("There is no ID reserved for the P-S-T changeset.");
            }
            var changesetId = changesetIdRange.Current;


            var changesetInfo = new BuPortfolioSecurityTargetChangesetInfo(
                changesetId,
                changeset.Username,
                DateTime.Now, /* is going to be ignored */
                calculationId
                );

            manager.InsertPortfolioSecurityTargetChangeset(changesetInfo);

            var changes       = changeset.Changes;
            var changeIdRange = manager.ReservePortfolioSecurityTargetChangeIds(changes.Count());

            foreach (var change in changes)
            {
                if (!changeIdRange.MoveNext())
                {
                    throw new ApplicationException("There is no ID reserved for the P-S-T change.");
                }
                var changeId = changeIdRange.Current;

                var resolver = new Apply_IPstChangeResolver(this, manager, changesetId, changeId);
                change.Accept(resolver);
            }
        }
Пример #9
0
 public void Write(JsonWriter writer, BuPortfolioSecurityTargetChangesetInfo changesetInfo)
 {
     writer.Write(changesetInfo.Id, JsonNames.Id);
     writer.Write(changesetInfo.Username, JsonNames.Username);
     writer.Write(changesetInfo.Timestamp, JsonNames.Timestamp);
 }
Пример #10
0
 public Changeset(BuPortfolioSecurityTargetChangesetInfo latestChangeset, String username, IEnumerable <IPstChange> changes)
 {
     this.LatestChangeset = latestChangeset;
     this.Username        = username;
     this.Changes         = changes.ToList();
 }
Пример #11
0
 public void Resolve(BuPortfolioSecurityTargetChangesetInfo changesetInfo)
 {
     this.Result = "Bottom-up-portfolio/Security target";
 }
Пример #12
0
 protected void SerializePortfolioSecurityTargetChangeset(
     BuPortfolioSecurityTargetChangesetInfo changesetInfo, IJsonWriter writer)
 {
     this.SerializeChangeset(changesetInfo, writer);
 }