Exemplo n.º 1
0
        public Task <CompanyData> GetCompanyValuationData(string companyName)
        {
            _log.Info($"Start valuation for {companyName}");

            var stockTicker = _companyStockTickerRetriever.GetCompanyStockTicker(companyName);
            var keyPersons  = _companyKeyPersonsRetriever.GetKeyPersons(stockTicker).ToArray();
            var keyWords    = _keyWordsProvier.GetKeyWords();

            var companyData = new CompanyData
            {
                Name     = companyName,
                Category = "Corporate"
            };

            foreach (var keyWordGroup in keyWords.GroupBy(k => k.Category))
            {
                foreach (var keyPerson in keyPersons)
                {
                    var person = GetPerson(keyPerson, companyData);

                    var personScore = new PersonScore
                    {
                        Category = keyWordGroup.Key,
                        Passed   = true,
                        Sources  = new List <SearchEngineResult>()
                    };

                    person.Scores.Add(personScore);
                }

                companyData.Scores.Add(new CompanyScore
                {
                    Category = keyWordGroup.Key,
                    Score    = 0
                });
            }

            foreach (var companyDataMember in companyData.Members)
            {
                companyDataMember.TotalScore = companyDataMember.Scores.Count(s => !s.Passed);
            }

            var totalFailures = companyData.Members.Sum(m => m.TotalScore);
            var maxRisk       = companyData.Members.Count * companyData.Scores.Count;

            companyData.TotalScore = 100.0 * totalFailures / maxRisk;

            _log.Info($"Finish valuation for {companyName} score {companyData.TotalScore}");

            return(Task.FromResult(companyData));
        }
Exemplo n.º 2
0
        private static Person GetPerson(KeyPerson keyPerson, CompanyData companyData)
        {
            var existingPerson = companyData.Members.FirstOrDefault(p => p.Name == keyPerson.Name);

            if (existingPerson != null)
            {
                return(existingPerson);
            }

            var person = new Person
            {
                Name  = keyPerson.Name,
                Title = keyPerson.Title
            };

            companyData.Members.Add(person);

            return(person);
        }
Exemplo n.º 3
0
        public async Task <CompanyData> GetCompanyValuationData(string companyName)
        {
            _log.Info($"Start valuation for {companyName}");

            var stockTicker = _companyStockTickerRetriever.GetCompanyStockTicker(companyName);
            var keyPersons  = _companyKeyPersonsRetriever.GetKeyPersons(stockTicker).Take(10).ToArray();
            var keyWords    = _keyWordsProvier.GetKeyWords();

            var companyData = new CompanyData
            {
                Name     = companyName,
                Category = "Corporate"
            };

            foreach (var keyWordGroup in keyWords.GroupBy(k => k.Category))
            {
                var totalPassed = 0;
                foreach (var keyPerson in keyPersons)
                {
                    var person = GetPerson(keyPerson, companyData);

                    var results = new List <SearchEngineResult>();
                    foreach (var keyWord in keyWordGroup)
                    {
                        List <SearchEngineResult> collection = await _personEvaluationService.EvaluatePersonAsync(keyPerson.Name, keyWord.Word);

                        results.AddRange(collection);
                    }

                    var passed      = !results.Any();
                    var personScore = new PersonScore
                    {
                        Category = keyWordGroup.Key,
                        Passed   = passed,
                        Sources  = results
                    };

                    person.Scores.Add(personScore);

                    if (passed)
                    {
                        totalPassed++;
                    }
                }

                var nubmerOfFailed = keyPersons.Count() - totalPassed;

                companyData.Scores.Add(new CompanyScore
                {
                    Category = keyWordGroup.Key,
                    Score    = nubmerOfFailed
                });
            }

            foreach (var companyDataMember in companyData.Members)
            {
                companyDataMember.TotalScore = companyDataMember.Scores.Count(s => !s.Passed);
            }

            var totalFailures = companyData.Members.Sum(m => m.TotalScore);
            var maxRisk       = companyData.Members.Count * companyData.Scores.Count;

            companyData.TotalScore = 100.0 * totalFailures / maxRisk;

            companyData.Members = companyData.Members.OrderByDescending(m => m.TotalScore).ToList();

            _log.Info($"Finish valuation for {companyName} score {companyData.TotalScore}");

            return(companyData);
        }
Exemplo n.º 4
0
 public void SetCompanyValuationData(CompanyData companyData)
 {
     _companyDatas[companyData.Name] = companyData;
 }
        public async Task <CompanyData> GetCompanyValuationData(string companyName)
        {
            var stockTicker = _companyStockTickerRetriever.GetCompanyStockTicker(companyName);
            var keyPersons  = _companyKeyPersonsRetriever.GetKeyPersons(stockTicker).Take(5).ToArray();
            var keyWords    = _keyWordsProvier.GetKeyWords();

            var companyData = new CompanyData
            {
                Name     = companyName,
                Category = "Corporate"
            };

            foreach (var keyWordGroup in keyWords.GroupBy(k => k.Category))
            {
                var totalPassed = 0;
                foreach (var keyPerson in keyPersons)
                {
                    var person = GetPerson(keyPerson, companyData);

                    var results = new List <SearchEngineResult>();
                    foreach (var keyWord in keyWordGroup)
                    {
                        var collection = await _searchEngineService.Search(keyPerson.Name, keyWord.Word);

                        results.AddRange(collection);
                    }

                    var passed      = !results.Any();
                    var personScore = new PersonScore
                    {
                        Category = keyWordGroup.Key,
                        Passed   = passed,
                        Sources  = results
                    };

                    person.Scores.Add(personScore);

                    if (passed)
                    {
                        totalPassed++;
                    }
                }

                companyData.Scores.Add(new CompanyScore
                {
                    Category = keyWordGroup.Key,
                    // number of failed
                    Score = keyPersons.Count() - totalPassed
                });
            }

            foreach (var companyDataMember in companyData.Members)
            {
                companyDataMember.TotalScore = companyDataMember.Scores.Count(s => !s.Passed);
            }

            var totalFailures = companyData.Members.Sum(m => m.TotalScore);
            var maxRisk       = companyData.Members.Count * companyData.Scores.Count;

            companyData.TotalScore = 100.0 * totalFailures / maxRisk;

            return(companyData);
        }