University of Washington Seattle Campus Python Code File Programming Task
Question Description
nasdaq
: Close of index at the end of each trading day intrading_days
.sp500
: Close of index at the end of each trading day intrading_days
.djia
: Close of index at the end of each trading day intrading_days
.trading_days
: Number of trading days since Jun 1, 2016. Jun 1 is trading day 0.
In the discussion below, you might find it confusing when I refer to “index.” Do I mean the address of an element of a list (it’s “index”) or do I mean one of the stock indices such as the DJIA, etc.? I try to make it clearer by referring to the former as the “element index” and the latter as the “stock index”. You’ll also want to pay attention to the context.
Please be aware of the following:
- Please do not read in input from the keyboard. Instead, set values to variables or type in values as input arguments to function calls.
- If you have code that doesn’t work in your notebook or source code file, but you have later code in your file that does work, put your answers into different files so the code errors in your answers to the earlier questions don’t prevent the file from running for the later questions.
- For questions that ask you to create images, your code must have a
show
(at the end of the entire file, not the end of each applicable question) orsavefig
call (for each applicable question) so that we can see the plots you have made.
Using the above data, write a program that does the following:
- Calculates and prints out the correlation between each combination of the three stock indices, i.e., between
nasdaq
andsp500
,nasdaq
anddjia
, andsp500
anddjia
. This calculation cannot make use of any pre-written calculation functions from SciPy, NumPy, matplotlib, pandas, etc. (You can, however, use functions likeshape
,ravel
, etc.) That is to say, you have to write your own mean, standard deviation, covariance, sum, cumsum, etc. functions (if you choose to use them) in the .py file. (If you don’t import scipy, etc., you’ll be fine.) Note that if you do this task by writing a correlation calculating function, it will help you do #2 below. - Calculates the lag autocorrelation for each of the three stock indices. You can consider only positive lags if you’re correlating f(t) vs. f(t+lag), where f is the NASDAQ, S&P500, or DJIA index. You do not need to consider lags greater than 10 days. Again, you cannot use calculation functions you have not written yourself. (You can, however, use functions like
shape
,ravel
, etc.) - Plots each lag autocorrelation out on a single figure. The y-axis of the graph should be the correlation coefficient and the x-axis should be lag in number of days. You may use matplotlib functions for this section.
- Describe what the plot tells you. (You do not have to be “right” about what the plot says, just not “wrong.” That is, if you claim the plot says something and it says the opposite of that, that’s “wrong.” If you say the plot says something and it might say that or might not, that’s okay.) I mainly want you to try and interpret the plot.
Your code should be adequately commented. In particular, any functions you write should have adequately written docstrings.
As a reminder, while you can talk and work with each other on the homework, you have to write-up your own solution.
Deliverables
Your Python code file (you can name it anything you want, as long as it ends with the .py or .ipynb suffix). Please do not submit your image files. Please use comments to label the question numbers in your code.
"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."