Course Home | Documentation | Lab Hours/Tutoring | Projects | Quizzes | Schedule | Submit

Saint Louis University

Computer Science 1050
Introduction to Computer Science: Multimedia

Michael Goldwasser

Spring 2016

Dept. of Math & Computer Science

Gathering Stock Data from Yahoo

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:

We provide only the briefest of summaries.

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:
http://finance.yahoo.com/d/quotes.csv?s=AAPL+GOOG&f=snvb3gh
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:
http://ichart.yahoo.com/table.csv?s=AAPL&a=3&b=3&c=2010&d=10&e=2&f=2012&ignore=.csv
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.


Michael Goldwasser
CSCI 1050, Spring 2016
Last modified: Tuesday, 05 April 2016
Course Home | Documentation | Lab Hours/Tutoring | Projects | Quizzes | Schedule | Submit