Esempio n. 1
0
        public void GenerateAnalyses()
        {
            _logger.Info("Generating analyses ...");

            var marketData = _marketDataRepository.GetAll().ToList();

            if (ContainsDataWithoutIsin(marketData))
            {
                throw new BusinessException("There are marketdata without ISIN. No analysis generated.");
            }

            _logger.Info("Removing discontinued market data rows.");
            var latestDate = marketData.Max(d => d.DateTime).Date;

            RemoveEntriesWithoutUptodateData(marketData, latestDate);
            _logger.Info($"Having discontinued market data rows removed {marketData.Count} data entries remained.");

            var groupedMarketData = from data in marketData
                                    group data by data.Isin into dataByIsin
                                    select dataByIsin
                                    .OrderByDescending(d => d.DateTime)
                                    .Take(_slowMovingAverage);

            var analyses = groupedMarketData.Select(GetAnalysis).ToImmutableList();

            if (!analyses.Any())
            {
                _logger.Info("No analyses generated.");
                return;
            }

            _logger.Info($"{analyses} analyses generated.");

            _logger.Debug("Adding analyses to repository ...");
            _financialAnalysesCsvFileRepository.AddRange(analyses);
            _logger.Debug("Analyses added.");

            _logger.Debug("Saving analyses to repository ...");
            _financialAnalysesCsvFileRepository.SaveChanges();
            _logger.Debug("Analyses saved.");

            _logger.Info("*** *** ***");
        }
Esempio n. 2
0
        public void GenerateAnalyses()
        {
            _logger.Info("Start generating analyses.");

            var marketData = _marketDataRepository.GetAll().ToList();

            if (ContainsDataWithoutIsin(marketData))
            {
                throw new BusinessException("There are marketdata without ISIN. No analysis generated.");
            }

            _logger.Info("Removing discontinued market data rows.");
            RemoveEntriesWithoutUptodateData(marketData);
            _logger.Info($"Having discontinued market data rows removed {marketData.Count} data entries remained.");

            _logger.Info("Filtering registry entries.");
            var filteredRegistry = new Registry(
                _registryRepository
                .GetAll()
                .Where(RegistryItemIsInteresting));

            _logger.Info($"{filteredRegistry.Count()} registry entry found with positive EPS.");

            var groupedMarketData = from data in marketData
                                    where filteredRegistry.ContainsKey(data.Isin)
                                    group data by data.Isin into dataByIsin
                                    select dataByIsin
                                    .OrderByDescending(d => d.DateTime)
                                    .Take(_slowMovingAverage);

            var analyses = groupedMarketData.Select(GetAnalysis);

            _logger.Info($"{analyses.Count()} analyses generated.");

            _financialAnalysesCsvFileRepository.AddRange(analyses);
            _financialAnalysesCsvFileRepository.SaveChanges();
        }