Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I have a list of tickers (~11,500) in a .txt/.csv file and accompanying fund data from yahoo finance. I'm wondering if there is a reasonably easy/accessible way to use this list to obtain expense ratios from yahoo finance or elsewhere? Is it a case of writing a C#/Javascript to queery the YQL 11500 times to http://finance.yahoo.com/q/pr?s=TICKER and then store data from the section: Annual Report Expense Ratio (net): X.YZ% ?

Any help greatly appreciated.

Best wishes

share|improve this question

3 Answers 3

Python version of Brian's R code:

Brian's code automatically grabs the first expense ratio it finds, which is the one you wanted. This version is a little more explicit.

import urllib2, re
stockSymbols = [ "VDIGX", "VFIAX" ]
expenses = [ [ "Fund", "Most Recent Expense Ratio" ] ]
for stockSymbol in stockSymbols:
    page = urllib2.urlopen("http://finance.yahoo.com/q/pr?s=" + stockSymbol + "+profile" )
    data = page.read()
    row = re.findall("Annual Report Expense Ratio.*?</tr>", data)
    if len(row) > 0:
        ER = re.findall("<td.*?>(\d+\.\d+).*?</td>", row[0] )[0]
        expenses.append( [ stockSymbol, ER ] )
    else:
        print stockSymbol, "does not appear to be a fund with an expense ratio"
print "\n".join( i[0] + "," + i[1] for i in expenses )
share|improve this answer

If you're building a technical system that you want to be easily updatable, then yes. a C# query is probably your best bet. A cursory search around Yahoo reveals no-such functionality, and the fact that no one else has jumped on this question with an answer only serves to bolster that case. If you need help with implementation (which isn't in your question) just let me know, and I'll put together a toy example. Good Luck!

share|improve this answer

I once used some code from SO to do a similar task. Here's a bit of a modification. It's slow but you don't need it often.

syms <- c('VDIGX','VFIAX')
library(RCurl)
library(stringr)
for(sym in syms){
  try({
    url <- paste0("http://finance.yahoo.com/q/pr?s=", sym,"+profile")
    profile <- getURL(url)
    row  <- str_extract(profile, "Expense Ratio.*?</tr>")
    cell <- str_extract(row, "<td.*</td>")
    mer <- str_replace_all( cell, "<.*?>", "" )
    cat(sym,cell," ")
  })
}
share|improve this answer
    
For those that aren't programmers, this is the R language. Great for doing statistical work, not so great for most other tasks. –  chollida Jun 9 at 17:04
    
@chollida, thanks, I spent too much time trying to figure out how to pretty print it, I forgot to mention that. The language won't make any difference to the speed of downloading 11k pages. –  brian Jun 9 at 17:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.