How to Get Stock Quotes Using Google Finance API

How can I get stock quotes using Google Finance API?

There's a whole API for managing portfolios. *Link removed. Google no longer provides a developer API for this.

Getting stock quotes is a little harder. I found one article where someone got stock quotes using Google Spreadsheets.

You can also use the gadgets but I guess that's not what you're after.

The API you mention is interesting but doesn't seem to be documented (as far as I've been able to find anyway).

Here is some information on historical prices, just for reference sake.

How to get data using Google finance API

Check this project : Implementation of Google Finance API in C# , it has also a demo of how to use it.

You may also check Yahoo finance API , here's a sample of how to get real-time data from it in C#

Java: Get position's price Google Finance API

You can't directly access stock prices, using the Google Finance API, because they do not expose raw quote data due to data rights and licensing reasons.

You can compute it, however. Look at the transaction feed for a given position (You must own shares of the position, not just a 0-share entry.) Compute the total number of shares owned (cumulative buys less cumulative sells) and then look at the market value of the position.

Market value / number of shares owned = individual share price.

Display stocks data from Google Finance or Yahoo! Finance

Yahoo! Finance gives you real-time stock quotes. Data is returned as a CSV.

See this NASDAQ page at http://finance.yahoo.com/q?s=^IXIC

  1. Click the Download Data button to access live data

  2. Click the Download To Spreadsheet button to access historical data

You can access that data from Flash using the LoadVars or URLLoader classes.
Use unescape() to decode the string from its URL-encoded format.

google finance api not working from 6/september/2017

In the end i started using yahoo finance. The data is not live, there is a 20 minutes delay. I thought it will be helpful to people who are facing issues like me.

The yahoo api url is https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%3D%22MSFT%22&env=store://datatables.org/alltableswithkeys

This will return the stock data in xml format. You can parse the xml to get your desired fields.

Thanks,
Ram

How to create a stock quote fetching app in python

This module comes courtesy of Corey Goldberg.

Program:

import urllib
import re

def get_quote(symbol):
base_url = 'http://finance.google.com/finance?q='
content = urllib.urlopen(base_url + symbol).read()
m = re.search('id="ref_694653_l".*?>(.*?)<', content)
if m:
quote = m.group(1)
else:
quote = 'no quote available for: ' + symbol
return quote

Sample Usage:

import stockquote
print stockquote.get_quote('goog')

Update: Changed the regular expression to match Google Finance's latest format (as of 23-Feb-2011). This demonstrates the main issue when relying upon screen scraping.



Related Topics



Leave a reply



Submit