|
||||||
Google, Yahoo! Finance and REBOL ProgrammingHow to Use Financial Information Stored in CSV FilesBoth 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:
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! FinanceYahoo! 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 FinanceJust 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.
|
||||||
|
|
||||||
|
|
||||||