public async Task Get(StrategyRequest request) { await _stocksRepository.DeleteIncomeStatementEntities(); await _stocksRepository.DeleteStockProfileEntities(); await _stocksRepository.DeleteBalanceSheetEntities(); var sortedStocks = await _stockListService.GetSortedStocks(new DCFRequest() { DividendMoreThan = request.Dividend, MarketCapMoreThan = request.MarketCapMoreThan, Sector = request.Sector, VolumeMoreThan = request.VolumeMoreThan }); foreach (var item in sortedStocks) { await _balanceSheetProvider.GetBalanceSheets(item.Symbol); } var stockSplits = ListExtensions.Split(sortedStocks, 5); foreach (var stockSplit in stockSplits) { var stockSymbols = StringExtensions.GetSymbolsString(stockSplit.Select(x => x.Symbol).ToArray()); var stockProfiles = await _profileProvider.GetStockProfile(stockSymbols); } foreach (var stock in sortedStocks) { await _incomeStatementProvider.GetIncomeStatements(stock.Symbol); } }
public async Task GetStockPrices(int dividend, long marketCapMoreThan, DateTime from, DateTime to, string sector, long volumeMoreThan) { await _stocksRepository.DeleteAllStockPriceHistoricEntities(); var sortedStocks = await _stockListService.GetSortedStocks(new DCFRequest() { DividendMoreThan = dividend, MarketCapMoreThan = marketCapMoreThan, Sector = sector, VolumeMoreThan = volumeMoreThan }); var splitList = ListExtensions.Split(sortedStocks, 5); foreach (var stockItem in splitList) { var dbEntities = new List <StockPriceHistoricEntity>(); var stockSymbols = StringExtensions.GetSymbolsString(stockItem.Select(x => x.Symbol).ToArray()); var historicPrices = await _stockPriceService.GetHistoricPrices(stockSymbols, from, to); if (historicPrices.HistoricalStockList != null) { foreach (var historicPrice in historicPrices.HistoricalStockList) { var stockEntities = _mapper.Map <List <StockPriceHistoricEntity> >(historicPrice.Historical); foreach (var stockEntity in stockEntities) { stockEntity.Symbol = historicPrice.Symbol; } dbEntities.AddRange(stockEntities); } } await _stocksRepository.SaveStockPriceHistoricEntities(dbEntities); } var spyPrice = await _stockPriceService.GetHistoricPrices($"SPY?from={from.ToString("yyyy-MM-dd")}&to={to.ToString("yyyy-MM-dd")}"); var spyEntities = _mapper.Map <List <StockPriceHistoricEntity> >(spyPrice.Historical); foreach (var stockEntity in spyEntities) { stockEntity.Symbol = spyPrice.Symbol; } spyEntities.AddRange(spyEntities); await _stocksRepository.SaveStockPriceHistoricEntities(spyEntities); }
public async Task UpdateDCFs(DCFRequest request) { var stocks = await _stockListService.GetSortedStocks(request); foreach (var stock in stocks) { await _stocksRepository.DeleteDCF(stock.Symbol); var stockDcfs = await _dcfService.GetDividendCalendar2(stock.Symbol); foreach (var dcf in stockDcfs) { var dbStockDcfs = _mapper.Map <List <Historical_discounted_cash_flow_Entity> >(dcf); foreach (var dbDcf in dbStockDcfs) { dbDcf.Symbol = stock.Symbol; } await _stocksRepository.SaveDCFs(dbStockDcfs); } } }
public async Task <IActionResult> GetSortedStockList(DCFRequest request) { var result = await _stockListService.GetSortedStocks(request); return(Ok(result.Count)); }