Unblock Myspace - Homeowner Loans - Car Finance - Problem Mortgage - Car Hire Usa

PDA

View Full Version : Incorporate realtime stock quote


digitalpoint
Mar 5th 2004, 8:30 am
I'm sure there is some sort of free XML feed for stock quotes out there, but I wasn't able to find one. Yahoo finance has the ability to download up to date stock data (with the normal 15 minute lag) to a CSV file.

So, let's say we wanted a stock quote for Yahoo... First, go to Yahoo finance's page for whatever company you want a quote for:

http://finance.yahoo.com/q?s=YHOO

Under the stock figures, there is a download data option. Use that URL in the fopen() function below.


echo "Stock quote: ";

$handle = @fopen("http://finance.yahoo.com/d/quotes.csv?s=YHOO&f=sl1d1t1c1ohgv&e=.csv", "r");
$data = @fgetcsv($handle, 1000);
@fclose($handle);

echo "<B>" . $data[1] . "</B> ";
if ($data[4] < 0) {
echo "<FONT COLOR=RED>" . $data[4] . "</FONT>";
} elseif ($data[4] > 0) {
echo "<FONT COLOR=GREEN>" . $data[4] . "</FONT>";
} else {
echo $data[4];
}

echo " (" . date ("M j, g:i a", strtotime($data[2] . " " . $data[3])) . " EST)";


Ta-da! You now have a stock quote that is "live".

- Shawn

rhythmiccycle
Nov 26th 2007, 7:43 pm
I am also interested i making a stock ticker, and i found that you could get even more than just the quote, if you use the right tags.

check out this page:

-- I can't post the link because i'm too new, but you can google, "yahoo data download" it will be the first page---

it has a whole bunch of other info you can get from yahoo. such as a 200-day or 50-day moving average.

commandos
Nov 26th 2007, 8:17 pm
wow that's what i call a bump !

man this topic is 2004 lol

serialCoder
Nov 26th 2007, 8:23 pm
LoL, i didnt notice it at all, just noticed it when i read your post and checked when its posted, how did he even found the thread??

commandos
Nov 26th 2007, 8:25 pm
maybe by searching google for : "Incorporate realtime stock quote"

the forum is #1 lol