Exemplo n.º 1
0
        public async Task <string> GetFinancialSummary(string symbol)
        {
            var profile = await _barchartClient.GetProfiles(symbol);

            var quote = (await _barchartClient.GetQuote(new[] { symbol }, new[] { "D" },
                                                        new[] { "previousClose", "avgVolume", "averageWeeklyVolume" }))
                        ?.ElementAt(0);
            var technical = (await _barchartClient.GetTechnicals(new[] { symbol },
                                                                 new[] { "priceChangeYTD" }))?.ElementAt(0);
            var earning = await _barchartClient.GetCorporateActions(symbol, EventType.earnings);

            var dividend = await _barchartClient.GetCorporateActions(symbol, EventType.dividend);

            var estimate = await _barchartClient.GetEarningsEstimates(symbol);

            var oneDayVolumeChange  = (float)quote.Volume / quote.AvgVolume.Value - 1;
            var fiveDayVolumeChange = (float)quote.AverageWeeklyVolume.Value / quote.AvgVolume.Value - 1;
            var earningsChange      = (float)earning.Value / estimate.AverageEstimate - 1;

            return($"<h4>About {profile.ExchangeName}</h4>" +
                   $"<ul><li>{symbol} is at ${quote.LastPrice}, a {quote.PercentChange}% change from last trading day close of ${quote.PreviousClose}.</li>" +
                   $"<li>{symbol} had a volume of {quote.Volume}, {Math.Abs(oneDayVolumeChange): 0.##}% {(oneDayVolumeChange > 0 ? "above" : "below")} the year-to day volume of {quote.AvgVolume}." +
                   $" The average volume over the last five days ({quote.AverageWeeklyVolume}) is {(fiveDayVolumeChange > 0 ? "up" : "down")} {Math.Abs(fiveDayVolumeChange): 0.##}% compared to the average.</li>" +
                   $"<li>{symbol} has {(technical.PriceChangeYtd > 0 ? "increased" : "decreased")} {Math.Abs(technical.PriceChangeYtd.Value)}% since the start of the year.</li>" +
                   $"<li>{symbol} earnings of {earning.Value} is {Math.Abs(earningsChange): 0.##}% {(earningsChange > 0 ? "higher" : "lower")} than {estimate.AverageEstimate} as estimated.</li>" +
                   $"{(dividend != null ? $"<li>{symbol} last dividend was {dividend.Value}.</li></ul>" : "")}");
        }
Exemplo n.º 2
0
        public void GetTechnicals()
        {
            var technical = _barchartClient.GetTechnicals(_symbol).Result;

            Assert.AreEqual(technical.Symbol, _symbol);
        }