How to get a list of all Yahoo Finance investment funds in R?

I want to get a list of all the mutual funds available through Yahoo Finance, in R. The TTR package has the StockSymbols function, but it does not seem to receive mutual funds.

Thanks,

+6
source share
1 answer

I do not think that Yahoo will provide a list of all the mutual funds in which they have data for (similarly, they do not provide a list of stocks that they cover). You can download the list from the site that you mentioned in the comments, by all means, get the appropriate "Profile" page from Yahoo, and extract the necessary information - the "Category" field seems to be the closest to the "sector and industry" that you want .

# Read the list of funds # I assume the file was downloaded manually from # http://www.eoddata.com/Data/symbollist.aspx?e=USMF # This requires registration (free). d <- read.delim( "USMF.txt", stringsAsFactors = FALSE ) # Retrieve the profile page, for each of the funds. # It takes 1 second for each, and there are 24,000 of them: # this may take more than 6 hours. library(RCurl) library(stringr) d$Category <- "" for( i in seq_len(nrow(d)) ) { try({ url <- paste0("http://uk.finance.yahoo.com/q/pr?s=", d$Symbol[i]) cat( url, " " ) profile <- getURL(url) row <- str_extract(profile, "Category.*?</tr>") cell <- str_extract(row, "<td.*</td>" ) d$Category[i] <- str_replace_all( cell, "<.*?>", "" ) cat( d$Category[i], "\n" ) }) } head(d) 
+3
source

Source: https://habr.com/ru/post/949883/


All Articles