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 | 0 Comments

No Comments

Leave a comment...