Esempio n. 1
0
        public async Task <IEnumerable <Instrument> > GetTheBestDiscountDividendCompanies(double discountRate)
        {
            try
            {
                var instruments = await _instrumentRepository.GetSymbolsParseHtml();

                var costEffectiveInstruments = new List <Instrument>();
                foreach (var instrument in instruments)
                {
                    var dividend = await _instrumentRepository.GetDividends(instrument.Isin);

                    instrument.AddDividends(dividend);
                    var priceRequired = new DiscountDividendModel(instrument.Dividends.Select(x => x.Price).ToArray(), discountRate).Value;
                    if (instrument.Valuation.BidPrice < priceRequired)
                    {
                        costEffectiveInstruments.Add(instrument);
                    }
                }
                return(costEffectiveInstruments);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "GetTheBestDiscountDividendCompanies");
                throw e;
            }
        }