Saint Louis University |
Computer Science 1050
|
Dept. of Math & Computer Science |
Interestingly, Yahoo Finance seems to provides an (undocumented and unsupported) interface for requesting current or historical stock data in a CSV format. They do limit you to a maximum frequency of requests so that you don't overly tax their servers, and their Terms of Service only allow use of this interface for non-commercial purposes (such as education!).
Some informative explanations of the interface can be found at:
To get the most current quote for one or more stocks (although likely
with 5-minute delay during market hours), you can use a URL such as:
where the AAPL+GOOG can be any combination of one or more
stock symbols, and the symbols after the f= parameter
describes which fields you wish to be sent. (In our example s is
symbol, n is name, v is volume,
b3 is real-time bid, g is daily low and
h is daily high.)
Historical data can be retrieved at either daily, weekly, or monthly
intervals, using a url such as:
For this syntax, the parameters a, b, and c
define a start of the historical query range, respectively as month, date, and
year. Note well that they use an unusual convention where months are
zero-indexed (e.g., January is 0), yet dates and years use natural
values. Similarly, parameters d, e, and f
define the end of the query range. It is also worth noting that these
results include a first header line, and then all entries ordered in
reverse chronological order (i.e., most recent first).
Here is an example of our own stock grapher (although this version does not allow you to switch to any data set other than the default YHOO).
Our implementation as source code or formatted as pdf file.