private async Task <bool> TickerAsStock(string symbolOrName) { var result = await _stocks.GetQuote(symbolOrName); if (result != null) { var change = ""; var delta = result.Price - result.Open; if (delta > 0) { change += "up "; } else { change += "down"; } change += $"{(delta / result.Price):P}"; await TypingReplyAsync($"{result.Symbol} is trading at {result.Price:0.00}, {change} since opening today"); return(true); } return(false); }
private async Task <bool> TickerAsStock(string symbolOrName) { var result = await _stocks.GetQuote(symbolOrName); if (result != null) { //Try to find the name of the stock var symbol = await _search.Search(result.Symbol) .Where(a => a.Symbol.Equals(result.Symbol, StringComparison.OrdinalIgnoreCase)) .Cast <IStockSearchResult?>() .FirstOrDefaultAsync(); var change = ""; var delta = result.Price - result.Open; if (delta != 0) { if (delta > 0) { change += "up"; } else if (delta < 0) { change += "down"; } change += $" {delta / result.Price:P}"; } else { change += "no change"; } var name = symbol == null ? "" : $"({symbol.Name}) "; await TypingReplyAsync($"{result.Symbol} {name}is trading at {result.Price:0.00}, {change} since opening today"); return(true); } return(false); }