Assignment 10 - Stock Analysis due December 2nd Note: changes 11/27, sample output corrected 11/28 10:30 am The purpose of this assignment is to give you practice working with arrays, passing them to...

1 answer below »
c++ homework


Assignment 10 - Stock Analysis due December 2nd Note: changes 11/27, sample output corrected 11/28 10:30 am The purpose of this assignment is to give you practice working with arrays, passing them to functions, and reading and writing text files. In this program you will determine various statistics for a Dow Jones Industrial Average Stock. You are to read the stock history data for the last 1000 market days (approximately 4 years) into arrays and then perform the calculations for various time periods. Your are to create a report similar to the following. Sample Output Stock: CAT Current Date: 2019-11-26 Current Close: $146.09 Market Days Start Date Open Price Up Days Down Days Gain Pct Gain Max Close Avg Close ----------- ---------- ---------- ------- --------- ---- -------- --------- -------- - 5 2019-11-20 142.45 2 3 3.64 2.56% 146.42 144.25 10 2019-11-13 144.36 4 6 1.73 1.20% 146.42 144.13 20 2019-10-30 141.00 8 12 5.09 3.61% 148.16 144.61 50 2019-09-18 131.63 24 26 14.46 10.99% 148.16 134.85 100 2019-07-09 134.11 48 52 11.98 8.93% 148.16 130.46 200 2019-02-13 134.20 101 99 11.89 8.86% 148.16 131.83 500 2017-12-01 141.60 251 248 4.49 3.17% 170.89 138.85 1000 2015-12-08 66.99 508 489 79.10 118.08% 170.89 115.69 Output Details Stock (example CAT) is stock ticker of a Dow Jones Industrial Average (DJIA) stock. Current Date represents the most recent market date stored in the history file. Current Close represents the most recent closing price for the current market date stored in the history file. Use the Close value for this, not the Adj Close. Market Days represents a time period for analysis. For example, 1000 market days represents the last 1000 entries in the history file. The number of market days is inclusive. If the market days is 5 and the current date is 2019-11-27, then the last 5 market days are 2017-11-27, 2017-11-26, 2017-11-25, 2017-11-22, and 2017-11-21. Start Date is the first date in a time span of the length indicated by the number of Market Days and ending with the Current Date. Open Price is the opening price (Open) on the Start Date. Up Days is the number of days in the time period in which the stock Close price is greater than the stock Open price. Down Days is the number of days in the time period in which the stock Close price is less than the stock Open price. Gain is the difference between the Current Close price and Open Price when time period starts. Pct Gain is the percentage gain from the Open Price when time period starts and the Current Close price. Max Close is the highest close that occurs during the time period for analysis. Avg Close is the average close that occurs during the time period for analysis. Sample Input File Date,Open,High,Low,Close,Adj Close,Volume 2015-12-08,66.989998,67.160004,66.180000,66.540001,58.241219,6866300 2015-12-09,66.300003,67.019997,65.160004,65.910004,57.689789,8578000 2015-12-10,65.980003,67.089996,65.910004,66.379997,58.101162,5768700 2015-12-11,65.379997,66.099998,64.480003,65.430000,57.269665,7572600 2015-12-14,65.629997,66.180000,64.730003,66.120003,57.873596,7371100 2015-12-15,65.459999,66.959999,65.239998,66.750000,58.425026,6061200 2015-12-16,66.220001,67.879997,66.139999,67.720001,59.274048,6747600 2015-12-17,67.180000,67.510002,64.879997,64.900002,56.805748,6800000 2015-12-18,64.599998,65.870003,64.099998,65.110001,56.989555,13490900 2015-12-21,65.589996,65.820000,64.379997,65.239998,57.103352,5311500 2015-12-22,66.250000,68.790001,66.110001,68.410004,59.878002,9697200 ... Note that the input data is sorted from oldest to newest. Program Requirements 1. Use at least 4 functions. 2. Use at least 3 named constants. 3. Use at least 3 arrays. 4. Use the current market data files. 5. Your analysis must contain the 8 market date spans (5, 10, 20, 50, 100, 200, 500, and 1000 days) shown in the Sample Output above and below. 6. Your analysis report must be written to a file. 7. File opens must be checked 8. Market dates must be stored in a (1000 element) string array. 9. The report format must closely follow the sample output above. Dollar values, number alignment, percentage formats, and approximate spacing must be observed. 10. Use any one of the input files for test: CAT.csv MSFT.csv WMT.csv 11. Your program must use the original CSV input file. You may not modify the original input file outside of your program. Note: your solution will be graded using another current input file of the same size. Program Hints There are many parts to this assignment. Break your solution down into pieces (functions), write and test each piece as you proceed. Start with reading in the history file. Make sure you are successful with that first, then proceed. In the beginning, work with a small amount of data (maybe array sizes of 10), so that you can see that you are performing calculations correctly. Don't worry about formatting the output until the end after you know you have all of the calculations are correct. Make sure you test as you proceed. Suggestions 1. Read in the input file and remove the commas. 2. Since the input date is recorded in the input file from oldest to newest, you may want to store the data backwards in the arrays. 3. Write a function to calculate the number of up days for the time period. 4. Write a function to calculate the number of down days for the time period. 5. Write a function to determine the max close for the time period. 6. Write a function to determine the average close for the time period. Sample Output Files Stock: MSFT Current Date: 2019-11-26 Current Close: $152.03 Market Days Start Date Open Price Up Days Down Days Gain Pct Gain Max Close Avg Close ----------- ---------- ---------- ------- --------- ---- -------- --------- --------- 5 2019-11-20 150.31 3 2 1.72 1.14% 152.03 150.39 10 2019-11-13 146.74 7 3 5.29 3.61% 152.03 149.80 20 2019-10-30 143.52 12 8 8.51 5.93% 152.03 147.31 50 2019-09-18 137.36 25 25 14.67 10.68% 152.03 142.23 100 2019-07-09 136.00 50 50 16.03 11.79% 152.03 139.78 200 2019-02-13 107.50 110 90 44.53 41.42% 152.03 131.42 http://voyager.deanza.edu/~bentley/cis22a/CAT.csv http://voyager.deanza.edu/~bentley/cis22a/MSFT.csv http://voyager.deanza.edu/~bentley/cis22a/WMT.csv 500 2017-12-01 83.60 268 230 68.43 81.85% 152.03 112.74 1000 2015-12-08 55.47 534 459 96.56 174.08%
Answered Same DayDec 01, 2021

Answer To: Assignment 10 - Stock Analysis due December 2nd Note: changes 11/27, sample output corrected 11/28...

Prasun Kumar answered on Dec 02 2021
152 Votes
Steps:
1. Unzip the file “ex10.zip”
2. Open a terminal
3. Navigate inside the unzipped folder (e
x10)
4. Type “make” to build the solution
5. Type “./ex10 WMT.csv” to run the solution
6. The output is created in WMT.txt file in the same folder.
7. Similarly if the program is run with “./ex10...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here