Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

UWSC Date to Float Data Files & Floating Point Array Programming Exercises

UWSC Date to Float Data Files & Floating Point Array Programming Exercises

UWSC Date to Float Data Files & Floating Point Array Programming Exercises

Question Description

This comma-separated value file hold various daily values for the S&P500 stock index for all trading days from Jan 3, 1950 to Oct 7, 2016. Column headers in the file are self-explanatory, except the final column: The “Adj Close” column is the close price adjusted for dividends and splits. This file was downloaded from: http://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC (Links to an external site.) (accessed Oct 8, 2016; note that versions of the original data file that are currently available online may have slightly different formatting of the fields).

Remember, a comma-separated value file is a plain text file that follows certain conventions: commas separate columns, quotation marks set off fields, etc.

Please be aware of the following:

  • 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, write a program that does the following:

  1. Write a function convert_date_to_float that takes a string of the format yyyy-mm-dd and converts it to a floating point number. Thus, '1950-01-31' as input results in a return value of 19500131.0
  2. Reads the contents of the data file into a floating point array data2 without using genfromtxt or any other pre-written file-reading function (read, readlines, etc. are not pre-written file-reading functions but methods of a file object). Thus, you have to create a file object, use string methods to access, convert, etc. Make the first column be yyyy-mm-dd as a floating point number. You can use the function you wrote for #1 to do this. For this task, you do not have to write a function.
  3. Reads the contents of the data file into a floating point array data3 using genfromtxt. Using what we’ve covered in this class, the first column of the array this call to genfromtxt returns will be filled with “nan”s (i.e., “not-a-number” values). That’s okay. For this task, you do not have to write a function.
  4. Compare all values (except the first column) in data2 and data3 to confirm they are “equal” to each other. Since they’re all floating point values, you’re checking that they are “close” to each other. Hint: There’s a function in NumPy called allclose that will help here. For this task, you do not have to write a function.
  5. Create an xy plot of the adjusted close (y-axis) versus trading day (x-axis). You don’t need to plot a date on the x-axis; “days since Jan 3, 1950” would be fine. For this task, you do not have to write a function. Your graph should look similar to this one:
  6. Create an xy plot of the difference between the high and low value for the day (y-axis) versus trading day (x-axis). You don’t need to plot a date on the x-axis; “days since Jan 3, 1950” would be fine. For this task, you do not have to write a function. Your graph should look similar to this one:

NB regarding Tasks 2 and 3: Your goal is to read in the text data from the file and convert it into floating point values. You’ll then store the floating point values in an array. Once you’ve done that, the rest of the tasks are much easier to do. Do not store the text data as a string array; taking that approach will probably make things much more difficult for you. Also, if you find yourself writing nested for loops, you’re probably doing something wrong; it’s not supposed to be that hard.

Your code should be adequately commented in the sense that I can see which parts correspond to which tasks. Also, 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.

Whenever I talk about a “stock index” above, I do not mean the location of a value in a list or array but the value of a stock market benchmark like the S&P500 or DJIA stock index.

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.

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

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20