views:

608

answers:

5

There's a fairly easy way of retrieving 15-minute delayed quotes off of Yahoo! Finance web site ("quotes.csv" API).

However, so far I was unable to find any info on how to access real-time quotes.

The hang-ups with real-time quotes are:

  • Only available to logged-in user
  • No API
  • Non-obvious how to scrape the info - I'm somewhat convinced they are placed on the page by some weird Ajax call.

So I was wondering if anyone had managed to develop a publically available solution to retrieve real-time quotes for a stock from Yahoo! Finance.

Notes:

  • Implementation language/framework need is flexible but Perl or Excel is highly preferred.

  • Assume that security is not an issue - I'm willing to supply yahoo userid and pasword, even in cleartext.

  • I'm not 100% hung up on Yahoo - they are merely the only provider of free realtime stock quotes I'm familiar with. if the same thing can be done with Google Finance, I'd be just as happy.

  • This is for a personal project, so scalability/fault tolerance/etc... are not important.

  • I'm looking for a "do the whole retrieval" library ideally, but if I'm pointed to partial solutions (e.g. how to retrieve info from Yahoo's user-logged-in pages; how to scrape realtime quotes from Yahoo's page) I can fill in the blanks.

I saw Finance::YahooQuote but it does not seem to allow you to supply log-in information and appears to use the lagging quotes.csv API

Thanks!

+1  A: 

I could find no guarantees of real-time, but the Google Finance Portfolio Data API seems quite well documented and far cleaner than page scraping.

msw
+1  A: 

Anywhere providing real-time data will want paying a fairly large sum for it. That's why they delay the free data, because the real-time data is so valuable.

Looking at it the other way, any way you can find to get free real-time data is almost certainly illegal or breaks the usage agreement. This data belongs to someone and they won't like you taking it.

I worked at a company who wanted such data legitimately and they could find no way to get it cheaply. In fact IIRC even a feed of time-delayed data is free if you plan to use it in an application rather than looking at it on a web-page.

John
I have a feeling that non-commercial use is covered by TOS...
DVK
Maybe some places, though real-time stock data is too valuable to be given away by many. Besides, in what non-commercial situations would real-time data be required compared to time-delayed feeds?
John
@John: personal trading?
DVK
If you're making money from it, I think they'd argue that's commercial. The ability to make money from real-time data is precisely why it's so expensive to buy a feed in the first place.
John
Ughm... and that'd be different from me making money by looking at their real-time prices on my Yahoo!Finance page how?
DVK
Well just do that then. Problem solved.
John
+2  A: 

Excel has a built in link to MS stock quotes. They should provide the same information you are looking for. You can also download the addin.

guitarthrower
thanks for the edits sinan
guitarthrower
A: 

This is how I do it. I coded it myself.

http://afewtips-com.blogspot.com/2010/05/perl-get-stock-history-from-yahoo-and.html

Michael T
A: 

This is the code which can be modified with the correct code for realtime.

http://criticalstocks.tumblr.com/post/732137771/perl-stock-quotes-from-yahoo

Last Trade (Real-time) with Time k1 Bid (Real-time) b3 Ask (Real-time) b2 Change Percent (Real-time) k2 Change (Real-time) c6 Holdings Value (Real-time) v7 Day's Value Change (Real-time) w4 Holdings Gain Pct (Real-time) g5 Holdings Gain (Real-time) g6 Day's Range (Real-time) m2 Market Cap (Real-time) j3 P/E (Real-time) r2 After Hours Change (Real-time) c8 Order Book (Real-time) i5

Critical Stocks