COSC COSC5910.03 Software Foundations

Instructor: J. Liu

Assignment 2. Due Tuesday March 4 in class.

This assignment asks you to code the download and manipulation of stock quotes taken from the web. In order to get stock information from web sites, we can use the class. An example of accessing a Yahoo site is given in

Alternatively, we can use the "type" package developed by Professor Hamzeh Roumani of the Department of Computer Science. (For the download and setup of this package, follow the link from the course web page.) An example of using this package is given in the code

Yahoo provides stock historical quotes from its web site (at ""). From this site, one can enter the start and end date, select daily, weekly, or monthly data and the ticker symbol (Try it!!).

Alternatively, one can enter an URL string on the "Address" or "Location" field in the browser directly to obtain a table of specific stock quote data. For example, to obtain the weekly stock price of "Home Depot" (with ticker symbol "HD") from January 1, 2002 to Dec 31, 2002, one can enter:
This will give a table of stock quotes of "Home Depot" for the requested period in the "csv" (comma separated value) format. Here the fields in the location string are given by:
a month of start date - 1
b day of start date
c year of start date
d month of end date - 1
e day of end date
f year of end date
s stock symbol
There are four different possible values for "g=": d (daily quotes), m (monthly quotes), w (weekly quotes), v (dividends).

Click here for a sample of the quote table for this set of stock information. Indeed, this sample can be obtained from the examples in and

  1. You are provided with an incomplete class Read the inline documentation from the StockQuotes class, and complete the setQuotes(..) method in this class. You should use the request on the Yahoo site to obtain a table of stock quotes. Then use the StringTokenizer class to extract data in the setQuotes method. Quote objects do not include an open price, which is included in the table of data.

    Note that there is an additional yearly quote type in the StockQuotes class. In such a case, monthly stock data should be downloaded from the Yahoo site and the data for each year should be compressed to form one quote item with the String date set to be the corresponding year, a 4-digit String, such as "2002".

    Write an application code to obtain and output the stock quotes of a stock. Your tester should demonstrate the features of daily, weekly, monthly and yearly stock quotes.

  2. Use your StockQuotes class to obtain the yearly quotes of the thirty Dow stocks for the past five years. Print a table of the thirty Dow stocks of their yearly percentage stock price change for the past five years. The rows of the table are associated with the Dow stocks and the columns with the years. For each year, give the best and worst performing Dow stock.

    Here, you can ignore the quarterly dividend in the performance evaluation.

Last Updated: 02/05/2003