CS60 Project 6 --------------------- Due Fri. Dec 5th @ midnight Use the Force..er...STL --------------------------- The task of this project is to figure out the stock market. Kidding. We will be creating a database program that loads stock market data into memory and then allows the user to ask certain questions about the data. The program must be able to intelligently search through the data to answer the questions asked by the user. On the website, stock data is provided for the company RedHat Inc. and is formatted as follows: line 1: field name strings (Date,Open,High,Low,Close,Volume) lines 2-n: data values (Date,Open,High,Low,Close,Volume) Some example lines from company RedHat (RHAT) date look like: Day,Month,Year,Open,High,Low,Close,Volume 4,2,2003,5.50,5.61,5.38,5.58,607400 5,2,2003,5.57,5.69,5.42,5.52,424600 6,2,2003,5.56,5.57,5.28,5.33,567000 .... Your program should create a notion of a 'companyDB' that stores this data in a way that allows us to find answers to the following questions: 1.) Show me records from dates A through B A is a start date (2,1,1999) B is an end date (23,1,1999) 2.) What is the average M value between A and B M is the field of interest (Open, High, Low, Close, etc) A is a start date (2,1,1999) B is an end date (23,1,1999) 3.) For dates A through B, show me the records that have a higher N than M value. M is the field of interest (Open, High, Low, Close, etc) N is the field of interest (Open, High, Low, Close, etc) A is a start date (2,1,1999) B is an end date (23,1,1999) 4.) Is there an upward trend between dates A and B for N values? A is a start date (2,1,1999) B is an end date (23,1,1999) N is the field of interest (Open, High, Low, Close, etc) Time ---------------- In C and C++, under UNIX, time is usually handled using a notion of 'time in seconds since the Epoch (00:00:00 UTC, January 1, 1970)'. Using this notion, two times, no matter when since 1970, can be compared to find out which time was before the other. Converting from our standard notion of time (day/month/year) to the number of seconds since the epoch is done using predefined structures and functions. For example: #include main() { struct tm mytime; time_t etime; bzero(&mytime, sizeof(mytime)); mytime.tm_mday = 2 mytime.tm_mon = 1 mytime.tm_year = 1999 - 1900; etime = mktime(&mytime); cout << etime << endl; } The above example will print out 917942400 which is the number of seconds Feb 2, 1999 was from the epoch. The above formulation also works for years >= 2000. In this assignment, it would be wise to internally represent the times of stock data as epoch time instead of the day/month/year form that is given in the file. ----------------------------------------------------------------------- HINTS: The biggest problem to solve for this assignment is how to organize your data to make the answers to questions easy to answer. Here are some useful observations: 1.) All questions require ability to find a range of dates - use lower_bound and upper_bound on a sorted vector of epoch times to obtaim a range of iterators. 2.) Questions 2 and 3 require knowledge of an entire column of data that can be indexed according to date - each column of data can be stored as a map. 3.) Questions 2, 3 and 4 require some way to MAP between strings and columns of data (Open == column 3). Program Requirements ------------------------------ 1.) Program must be able to read and parse the stock market data files. 2.) Program must present a menu of options to the user with options 1-4 indicating the search to perform and 5 indicating exit. 3.) Program must return correct results from the search questions. Use the following input scenarios for your turnin scriptfile showing the proper execution of your code: 1.) Show me records from dates 1/1/1999 through 30/12/2004 2.) Show me records from dates 1/1/1999 through 30/12/2001 3.) Show me records from dates 1/1/2002 through 30/12/2004 4.) What is the average "Open" value between 1/1/2001 and 1/12/2001 5.) What is the average "Close" value between 1/1/2001 and 1/12/2001 6.) What is the average "Close" value between 1/1/2003 and 1/12/2003 7.) For dates 1/1/1999 through 30/12/2004, show me the records that have a higher "Open" than "Close" value. 8.) For dates 1/1/2001 through 30/12/2002, show me the records that have a higher "Close" than "Open" value. 9.) For dates 1/1/2000 through 30/12/2001, show me the records that have a higher "High" than "Close" value. Turnin ---------------------------- The turnin tag for this project is 'project6' and must include all code, header files, a script file showing compilation and execution of the program, and an optional README file with special instructions for the grader. Extra Credit (+10 pts.) ------------------------------- Add a new question to your menu 5.) Show me any upward trends of length N days in the company's M values for dates A to B? N is a number of days M is the field of interest (Open, High, Low, Close, etc) A is a start date (2,1,1999) B is an end date (23,1,1999) turnin should include the following scenarios: 10.) Show me any upward trends of length 3 days in the company's "Close" values for dates 1/1/2002 to 30/12/2004? 11.) Show me any upward trends of length 5 days in the company's "Open" values for dates 1/1/1999 to 30/12/2001?