1

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!

pnuts
  • 58,317
  • 11
  • 87
  • 139
DVK
  • 126,886
  • 32
  • 213
  • 327
  • 2
    realtime stockinfo is not available unless you have a payed contract – Grumpy Mar 17 '10 at 15:37
  • 2
    Wouldn't this violate Yahoo's TOS? In any case, I suspect this is fairly trivial to do, but I am reluctant to post here. If it is strictly for personal use (forever and after), you can contact me via my Google profile. – Sinan Ünür Mar 17 '10 at 15:42
  • You don't need a payed contract necessarily, but you do need to agree to the exchanges' terms of service. The terms will almost always include a provision that prohibits you from redistributing the data to anyone who has not also agreed to the terms of service. – mob Mar 17 '10 at 15:42
  • @mobrule/Sinan - this is for a personal project (I just want a daemon which will alert me when my favorite stocks move, ala Yahoo Finance Alert emails but realtime). I'll check Yahoo's TOS but I am pretty sure it's covered. – DVK Mar 17 '10 at 15:45
  • Is 15min really too long to wait? Given that unless you pay for a very expensive stockbroker, a trade might take several minutes to action anyway... – Mr. Boy Mar 17 '10 at 16:14
  • I don't have a very expensive broker and I can execute trades with seconds. *shrug* For some people, 15 microseconds is too long to wait. Seriously. – brian d foy Mar 17 '10 at 16:22
  • When I was rummaging about, I did not find any real-time quotes for free. *But* that was over a year ago so my info may be out of date. – Paul Nathan Mar 17 '10 at 16:26
  • What brian said. Some of my best trades were picking on a trend in my favorite stock and getting in or out early enough – DVK Mar 17 '10 at 16:31
  • 1
    @brian... _Executing_ the trade is not the same as _completing_ the trade, they still have to find someone to buy the shares after all. Didn't you have to wait a short time to get confirmation exactly what price the shares were sold for? – Mr. Boy Mar 17 '10 at 16:41
  • very good post, i was really searching for this topic as i wanted this topic to understand completely and it is also very rare in internet that is why it was very difficult to understand –  Oct 08 '11 at 09:37

4 Answers4

2

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.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
guitarthrower
  • 5,624
  • 3
  • 29
  • 37
1

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
  • 42,753
  • 9
  • 87
  • 112
1

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.

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • 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? – Mr. Boy Mar 17 '10 at 16:12
  • 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. – Mr. Boy Mar 17 '10 at 16:39
  • Ughm... and that'd be different from me making money by looking at their real-time prices on my Yahoo!Finance page how? – DVK Mar 18 '10 at 05:46
1

As of 1 November 2017, Yahoo has shut down the stock quote API. Alphadvantage https://www.alphavantage.co/documentation/ is the current go-to for delayed quotes on US exchanges. You do need to update Finance::Quote to 1.40 or later (1.47 is the current version as of 18 Dec 2017).