/// <summary> /// Get company list. /// </summary> /// <param name="exchange">The exchange to get the company names.</param> /// <returns>List of companies.</returns> public async Task <IEnumerable <Company> > GetCompanyListAsync(ExchangeSymbol exchange) { string url = $"https://old.nasdaq.com/screening/companies-by-name.aspx?exchange={exchange}&render=download"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate, br"); request.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-US,en;q=0.9"); using (HttpWebResponse response = (HttpWebResponse)(await request.GetResponseAsync())) using (Stream responseStream = response.GetResponseStream()) using (TextReader reader = new StreamReader(responseStream)) { string[] header = CSV.Import(reader); IEnumerable <Company> companies = CSV.ImportToArray(reader) .Select(r => new Company { Symbol = r[0], Name = r[1], LastSale = Parse.NullFloat(r[2]), MarketCap = r[3], IPOyear = Parse.NullInt(r[4]), Sector = r[5], Industry = r[6], SummaryQuote = r[7] }); return(companies.ToArray()); } //// "Symbol","Name","LastSale","MarketCap","IPOyear","Sector","industry","Summary Quote", //// https://old.nasdaq.com/screening/companies-by-industry.aspx //// https://api.nasdaq.com/api/screener/stocks?tableonly=true&limit=25&offset=0&download=true }
public async Task TestGetCompanyListAsync(ExchangeSymbol exchange) { var client = new NasdaqCompanyListClient(); IEnumerable <Company> result = await client.GetCompanyListAsync(exchange); Assert.NotNull(result); Assert.True(result.Any(), $"No results for {exchange}."); Company company = result.First(); Assert.IsType <string>(company.Symbol); }
public override int GetHashCode() { unchecked { var hashCode = (SymbolId != null ? SymbolId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExchangeId != null ? ExchangeId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ExchangeSymbol != null ? ExchangeSymbol.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BaseAsset != null ? BaseAsset.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (QuoteAsset != null ? QuoteAsset.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TradeTypeAsString != null ? TradeTypeAsString.GetHashCode() : 0); return(hashCode); } }
public static List <ExchangeSymbol> GetSymbols(List <Exchange> exchanges) { List <ExchangeSymbol> exchangeSymbols = new List <ExchangeSymbol>(); foreach (Exchange exchange in exchanges) { ExchangeSymbol exchangeSymbol = new ExchangeSymbol(); exchangeSymbol.Exchange = exchange; exchangeSymbol.Symbols = GetSymbolForMarket(exchange);; exchangeSymbols.Add(exchangeSymbol); } return(exchangeSymbols); }