*Python Stock Exchange Data Problem Expected Duration: 3-6 hours A comma-separated value file stocks_data.csv contains historical data on the Adjusted...

50.1K

Verified Solution

Question

Programming

*Python

Stock Exchange Data

Problem

Expected Duration: 3-6 hours

A comma-separated value file stocks_data.csv contains historicaldata on the Adjusted Closing Price for 3 stocks daily from Jan 2,2009 to Dec 31,2018. The stocks are Apple (APPL), Microsoft (MSFT)and IBM (IBM).

A snippet from the data file looks like the following:

SymbolDateAdj. Close
MSFT4/16/201435.807358
MSFT6/21/201020.752356
IBM2/10/200968.930023
AAPL2/14/2018164.227203
IBM6/13/2017141.24379
IBM12/26/2017142.835663
MSFT4/1/200915.053272
AAPL4/17/200915.445643

You can see that each row has a symbol, date and closing price,but the stock data is not sorted by symbol, date or price.

Your task has two main parts:

Part I

For each stock, print the following information to the consoleand to a text file called stock_summary.txt:

  1. the max price and date it occurs
  2. the min price and date it occurs
  3. the average (mean) price

Part 2

Print to the console and append to the output filestock_summary.txt:

  1. The stock among the 3 with the highest overall closing priceand its date
  2. The stock among the 3 with the lowest overall closing price andits date

Example output looks like the following. Your output must matchthe format, but replace the placeholders with specific values.

AAPL----Max: price dateMin: price dateAve: meanIBM----Max: price dateMin: price dateAve: meanMSFT----Max: price dateMin: price dateAve: meanHighest: Symbol price dateLowest: Symbol price date

Tests

This project has a rubric that matches these test cases, and isused for grading.
Your instructor may also use automated unit test code and/or pylintfor grading.

  1. load data from csv input file
  2. if the input file does not exist, print \"file does not exist.\"and exit.
  3. generate summary data for each stock (counts as 1 test case,all correct for this to count)
  4. compute the highest of all stocks and compute the lowest of allthe stocks
  5. use functions to minimize obvious repeated code
  6. write same correct output to filestock_summary.txt and console
  7. use loops in code to eliminate repeated code
  8. use appropriate modules and builtin functions to simplifycode
  9. Code has a main function with conditional execution.
  10. File has a module docstring with required information init.
  11. Code follows PEP8 Python Style guide for code style (not yourbook's Java style)
  12. Thonny's Assistant or pylint says your code is OK, nowarnings.

I am really hoping that you can leave a lot of comments on howyou do this because I want to learn how to do it. If you can, canyou focus on #5 above? use functions to minimize obvious repeatedcode. Thanks for your help!

Answer & Explanation Solved by verified expert
4.2 Ratings (640 Votes)
ProgramSummary of data you can remove it if you wantSummarypython filenamepy    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students