예제 #1
0
        protected Dictionary <String, BottomUpPortfolio> GetBottomUpPortfolios(
            IEnumerable <PortfolioInfo> portfolioInfos,
            SecurityRepository securityRepository
            )
        {
            var result = new Dictionary <String, BottomUpPortfolio>();

            foreach (var portfolioInfo in portfolioInfos)
            {
                if (securityRepository.IsPortfolioAFund(portfolioInfo.Id))
                {
                    var bottomUpPortfolio = new BottomUpPortfolio(
                        portfolioInfo.Id,
                        portfolioInfo.Name,
                        securityRepository.GetFundByPorfolioId(portfolioInfo.Id)
                        );
                    result.Add(bottomUpPortfolio.Id, bottomUpPortfolio);
                }
                else
                {
                    if (portfolioInfo.IsBottomUp)
                    {
                        var bottomUpPortfolio = new BottomUpPortfolio(
                            portfolioInfo.Id,
                            portfolioInfo.Name,
                            null
                            );
                        result.Add(bottomUpPortfolio.Id, bottomUpPortfolio);
                    }
                }
            }
            return(result);
        }
예제 #2
0
        public SecurityRepository CreateSecurityRepository(
            Func <CountryRepository> ondemandCountryRepository,
            IEnumerable <SecurityInfo> securities)
        {
            var repository = new SecurityRepository(
                this.monitor,
                securities,
                ondemandCountryRepository()
                );

            return(repository);
        }
예제 #3
0
 public SecurityRepository ClaimSecurityRepository(
     Func <IEnumerable <SecurityInfo> > ondemandSecurities,
     Func <CountryRepository> ondemandCountryRepository)
 {
     return(this.securityRepositoryStorage.Claim(SecurityManagerCacheKey, delegate
     {
         var securities = ondemandSecurities();
         var countryRepository = ondemandCountryRepository();
         var repository = new SecurityRepository(
             this.monitor,
             securities,
             countryRepository
             );
         return repository;
     }));
 }
예제 #4
0
 public SecurityRepository ClaimSecurityRepository(
     IDataManager manager,
     Func <CountryRepository> ondemandCountryRepository
     )
 {
     return(this.securityRepositoryStorage.Claim(SecurityManagerCacheKey, delegate
     {
         var securities = manager.GetAllSecurities();
         var repository = new SecurityRepository(
             this.monitor,
             securities,
             ondemandCountryRepository()
             );
         return repository;
     }));
 }
예제 #5
0
        public PortfolioRepository(
            IEnumerable <PortfolioInfo> portfolios,
            SecurityRepository securityRepository
            )
        {
            var bottomUpPortfolios = this.GetBottomUpPortfolios(portfolios, securityRepository);

            if (!bottomUpPortfolios.Any())
            {
                throw new ApplicationException("There are no bottom up portfolios at all, check your database.");
            }
            this.bottomUpPortfolios = bottomUpPortfolios;

            this.bottomUpPortfolioBySecurityId = this.bottomUpPortfolios.Select(x => x.Value).Where(x => x.Fund != null).ToDictionary(x => x.Fund.Id);

            this.broadGlobalActivePortfolios = portfolios
                                               .Where(x => !x.IsBottomUp)
                                               .Select(x => new BroadGlobalActivePortfolio(
                                                           x.Id,
                                                           x.Name
                                                           )).ToDictionary(x => x.Id);
        }
예제 #6
0
        internal object PrepareToSend(ChangingTtbpt.Changeset changeset, IDataManager manager, Aims.Core.SecurityRepository securityRepository, ManagingBaskets.BasketRepository basketRepository, String ttName, String portfolioName)
        {
            var result = new List <String>();

            if (changeset != null)
            {
                var date = DateTime.Now;
                foreach (var change in changeset.Changes)
                {
                    var resolver = new Mail_IChangeResolver(this, manager, securityRepository, basketRepository, result, changeset.Username, date, ttName, portfolioName);
                    change.Accept(resolver);
                }
            }

            return(result);
        }
예제 #7
0
        internal List <String> PrepareToSend(Changeset changeset, IDataManager manager, Aims.Core.SecurityRepository securityRepository)
        {
            var result = new List <String>();

            if (changeset != null)
            {
                var date = DateTime.Now;
                foreach (var change in changeset.Changes)
                {
                    var resolver = new Mail_IChangeResolver(this, manager, securityRepository, result, changeset.Username, date);
                    change.Accept(resolver);
                }
            }

            return(result);
        }