Stock Quotes From Yahoo in RSS or CSV

UPDATE: The location of the CSV file has changed since this post was originally written.

I’ve been trying to find a way to get stock quotes delivered to me (via email or RSS) for too long now. It turns out I just wasn’t searching very well because a solution was made back in 2005.

Check out the freely available script at TC’s Blog that generates a custom RSS feed based on the stock symbols of your choice.

As with most things, I decided this approach was slight overkill for my needs so I cut into the meat of TC’s script and took out the part I needed most. His script runs off of Yahoo! Finance’s little known ability to deliver quotes in a CSV file.

So here’s the URL you need:

http://quote.yahoo.com/d/quotes.csv?s=SYMBOL&f=sl1d1t1c1ohgv&e=.csv

If you toss that into fopen or curl (or whatever your weapon of choice is) and then parse the result using fgetcsv you’ll be good to go. Here’s a breakdown of the array that fgetcsv will return.

array[0] = Symbol
array[1] = Last Price
array[2] = Date
array[3] = Time
array[4] = Change
array[5] = Open Price
array[6] = Day High Price
array[7] = Day Low Price
array[8] = Trade Volume

Keep in mind that Yahoo! doesn’t give you real-time quotes. Their information comes on a twenty minute delay or so. Hopefully, using TC’s RSS script or just going straight to the CSV source will help you out.

October 29th, 2006 | PHP, Programming | 4 Comments

4 Comments

  1. Question: Have you figured out how to get a quote for a specific date via yahoo’s finance site. I mean in csv format that I can manipulate programatically? I have searched the “f” options but I don’t see an option there for specifying the date.

    TIA,
    Pete

    Comment by Pete Grant — September 20, 2008 @ 9:09 am

  2. Can I get a similar kind of url to get the weather in csv format

    Comment by Kailash — October 8, 2009 @ 2:25 am

  3. Hello, Thank you so much. It works like a charm. My only question is, can I do this without breaking any of the terms and conditions of yahoo??

    Comment by dave — April 10, 2010 @ 3:28 pm

  4. Hi,

    TC here..

    First, I’m sorry to say that the script is no longer running. I stopped using it myself, and forgot to keep it up to date. Anybody who feels like updating it and running it are of cause welcome to do so.

    Second, first my blog has moved:
    http://b.tc.dk/2005/01/yahoo-stock-to-rss-converter/

    Comment by TC — May 26, 2010 @ 5:39 am

Leave a comment...