Exemplo n.º 1
0
 internal void MailUpdateChange(UpdateChange change, IDataManager dataManager, SecurityRepository securityRepository, List<String> mailMessage, String username, DateTime date)
 {
     StringBuilder bodyAppendix = new StringBuilder("\n");
     bodyAppendix.AppendLine("---" + date + ", Approved by: " + username + "---");
     var security = securityRepository.FindSecurity(change.SecurityId);
     bodyAppendix.AppendLine("Adjustment for Portfolio " + change.PortfolioId + " of " + security.Name + "(" + security.ShortName + ") from " + MailSender.TransformTargetToString(change.TargetBefore) + " to " + MailSender.TransformTargetToString(change.TargetAfter));
     bodyAppendix.AppendLine("COMMENT: " + change.Comment);
     mailMessage.Add(bodyAppendix.ToString());
 }
Exemplo n.º 2
0
        internal void MailDeleteChange(DeleteChange change, IDataManager dataManager, SecurityRepository securityRepository, List <String> mailMessage, String username, DateTime date)
        {
            StringBuilder bodyAppendix = new StringBuilder("\n");

            bodyAppendix.AppendLine("---" + date + ", Approved by: " + username + "---");
            var security = securityRepository.FindSecurity(change.SecurityId);

            bodyAppendix.AppendLine("Adjustment for BASE: " + security.Name + "(" + security.ShortName + ") was removed [last target was " + MailSender.TransformTargetToString(change.BaseValueBefore) + "]");
            bodyAppendix.AppendLine("COMMENT: " + change.Comment);
            mailMessage.Add(bodyAppendix.ToString());
        }
Exemplo n.º 3
0
        private void MailUpdateChange(PstUpdateChange change, IDataManager dataManager, SecurityRepository securityRepository, MailMessage mailMessage, String username, DateTime date)
        {
            this.PortfolioName = change.PortfolioId;
            StringBuilder bodyAppendix = new StringBuilder("\n");

            bodyAppendix.AppendLine("---" + date + ", Approved by: " + username + "---");
            var security = securityRepository.FindSecurity(change.SecurityId);

            bodyAppendix.AppendLine(security.Name + "(" + security.ShortName + ") from " + MailSender.TransformTargetToString(change.TargetBefore) + " to " + MailSender.TransformTargetToString(change.TargetAfter));
            bodyAppendix.AppendLine("COMMENT: " + change.Comment);
            mailMessage.Body += bodyAppendix;
        }
Exemplo n.º 4
0
        private List <TradingTargetRecord> GetLines(SecurityRepository securityRepository, IDataManager dataManager)
        {
            //SecurityRepository securities = repositoryMananer.ClaimSecurityRepository(dataManager);
            var targets = dataManager.GetAllTargets();
            var result  = targets.Select(x => new TradingTargetRecord(x.PortfolioId, securityRepository.FindSecurity(x.SecurityId), x.Target)).ToList();

            var groups = result.GroupBy(x => new GroupKey {
                PortfolioId = x.PortfolioId, CountryCode = x.Security.IsoCountryCode
            })
                         .Select(x => new { Key = x.Key, Total = x.Sum(y => y.Target) })
                         .ToDictionary(x => x.Key);

            foreach (var r in result)
            {
                var key = new GroupKey {
                    CountryCode = r.Security.IsoCountryCode, PortfolioId = r.PortfolioId
                };
                if (groups.ContainsKey(key))
                {
                    r.SumByCountry = groups[key].Total;
                    if (r.SumByCountry != 0)
                    {
                        r.PercentByContry = r.Target / r.SumByCountry;
                    }
                }
            }

            var groupsByPortfolio = result.GroupBy(x => x.PortfolioId).Select(x => new { Key = x.Key, Total = x.Sum(y => y.Target) });

            foreach (var r in groupsByPortfolio)
            {
                // cash account line
                var record = new TradingTargetRecord(r.Key, new CompanySecurity("MODOFFSET", "", "MODOFFSET", "", new Country("US", "USA"), "", "", "USD", "", "US"), 1 - r.Total);
                record.SumByCountry    = record.Target;
                record.PercentByContry = 1;
                result.Add(record);
            }
            var proxyportfolios = dataManager.GetAllProxyPortfolios();

            foreach (var proxy in proxyportfolios)
            {
                var lists     = result.Where(x => x.PortfolioId == proxy.ProxyPortfolioId).ToList(); // get the list of targets for proxy portfolio
                var cloneList = CloneList(lists);                                                    //clone the list
                cloneList.ForEach(s => s.PortfolioId = proxy.PortfolioId);
                //below to lines replace the targets of actual portfolio with the proxy portfolio
                result.RemoveAll(x => x.PortfolioId == proxy.PortfolioId);
                // replace the proxy portfolio with the actual portfolio)
                result.AddRange(cloneList);
            }

            return(result);
        }