Search code examples
yqlyahoo-financeyahoo-apiquantitative-finance

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


I'm looking for a way to get list of all mutual funds and ETFs tickers from Yahoo Finance. I've found few solutions like for example:

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

or

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

But unfortunantely after checking dozens of random tickers most of them didn't belong to mutual funds category. Having list of this tickers seems useful as long I could find a way to check ticker's category.

enter image description here

On Yahoo Finance website using search box, popup show ticker's category. How to replicate this functionality programmatically or using for example YQL?

EDIT:

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


Solution

  • It's possible to tell wether ticker is mutual fund or ETF but it's hard to distinct between mutual fund and ETF.

    As an example let's take mututal fund with ticker TIBIX. From what I know only mutual funds and ETFs have category "Fund Family" in their profile tab. So you need YQL that checks whether ticker contains HTML span containing "Fund Family" inside.

    Raw YQL query

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

    Endpoint for the query

    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
    

    If you ticker is mutual fund or ETF, query should return such response:

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

    Either way result will be empty.