1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Incorporate realtime stock quote

Discussion in 'PHP' started by digitalpoint, Mar 5, 2004.

  1. #1
    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:
    SEMrush
    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)";
    
    PHP:
    Ta-da! You now have a stock quote that is "live".

    - Shawn
     
    digitalpoint, Mar 5, 2004 IP
    SEMrush
  2. rhythmiccycle

    rhythmiccycle Guest

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    rhythmiccycle, Nov 26, 2007 IP
  3. commandos

    commandos Notable Member

    Messages:
    3,652
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #3
    wow that's what i call a bump !

    man this topic is 2004 lol
     
    commandos, Nov 26, 2007 IP
  4. serialCoder

    serialCoder Guest

    Best Answers:
    0
    #4
    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??
     
    serialCoder, Nov 26, 2007 IP
  5. commandos

    commandos Notable Member

    Messages:
    3,652
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #5
    maybe by searching google for : "Incorporate realtime stock quote"

    the forum is #1 lol
     
    commandos, Nov 26, 2007 IP
  6. illinois

    illinois Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    hi everybody...
    i'm the webmaster of www .fanta-trade.eu it is a game/community based on stock markets.
    i'm using yahoo as data provider as well, but i would like to skip those 15 min of delay.
    do you know any data provider that give prices in "real" real time ?
    also for the europeans markets may be...

    thanks
     
    illinois, Dec 4, 2008 IP
  7. e33

    e33 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Just found a great blog post at the useful php blog explaining how to do exactly this!

    http://usefulphp.blogspot.com/2010/04/stock-quotes-with-php.html

    Very nicely done too - uses the Yahoo CSV service and returns a php array with all the info you need about the stock quote.
     
    e33, Apr 9, 2010 IP
  8. jo5key

    jo5key Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi Guys,
    I want just tell you that you do you can also find through google by typing "Incorporate real time stock quote" or you may found so many sites which provide Incorporate real time stock quote. Instead of writing code you have to take a simple way through google.
     
    jo5key, Sep 24, 2012 IP