Select Page

University of Washington Running a Computer Program Python Coding Task

Question Description

Hello i will be adding all the work and resources that you need to complete this assignment and if you need additional information you can always message me for more info

  • nasdaq: Close of index at the end of each trading day in trading_days.
  • sp500: Close of index at the end of each trading day in trading_days.
  • djia: Close of index at the end of each trading day in trading_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) or savefig call (for each applicable question) so that we can see the plots you have made.

Using the above data, do the following:

  1. Write a function called percent_of_mean that accepts one 1-D array of the values of a stock index as input. The function calculates the value of the stock index for each day as a percent of the mean value over the period covered by the list (you may use the SciPy mean function if you wish). Do not use loops.
  2. Make a plot of all three stock indices on one figure showing the value of each stock index as a percentage of the mean of that stock index vs. trading day since Jun 1, 2016. Title the plot and axes and add a legend as appropriate. You may reuse your previous assignment’s code to do this task. I’m asking you to do this again to confirm your function in Task #1 worked correctly.
  3. Write a function called num_days_big_percent_chg that has two inputs: a 1-D array that contains the values of a stock index and a number that is a percent. The function calculates and returns the total number of trading days where the magnitude of the percent change (up or down) in the stock index since the previous day is greater than the value of the percent input into the function. Do not use loops.
  4. For each stock index, calculate the number of days the magnitude of the percent change (up or down) in the stock index since the previous day is greater than 0.2%, 0.4%, 0.6%, 0.8%, and 1.0%. (It’s easier if you put the number of days values you calculated in a list for each of the above percent threshold values.) Make a plot of all three stock indices on one figure showing, for each stock index, the number of days vs. the percent threshold value. You may reuse your previous assignment’s code to do this task. I’m asking you to do this again to confirm your function in Task #3 worked correctly.
  5. Write a function moving_average that accepts a 1-D array as input and returns the three-day simple moving average. For each day of the stock index, you calculate the three-day simple moving average for a day in question by averaging the values of the stock index for the last three days (including the day in question). The function’s return value will thus be an array two elements less than the input array. You can learn more about a simple moving average by reading parts of this page (Links to an external site.) and this page (Links to an external site.). You cannot use a pre-written moving average function, though you may use the NumPy mean function if you wish (though you do not have to). You may use no more than one loop for this task and must make use of array syntax in your solution. Note that using array slicing to get a subarray is not array syntax; array syntax is implicit looping for (often arithmetic) operations.
  6. Make plots of the three-day simple moving average for all three stock indices, with each stock index’s curve on separate figures, vs. trading day since Jun 1, 2016. On each plot, also superimpose the non-moving averaged stock index (that is, the stock index values without any averaging done on it). Title the plots, axes, and add legends as appropriate. Thus, for this task, you should have three separate plots and each plot should have two curves. Here’s an example of what the DJIA graph should look like:

Reminders: NB: Remember in all the above problems that when I say “stock index value” or “the stock index,” I mean the value or values of the DJIA/S&P500/NASDAQ stock index at the end of the trading day, not the location of that value(s) in the list of values.

Hint: Remember array syntax doesn’t work on a list. If you have a list and you want to use array syntax, you first convert the list into an array by using NumPy’s array function.

Your code should be adequately commented. In particular, any functions you write should have adequately written docstrings. You may reuse docstrings from previous assignment(s).

As a reminder, while you can talk and work with each other on the homework, you have to write-up your own solution.

"Place your order now for a similar assignment and have exceptional work written by our team of experts, guaranteeing you "A" results."

Order Solution Now