Exemplo n.º 1
0
        public async Task <ActionResult> Index()
        {
            var news = (await _barchartClient.GetNews("AAPL"))?.ElementAt(0);

            ViewBag.News          = new NewsArticle(news.NewsID, news.Headline, news.FullText, news.LargeImageUrl);
            ViewBag.RelatedStocks = await _barchartClient.GetQuote(_symbols);

            return(View("News"));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> GetProfile(string symbol)
        {
            ViewBag.Profile = await _barchartClient.GetProfiles(symbol);

            ViewBag.Quote = (await _barchartClient.GetQuote(new[] { symbol }, new[] { "R" },
                                                            new[] { "previousClose", "bid", "ask", "fiftyTwoWkLow", "fiftyTwoWkHigh", "avgVolume" }))
                            ?.ElementAt(0);
            ViewBag.FinancialHighlight = (await _barchartClient.GetFinancialHighlights(new[] { symbol },
                                                                                       new[] { "beta", "peRatio", "ttmEPS" }))
                                         ?.ElementAt(0);
            ViewBag.Estimate = (await _barchartClient.GetEarningsEstimates(new[] { symbol },
                                                                           new[] { "exDividendDate", "dividendRate" }))
                               ?.ElementAt(0);
            ViewBag.Chart = await _barchartClient.GetChart(symbol);

            ViewBag.NewsArticles = (await _barchartClient.GetNews(symbol))
                                   .Take(10)
                                   .Select(n => new NewsArticle(n.NewsID, n.Headline, n.Preview));

            var earnings = await _barchartClient.GetCorporateActions(new[] { symbol }, null, null, EventType.earnings, 5);

            var dividends = await _barchartClient.GetCorporateActions(new[] { symbol }, null, null, EventType.dividend, 5);

            if (dividends == null)
            {
                ViewBag.Earnings = earnings.Select(e => new EarningsData {
                    Earnings = e
                });
            }
            else if (earnings == null)
            {
                ViewBag.Earnings = dividends.Select(d => new EarningsData {
                    Dividends = d
                });
            }
            else
            {
                ViewBag.Earnings = earnings.Join(dividends, e => e.EventDate.Month, d => d.EventDate.Month,
                                                 (e, d) => new EarningsData {
                    Earnings = e, Dividends = d
                });
            }

            return(View("Profile"));
        }
Exemplo n.º 3
0
 public async Task <ActionResult> Index()
 {
     ViewBag.NewsArticles = (await _barchartClient.GetNews(_symbol)).Select(n => new NewsArticle(n.NewsID, n.Headline, n.Preview));
     return(View());
 }