Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Data analytics is an interesting and growing area in Computer Science. In addition, Finance is an industry that employs Computer Science and Computer Information Technology

Data analytics is an interesting and growing area in Computer Science. In addition, Finance is an industry that employs Computer Science and Computer Information Technology majors. Thus, the design and implementation of statistical and simulation techniques is relevant. For this assignment you will calculate and simulate the returns of a stock market based on the weekly percent return information of how the SP500 performed from 1/1/1950 to 12/31/2018 (3601 weeks). That data is in the text file SP500-1950-2018-weekly.txt posted with this assignment specification. The data used to create the weekly percent return was retrieved from Yahoo finances historical data for the SP500. https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC Over those 3601 weeks the SP500 average (mean) weekly return was 0.16% (0.0016), the median (midpoint) was 0.29% (0.0029), and its standard deviation was 2% (0.0206). The average yearly return was 8.3% (0.0832 = 52 * 0.0016). If one had invested $100 on 1/1/1950 it would have been worth $ 15,033.86 on 12/31/2018. These values are from a spreadsheet. There are 2 phases to this assignment. Phase 1. In the first phase of this assignment, you are going to calculate the return of investing $100 over this period using weekly return data in a file. You must design and implement two classes in Phase 1 named: SimulateMarket and Sample. The design goal is to have Sample represent any sample, or collection, of observations and to be independent of the SimulateMarket application. You will use the Sample class in other programming assignments for this course. SimulateMarket is the application class (file SimulateMarket.java). SimulateMarket has a main method. SimulateMarket.class is the program that you will run. SimulateMarket must use the following symbolic constants (instance constants). constants name value type FILE_NAME SP500-1950-2018-weekly.txt private final String WEEKS 3601 private final int INVEST 100.0 private final double SimulateMarkets main method is shown below. There are no run time arguments to process, so main calls SimulateMarkets constructor. public static void main(String[] arg) { new SimulateMarket(); } SimulateMarkets constructor is the manager of the application. It should create a Sample instance named model, it should report the statistics of model, and it should call a method named historicalSP500(). Sample model can be created with the following statement. model = new Sample("SP500", makeDistribution(FILE_NAME)); 2 Sample model should be an instance variable of SimulateMarket. It will be also be used by other simulation methods in phase 2. The method makeDistribution reads the data from the file (SP500-1950-2018-weekly.txt) and stores it in a local ArrayList. Try/catch exception handling must be used with file processing. The local ArrayList is returned to be used by Samples constructor. private ArrayList makeDistribution(String fileName) {} Method historicalSP500() will calculate the return of investing $100 over the WEEKS number of weeks using the data stored in the Sample model. Have a local variable named money that is initially set to INVEST. For each week (where week = 0; week < WEEKS; week++) the value of money for the previous week is increased by the weekly percent return. You can use the follow expression to get the percent weekly return for a specific week stored in Sample model. model.get(week); Method historicalSP500 should report the value of money (the return) for investing for WEEKS in the SP500. Sample. Sample will use a private ArrayList data instance variable to hold the values in the sample. In phase 1, Sample will have 4 methods: its constructor, get(int i), computeStats(), and toString(). Samples constructor should assign the values of its ArrayList "argument" to its instance of ArrayList data (use ArrayList's copy constructor). The method get(i) should return the value in data at index i. The method computeStats() should calculate the following descriptive statistics for the values in data: min, max, average, median (midpoint), and standard deviation (a measure of variability or risk). Method toString() is inherited from Object and overridden in Sample. It will generate the report of the descriptive statistics using the method String.format(String format, Object... args). The String returned from toString() should have the following format. The values in the example below are the values your program should report for model in Phase 1. : size = <#####>, min = <#.####>, average = <#.####>, median = <#.####>, sd = <#.####>, max = <#.####> Below is the output from phase 1. P1 Simulate Market by Mike Barnes & Jane Doe Historical SP500 statistics: SP500: size = 3601, min = -0.1820, average = 0.0016, median = 0.0029, sd = 0.0206, max = 0.1412 Historical SP500 $ 100 becomes $ *.?? Note, the output above for models report is on two lines due to font size and word wrap. It is a single line in the programs output. The values can be used to test that your makeDistribution method reads the data file correctly. The historical result is not shown in the example above.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions

Question

How can earnings management affect the quality of earnings?

Answered: 1 week ago

Question

What is a verb?

Answered: 1 week ago