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
Note that the input data is sorted from oldest to newest.
Program Requirements
Use at least 4
Use at least 3 named
Use at least 3
Use the current market data
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
Your analysis report must be written to a
File opens must be checked
Market dates must be stored in a (1000 element) string
The report format must closely follow the sample output above. Dollar values, number alignment, percentage formats, and approximate spacing must be
Use any one of the input files for test: csv MSFT.csv WMT.csv
Your program must use the original CSV input file. You may not modify the original input file outside of your
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
Read in the input file and remove the
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.
Write a function to calculate the number of up days for the time
Write a function to calculate the number of down days for the time
Write a function to determine the max close for the time
Write a function to determine the average close for the time
Sample Output Files
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 |
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme