Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It need two class, one Sample and one SimulateMarket, so that it can do the linear simulation and distributional simulation and monte carlo simulation. all

It need two class, one Sample and one SimulateMarket, so that it can do the linear simulation and distributional simulation and monte carlo simulation. all the works need to be done in JAVA language

Data analytics is an interesting and growing area in Computer Science. In addition Finance is an industry that employs many Computer Science and Computer Information Technology majors. Thus, the design and implementation of statistical and simulation techniques is relevant. For this assignment you will simulate the returns of a stock market based on the weekly percent return information of how the SP500 performed from 1/1/1950 to 8/24/2018 (3582 weeks). That data isin the text file SP500-Weekly.txt posted with this assignment specification. The data used to create the weekly percent return was retrieved from Yahoo finances historical data for theSP500.

https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC

Over those 3,582 weeks the SP500 average (mean) weekly return was 0.17% (0.0016), the median (midpoint) was 0.29% (0.0029), and its standard deviation was 2% (0.0205). The average yearly return was 8.3% (0.083 = 52 * 0.0016). If one had invested $100 on 1/1/1950 it would have been worth $17,152.46 on 8/24/2018.

You are going to experiment with three simulation techniques to see how similar they are with the SP500 weekly distribution. Well call these techniques: linear, distributional, and Monte Carlo. Simulation is a technique where one can run many trials or scenarios that either generate a value (linear) or sample from a model distribution (distributional, Monte Carlo) toestimate a model or system. We are going to see how much a starting equity value of $100 increases in our simulations. We will compute statistics on our simulated trials. We will calculate the minimum, maximum, expected (mean, average), and median (midpoint) return values. The standard deviation, a measure of variability or risk, will also be computed. As with political polling, the more observations (trials) the more confident one is with the results.

You must design and implement two classes: Sample and SimulateMarket for this assignment. You can design and implement more, but you must have these two.

SimulateMarket. SimulateMarket is the application class for this assignment; it has a main method. SimulateMarket should estimate the growth of an investment ($100) over a duration (3582 weeks) using the assigned simulation techniques and report the results of the simulations.

Sample. There can be zero, one, or two instances of Sample used depending on the simulation technique. Instances of Sample have a variable ArrayList data that holds the valuesof the Sample. A generic ArrayList is part of the assignment specification. Sample computes and reports statistics on its data. Sample should have a method named computeStats() that calculates these descriptive statistics. Sample should have private Double variables to hold thesestatistics and public getter methods to return each statistic. Sample should have a public StringtoString() method that returns a description of the sample: name, size, min, max, mean, median, and standard deviation values. Consider using the static String.format(...) method with formatspecifications in your toString(). For example:

: size = <#####>, min = <#.####>, max = <#.####>, mean = <#.####>, median = <#.####>, sd = <#.####>

model: size = 3582, min = -0.1820, max = 0.1412, mean = 0.0016, median = 0.0029, sd = 0.0205, 

Linear simulation. SimulateMarket does not need to use an instance of Sample. With the starting equity, increase the equity value weekly (3582 times) by the average (0.0017) and median (0.0205) weekly return statistics from the actual SP500 distribution. Since this technique has a constant weekly increase, you will run 1 simulation trial for both the average and median and report the final equity value. This can be compared with the return the return of our actual data ($17,255.04). There are two linear simulation runs; using the average and using the median.

Distributional simulation. SimulateMarket uses an instance of Sample named equity for thedistributional simulation technique. With the starting equity, increase the equity value weekly by randomly sampling from a normal distribution with a mean (average and median) and standard deviation. Since you will be sampling from the distributions you should run 1,000 trials and calculate your statistics on the 1,000 equity returns. Use Javas Random.nextGaussian(mean,stdev) method to sample values from a normal distribution. Review the posted NormalDistribution.java example. Use the Sample class to hold the equity returns from the trialsand to compute and report the simulations statistics. There are two distributional simulations runs; using the average and using the median.

Monte Carlo simulation. SimulateMarket uses two instances of Sample (equity and model) for the Monte Carlo simulation technique. With the starting equity, increase the equity value weekly by a random sampled from the SP500 weekly return distribution and simulate 3582 weeks of stock market return. Use Javas Random classs nextInt(max) method to get a random weekly return from the posted weekly return data. One could sample a random value from an ArrayList of Double values name data with the following code snippet

Random r = new Random(); ... Double value = data.get(r.nextInt(data.size()));

The model instance of Sample is used to hold the posted SP500 weekly return data and toreport its statistics. When creating the file input stream used to read the data from the SP500-Weekly.txt you must use try/catch exception handling.

The Sample class will be used in P2. We may modify Sample in P2. Design and implement Sample so that its purpose is to represent a collection of data values, compute descriptivestatistics for the sample, and display a report of the sample. The simulation specific variablesand methods should be in the SimulateMarket class.

Use good program design: information hiding (private variables, public accessor methods), appropriately named variables, constant variables instead of hard-coded constants (private static double invest = 100.00; instead of 100.00), and consistent style (indentation, use of blank lines, etc.). You must have a comment block at the top of each *.java file that describes the class and lists the authors (group members). You should comment your work for a knowledgeable reader. What comments would you want to read in your program to understand it, if you were reading a year after you wrote it?

Compile all course assignments with stricter generic testing use Xlint. The command line call for the compiler is shown below, or set as a compile flag in your IDE.

javac Xlint *.java

Submission

Submit an archived (zipped, jar) file containing the following files: all source *.java files, SP500-Weekly.txt, and your report. The report file can be of type *.pdf, *.doc, *.html, or *.rtf. If you want to use another format please talk with me first. The report should have UML liteclass diagram for the Sample and SimulateMarket and other class you design and implement. These should have all methods and the important variables. It should also have a table of the results of your simulations, a brief description of your results, and an analysis (compare and contrast) of each stock market simulation technique.

If you have any questions please ask. Lab is a good time and place to discuss the assignment with me, your group (if you are in one), and with your fellow students. There is a Canvassdiscussion forum for this assignment that can be used to ask, read, and comment on questions concerning this project. If you email me questions I will also reply and I reserve the right to post relevant email questions and my replies on Canvas so all students can use them.

Assignment grading

No late assignments are accepted (unless there is a strong reason for an extension: e.g., medical, etc.) that has been made and agreed upon by me, before the due date.

If you submit an assignment that does not compile, is incomplete, or incorrect, do not expect a grade above C-. If you submit an assignment that implements the specified assignment correctly but with poor design or with a minimal report the grade will probably be in the 81 to 90 range (B- to B+). For a submission to earn an A grade (91 to 100) it must first be correct, well designed and implemented, and the report must be more than a description of the assignment and results; it must also discuss, compare, contrast, and analyze the results. If you have the assignment done and you wish to try other compliant simulation techniques (or extensions to these) that could also contribute to a higher grade. My intent in this assignment is for you to gain experience with the generic ArrayList class, simulation, pseudo-random number generators, descriptive statistics and distributions, file input, and the analysis of the correctness and results of programs that do not have convergent correct solutions (for example, simulations).Ill be glad to talk with you about your ideas; after you have solved the specified assignment.

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

Students also viewed these Databases questions

Question

Why is it hard for acquirers simply to buy cheap?

Answered: 1 week ago

Question

c. Determine the confidence intervals of the linearised parameters.

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago