雅虎财经 API 获取所有共同基金和 ETF 代码列表

Yahoo Finance API get list of all mutual funds and ETFs tickers

我正在寻找一种方法来从 Yahoo Finance 获取所有共同基金和 ETF 代码的列表。我发现很少有解决方案,例如:

https://github.com/Benny-/Yahoo-ticker-symbol-downloader

http://investexcel.net/all-yahoo-finance-stock-tickers/

但不幸的是,在检查了数十个随机代码后,其中大多数不属于共同基金类别。只要我能找到检查代码类别的方法,拥有此代码列表似乎很有用。

在使用搜索框的 Yahoo Finance 网站上,弹出窗口显示代码的类别。如何以编程方式或使用 YQL 等方式复制此功能?

编辑:

After following Daniel's advise I've successfully filtered tickers and updated them on my GitHub: https://github.com/MichaelDz6/Yahoo_Finance_ETFs_Web_Scraper

可以判断代码是共同基金还是 ETF,但很难区分共同基金和 ETF。

让我们以代码为 TIBIX 的共同基金为例。据我所知,只有共同基金和 ETF 在其个人资料选项卡中有类别 "Fund Family"。所以你需要 YQL 来检查 ticker 是否包含 HTML span containing "Fund Family" inside.

原始 YQL 查询

select * from htmlstring where url='https://finance.yahoo.com/quote/TIBIX/profile?p=TIBIX' and xpath='//span/*[contains(.,"Fund Family")]//text()'

查询的端点

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20htmlstring%20where%20url%3D'https%3A%2F%2Ffinance.yahoo.com%2Fquote%2FTIBIX%2Fprofile%3Fp%3DTIBIX'%20and%20xpath%3D'%2F%2Fspan%2F*%5Bcontains(.%2C%22Fund%20Family%22)%5D%2F%2Ftext()'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

如果您的代码是共同基金或 ETF,查询应该return这样的回应:

{"query":{"count":1,"created":"2017-09-25T07:07:10Z","lang":"en-US","results":{"result":"Fund Family"}}}

无论哪种方式,结果都将为空。