private async Task PrintFiveYearStats(string symbol)
        {
            //Five year period ends at the first event start date
            var fiveYearStats = await _yearlyStatsService.GetMinAndAvg(symbol, firstEventStartDate, 5);

            WriteLine($"5 Year Min: {fiveYearStats.Min}", ConsoleColor.Green);
            WriteLine($"5 Year Avg: {fiveYearStats.Avg}", ConsoleColor.Green);
        }
示例#2
0
        private async Task <StockReport> CreateStockReportModel(
            string symbol,
            string companyName,
            string category,
            DateTime event1Start,
            DateTime event2Start)
        {
            var stockReport = new StockReport
            {
                CompanyName = companyName,
                Symbol      = symbol,
                Category    = category
            };

            stockReport.CurrentPrice =
                (await _quoteApiService.Get(symbol)).Quote.Price;

            var dailyTimeSeries = await _dailyTimeSeriesApiService.Get(symbol);

            stockReport.ChangeFromEvent1ToEvent2     = _statisticsService.Difference(dailyTimeSeries, event1Start, event2Start.AddDays(-1));
            stockReport.ChangeFromEvent2ToReportDate = _statisticsService.Difference(dailyTimeSeries, event2Start, DateTime.Now.Date);


            var yearlyStats = await _yearlyStatsService.GetMinAndAvg(
                symbol,
                event1Start,
                new List <int> {
                1, 2, 3, 4, 5
            });

            stockReport.YearlyStats = yearlyStats.Select(y => new StockReportYearlyStats
            {
                NumberOfYearsPriorToEvent1 = y.NumberOfYears,
                Min = y.Min,
                Avg = y.Avg
            }).ToList();
            return(stockReport);
        }