Google, Yahoo! Finance and REBOL Programming

How to Use Financial Information Stored in CSV Files

© Mark Alexander Bain

Sep 4, 2009
Google, Yahoo! Finance and REBOL Programming, Mark Alexander Bain
Both Yahoo! Finance and Google Finance provide financial information, and these sources of data are especially useful for programmers using such languages as REBOL

In his New York Times article, Where Yahoo Leaves Google in the Dust, Randall Stross reveals that Yahoo! Finance draws 17.5 times the traffic of Google Finance, and says that:

  • Yahoo! Finance has been the most popular of the two for the last 19 consecutive months
  • In July 2009 Yahoo! Finance 21.7 unique United States visitors in July compared to Google Finance's 1.2 million
  • Yahoo! Finance's traffic grew by 12% from July 2008 to July 2009, while Google Finance’s traffic grew by 3%

He concludes that this discrepancy is not because Yahoo! Finance is in any way "better" than Google Finance, and it simply due to the way in which Yahoo! Finance provides highly complex (and intimidating) information in a simple and "safe" format. Google Finance's downfall is that it actually provides too much information. Not that any programmer will agree with that. As far as they're concerned there is no such thing as too much information.

Especially when using a dialecting language such as Rebol (for getting started with that read A Brief Introduction to REBOL Programming: How to Start Writing REBOL Scripts). They are, of course, not interested in what the web pages look like, they're only interested in how to get at the background data. And so, for them, both Yahoo! Finance and Google Finance are excellent sources of information.

Obtaining Data from Yahoo! Finance

Yahoo! Finance does not have a custom api (application programming interface), instead any requested fields are return to the programmer as a csv (comma separated file) from the web site (to learn more about the fields read Using Yahoo! Financial Stock Quotes: How to Access and Use On-Line Financial Data from Yahoo!). The REBOL programmer, therefore, just needs to know how to import the csv file:

quotes: read/lines http://download.finance.yahoo.com/d/quotes.csv?s=MSFT&f=sl1c1d1&e=.csv

Here the current Yahoo! Financial for Microsoft is imported into REBOL line by line. These lines of data can then be processed:

foreach quote quotes [
quote_data: parse/all quote ","
print [quote_data/1 "last price" quote_data/2 "change" quote_data/3]
]

The output from this can be seen in figure 1 at the bottom of this article.

Obtaining Data from Google Finance

Just like Yahoo! Finance, Google Finance returns its data in the form of a csv file (as discussed in An Introduction to Google Finance: How to Obtain Stock Quotes on the Internet). The steps to importing Google Finance data into REBOL are, therefore, just the same as importing Yahoo! Finance data:

quotes: read/lines http://finance.google.co.uk/finance/historical?q=MSFT&output=csv

And again this can be used line by line:

foreach quote quotes [
quote_data: parse/all quote ","
print ["Date:" quote_data/1 "Open:" quote_data/2 "High:" quote_data/3 "Low:" quote_data/4 "Close:" quote_data/5]
]

This time a set of historical data is return and displayed as shown in figure 2. This means that the REBOL programmer has an easy but effective way of incorporating both live and historical financial information in any of their applications.

BNC101


The copyright of the article Google, Yahoo! Finance and REBOL Programming in Computer Programming is owned by Mark Alexander Bain. Permission to republish Google, Yahoo! Finance and REBOL Programming in print or online must be granted by the author in writing.


Google, Yahoo! Finance and REBOL Programming, Mark Alexander Bain
Figure 1: REBOL and Yahoo! Finance, Mark Alexander Bain
 Figure 2: REBOL and Google Finance, Mark Alexander Bain
   


Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo