如何从Yahoo Finance获得股票代码的完整列表?

我已经无休止地search了一个方法,通过http://finance.yahoo.com获取所有雅虎股票代码符号的完整(和每日更新)列表

雅虎拥有全球很多交易所的股票,期货等信息,我希望通过它们提供所有可用的股票代码的组合列表。 我试过YQL,但他们有一个“符号=(或in)”的条款限制,所以我不能从符号中select*。

所以基本上,一次获得单个符号或几个符号的详细信息是很容易的,但我似乎无法find如何获得所有可用代码的列表。

任何人都可以帮忙吗?

http://code.google.com/p/yahoo-finance-managed/上有一个用于Yahoo.Finance API的漂亮的C#包装器,它可以帮助你。 不幸的是,没有直接的方式来下载股票列表,但是下面通过遍历字母组来创build列表:

AlphabeticIDIndexDownload dl1 = new AlphabeticIDIndexDownload(); dl1.Settings.TopIndex = null; Response<AlphabeticIDIndexResult> resp1 = dl1.Download(); writeStream.WriteLine("Id|Isin|Name|Exchange|Type|Industry"); foreach (var alphabeticalIndex in resp1.Result.Items) { AlphabeticalTopIndex topIndex = (AlphabeticalTopIndex) alphabeticalIndex; dl1.Settings.TopIndex = topIndex; Response<AlphabeticIDIndexResult> resp2 = dl1.Download(); foreach (var index in resp2.Result.Items) { IDSearchDownload dl2 = new IDSearchDownload(); Response<IDSearchResult> resp3 = dl2.Download(index); int i = 0; foreach (var item in resp3.Result.Items) { writeStream.WriteLine(item.ID + "|" + item.ISIN + "|" + item.Name + "|" + item.Exchange + "|" + item.Type + "|" + item.Industry); } } } 

它在大约4分钟的时间里给了我一份约75,000份证券的清单。

我设法做了类似的使用这个url:

http://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20yahoo.finance.industry%20where%20id%20in%20(从%20yahoo.finance中select%20industry.id%20 .sectors)的env =商店%3A%2F%2Fdatatables.org%2Falltableswithkeys

它使用Yahoo YQL API下载完整的股票代码列表,包括股票名称,股票代码和行业ID。 它似乎没有任何种类的股票符号修饰符。 例如罗杰斯通讯公司,它只下载RCI,而不是RCI-A.TO,RCI-B.TO等。我还没有find该信息的来源,但如果有人知道一个方法来自动下载,我我想听听。 另外,find一种方法来下载股票代码和交易所之间的某种关系,因为有些交易是在多个交易所进行的,或者我只想看看TSX上的东西。

我有一个类似的问题。 雅虎不提供它,但你可以通过查看nyse.com列表上的document.write语句,并find.js文件,在那里他们刚刚存储公司的列表,以给定的字母作为js数组文字。 您也可以在这里从nasdaq.com获得漂亮的csv文件: http : //www.nasdaq.com/screening/companies-by-name.aspx? letter=0&exchange=nasdaq&render=download(用exchange = nysereplaceexchange = nasdaq对于nyse符号)。

纳斯达克股票列表ftp://ftp.nasdaqtrader.com/symboldirectory

2个文件nasdaqlisted.txt和otherlisted.txt是| pipe分离。 这应该给你一个所有股票的好名单。

我可能会帮助(美国和非美国)股票和ETF的股票代码列表。

雅虎提供了一个收益日历,列出所有宣布给定date收益的股票。 这包括非美股。

例如,今天是: http : //biz.yahoo.com/research/earncal/20120710.html

url的最后一部分是您希望收入日历的date(采用YYYYMMDD格式)。 您可以循环几天,并在当天报告收益的所有股票的符号。

雅虎并不保证所有股票都有报告收益的数据,尤其是因为一些股票不存在(破产,收购等),但这可能是一个不错的起点。

如果您熟悉R ,则可以使用qmao软件包来执行此操作。 (见这篇文章 ),如果你有麻烦安装它。

 ec <- getEarningsCalendar(from="2011-01-01", to="2012-07-01") #this may take a while s <- unique(ec$Symbol) length(s) #[1] 12223 head(s, 20) #look at the first 20 Symbols # [1] "CVGW" "ANGO" "CAMP" "LNDC" "MOS" "NEOG" "SONC" # [8] "TISI" "SHLM" "FDO" "FC" "JPST.PK" "RECN" "RELL" #[15] "RT" "UNF" "WOR" "WSCI" "ZEP" "AEHR" 

这不包括任何ETF,期货,期权,债券,外汇或共同基金。

你可以在这里得到雅虎的ETF清单: http : //finance.yahoo.com/etf/browser/mkt只显示前20位。你需要该页面底部的“全部显示”链接的URL 。 你可以刮页面找出有多lessETF,然后构build一个URL。

 L <- readLines("http://finance.yahoo.com/etf/browser/mkt") # Sorry for the ugly regex n <- gsub("^(\\w+)\\s?(.*)$", "\\1", gsub("(.*)(Showing 1 - 20 of )(.*)", "\\3", L[grep("Showing 1 - 20", L)])) URL <- paste0("http://finance.yahoo.com/etf/browser/mkt?c=0&k=5&f=0&o=d&cs=1&ce=", n) #http://finance.yahoo.com/etf/browser/mkt?c=0&k=5&f=0&o=d&cs=1&ce=1442 

现在,您可以从该页面的表格中提取代码

 library(XML) tbl <- readHTMLTable(URL, stringsAsFactors=FALSE) dat <- tbl[[tail(grep("Ticker", tbl), 1)]][-1, ] colnames(dat) <- dat[1, ] dat <- dat[-1, ] etfs <- dat$Ticker # All ETF tickers from yahoo length(etfs) #[1] 1442 head(etfs) #[1] "DGAZ" "TAGS" "GASX" "KOLD" "DWTI" "RTSA" 

这就是我可以提供的所有帮助,但是你可以做类似的事情,通过这些页面来获得他们提供的一些期货(这些只是美国的期货)

http://finance.yahoo.com/indices?e=futures,http://finance.yahoo.com/futures?t=energy,http://finance.yahoo.com/futures?t=metals,http : //finance.yahoo.com/futures?t=grains,http://finance.yahoo.com/futures?t=livestock,http://finance.yahoo.com/futures?t=softs,http::// finance.yahoo.com/futures?t=indices ,

而且,对于美国和非美国指数,你可以刮这些页面

http://finance.yahoo.com/intlindices?e=americas,http://finance.yahoo.com/intlindices?e=asia,http://finance.yahoo.com/intlindices?e=europe,http : //finance.yahoo.com/intlindices?e=africa,http://finance.yahoo.com/indices?e=dow_jones,http://finance.yahoo.com/indices?e=new_york,http::// finance.yahoo.com/indices?e=nasdaq,http://finance.yahoo.com/indices?e=sp,http://finance.yahoo.com/indices?e=other,http::// finance。 yahoo.com/indices?e=treasury,http://finance.yahoo.com/indices?e=commodities

我一直在研究这几天,跟着无尽的线索,接近但并不完全符合我所追求的。

我需要的是一个简单的“象征,部门,行业”清单。 我正在使用Java,不想使用任何平台本机代码。

似乎大多数其他数据,如引号等,都是可用的。

最后,跟着一个build议去看“finviz.com”。 看起来就像票。 尝试使用以下内容:

http://finviz.com/export.ashx?v=111&t=aapl,cat&o=ticker这回来作为行,csv风格,与标题行,由股票代号sorting。; 你可以不断添加代号 在代码中,您可以读取stream。 或者您可以让浏览器询问您是否打开或保存文件。

http://finviz.com/export.ashx?v=111&&o=ticker同样的csv风格,但拉动所有可用的符号(很多,跨全球交stream);

将“导出”replace为“筛选器”,数据将显示在浏览器中。

你可以使用更多的选项,一个用于网站上的每个筛选器元素。

到目前为止,这是获得我无法轻易得到的数据的最强大和最方便的编程方式。 而且,看起来这个网站很可能是您实际或接近实时报价以外的大部分内容的唯一来源。

雅虎符号/代理/股票的完整列表可在以下网站下载(excel格式)。 http://www.myinvestorshub.com/yahoo_stock_list.php

列表已更新至2016年1月: http : //investexcel.net/all-yahoo-finance-stock-tickers/

我有一个解决方法是迭代的部门(当时你可以做…我最近还没有testing过)。

当你这样做的时候,你最终会被封锁,因为YQL每天都会被限制。

尽可能使用CSV API来避免这种情况。

我有同样的问题,但我想我有简单的解决scheme(代码是从我的RoR应用程序):从yahoo.finance.sectors提取行业ID并将其添加到数据库:

  select = "select * from yahoo.finance.sectors" generate_query select @data.each do |data| data["industry"].each do |ind| unless ind.kind_of?(Array) unless ind["id"].nil? id = ind["id"].to_i if id > 0 Industry.where(id: id).first_or_create(name: ind["name"]).update_attribute(:name, ind["name"]) end end end end end 

用行业id提取所有的符号:

  ids = Industry.all.map{|ind| "'#{ind.id.to_s}'" }.join(",") select = "select * from yahoo.finance.industry where id in" generate_query select, ids @data.each do |ts| unless ts.kind_of?(Array) || ts["company"].nil? if ts["company"].count == 2 && ts["company"].first[0] == "name" t = ts["company"] Ticket.find_or_create_by_symbol(symbol: t["symbol"], name: t["name"] ).update_attribute(:name, t["name"]) else ts["company"].each do |t| Ticket.find_or_create_by_symbol(symbol: t["symbol"], name: t["name"] ).update_attribute(:name, t["name"]) end end end end end 

连接hellper:

 def generate_query(select, ids = nil) if params[:form] || params[:action] == "sectors" || params[:controller] == "tickets" if params[:action] == "sectors" || params[:controller] == "tickets" if ids.nil? query= select else query= "#{select} (#{ids})" end else if params[:form][:ids] @conditions = params_parse params[:form][:ids] query = "#{select} (#{@conditions})" end end yql_execut(query) end end def yql_execut(query) # TODO: OAuth ACCESS (http://developer.yahoo.com/yql/guide/authorization.html) base_url = "http://query.yahooapis.com/v1/public/yql?&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q=" dirty_data = JSON.parse(HTTParty.get(base_url + URI.encode(query)).body) if dirty_data["query"]["results"] == nil @data, @count, @table_head = nil else @data = dirty_data["query"]["results"].to_a[0][1].to_a @count = dirty_data["query"]["count"] if @count == 1 @table_head = @data.map{|h| h[0].capitalize} else @table_head = @data.to_a.first.to_a.map{|h| h[0].capitalize} end end end 

对不起,一塌糊涂,但这是我的项目的第一个testing版本,我需要它非常快。 有一些助手variabels和其他东西我的应用程序,对不起。 但是我有问题:你有很多符号吗? 我有5500。

那么,经过一些挖掘,雅虎不提供任何“清单”的所有代号。 但是,这个网站提供了大量的信息。 也许你可以在这里find你要找的东西? http://www.gummy-stuff.org/Yahoo-data.htm

编辑:由于版权问题,该网站已closures。