Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Yahoo! Finance allows you to download historical data in CSV format, a popular format for importing and exporting data between applications, especially spreadsheets and databases.

Yahoo! Finance allows you to download historical data in CSV format, a popular format for importing and exporting data between applications, especially spreadsheets and databases. CSV is a simple text-based format in which values are written as text, with commas used to separate valueshence the name. The following example shows the first six lines from a CSV file for Apple Inc.s historical data for 2022: Date,Open,High,Low,Close,Adj Close,Volume 2021-12-31,178.089996,179.229996,177.259995,177.570007,176.276230,64062300 2022-01-03,177.830002,182.880005,177.710007,182.009995,180.683853,104487900 2022-01-04,182.630005,182.940002,179.119995,179.699997,178.390701,99310400 2022-01-05,179.610001,180.169998,174.639999,174.919998,173.645523,94537600 2022-01-06,172.699997,175.300003,171.639999,172.000000,170.746811,96904000 This example shows there are seven columns of data and the column names, separated by commas are: Date, Open, High, Low, Close, Adj Close, and Volume. All subsequent lines are the historical data for each date trading occurred: Date (in YYYY-MM-DD format) Opening price High Low Closing price Adjusted closing price Volume traded In this problem, you will be given a years worth of data in CSV format, read it into a List, and produce a summary report for a given date range. The ten companies used in this problem are: Symbol Company AAPL Apple Inc. AMD Advanced Micro Devices, Inc. AMZN Amazon.com, Inc. DELL Dell Technologies Inc. EA Electronic Arts Inc. GOOG Alphabet Inc. INTC Intel Corporation META Meta Platforms, Inc. MSFT Microsoft Corporation NFLX Netflix, Inc. Input: The program must read three things: A stock symbol (String), a string of characters that uniquely identify a stock (e.g. AAPL for Apple or INTC for Intel Corporation). A start date (String), in YYYY-MM-DD format. An end date (String), in YYYY-MM-DD format. A volume (integer) Processing: Using the csv_to_list() function with the stock symbol as the argument, read the contents of the stocks CSV file into a table List and save the table to a variable. For example, csv_to_list("AAPL") to read Apple Inc. data into a List. The table created from the CSV file will look something like the following: [ ['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'], ['2022-01-03', '177.830002', '182.880005', '177.710007', '182.009995', '180.683853', '104487900'] ['2022-01-04', '182.630005', '182.940002', '179.119995', '179.699997', '178.390701', '99310400'] ['2022-01-05', '179.610001', '180.169998', '174.639999', '174.919998', '173.645523', '94537600'] ... ['2022-12-30', '128.410004', '129.949997', '127.430000', '129.929993', '129.731918', '76960600'] ] NOTE: All data read from the CSV is String. Remember to convert prices to floats and the volume to integer before using them. Locate the row of data for the start date. For all rows from the start date to the end date inclusive: Count the total number of trading days in the period. Count the number of days the volume traded reached or exceeded the inputted volume. Find the largest daily price variation (the difference between the high and low prices) and the date on which it occurred. Output: Using f-strings, print the information you found in the following format: Stock: [company_name] ([stock_symbol]) Dates: [start_date] to [end_date] Trading days: [trading days] Days at or over [volume]: [days_at_or_over] Largest variation: $[99.99] on [date] Note: The inputted volume ([volume]) must have commas between hundreds, thousands, and millions, and the largest variation ([99.99]) must be rounded to two decimals, as shown in the following examples. Examples: Input Output AAPL 2022-01-01 2022-01-31 100000000 Stock: Apple Inc. (AAPL) Dates: 2022-01-01 to 2022-01-31 Trading days: 20 Days at or over 100,000,000: 9 Largest variation: $7.60 on 2022-01-24 AMD 2022-01-01 2022-03-31 75000000 Stock: Advanced Micro Devices, Inc. (AMD) Dates: 2022-01-01 to 2022-03-31 Trading days: 62 Days at or over 75,000,000: 54 Largest variation: $15.36 on 2022-02-11 AMZN 2022-04-01 2022-06-30 100000000 Stock: Amazon.com, Inc. (AMZN) Dates: 2022-04-01 to 2022-06-30 Trading days: 62 Days at or over 100,000,000: 17 Largest variation: $9.15 on 2022-04-21 Test Cases: Visible Test Cases Problem 2 (30 Marks) For visible test cases you will see the expected output of tests. Note If your program outputs nothing the test case will fail with no feedback. Check It!Show output LAST RUN on 3/19/2023, 1:11:34 PM Check 1 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Apple Inc. (AAPL) Dates: 2022-01-01 to 2022-01-31 Trading days: 20 Days at or over 100,000,000: 9 Largest variation: $7.60 on 2022-01-24 Check 2 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Advanced Micro Devices, Inc. (AMD) Dates: 2022-01-01 to 2022-03-31 Trading days: 62 Days at or over 75,000,000: 54 Largest variation: $15.36 on 2022-02-11 Check 3 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Amazon.com, Inc. (AMZN) Dates: 2022-04-01 to 2022-06-30 Trading days: 62 Days at or over 100,000,000: 17 Largest variation: $9.15 on 2022-04-21 Check 4 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Dell Technologies Inc. (DELL) Dates: 2022-01-01 to 2022-06-60 Trading days: 124 Days at or over 5,000,000: 36 Largest variation: $4.15 on 2022-05-27 Check 5 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Electronic Arts Inc. (EA) Dates: 2022-01-01 to 2022-01-15 Trading days: 10 Days at or over 2,500,000: 2 Largest variation: $5.19 on 2022-01-07 Check 6 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Alphabet Inc. (GOOG) Dates: 2022-06-01 to 2022-12-31 Trading days: 148 Days at or over 25,000,000: 68 Largest variation: $7.80 on 2022-07-05 Check 7 failed Enter the name of the CSV file: Enter the Stock symbolStock: EInter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line l Corporation (INTC) Dates: 2022-10-01 to 2022-12-31 Trading days: 63 Days at or over 50,000,000: 12 Largest variation: $2.25 on 2022-10-13 Check 8 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a lineStock: Meta Platforms, Inc. (META) Dates: 2022-01-01 to 2022-12-31 Trading days: 251 Days at or over 100,000,000: 6 Largest variation: $20.52 on 2022-01-24 Check 9 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Microsoft Corporation (MSFT) Dates: 2022-06-01 to 2022-06-30 Trading days: 21 Days at or over 40,000,000: 3 Largest variation: $13.05 on 2022-06-02 Check 10 failed Enter the name of the CSV file: Enter the Stock symbol: Enter the start date (yyyy-mm-dd): Enter the end date (yyyy-mm-dd): Enter the volume threshold: Traceback (most recent call last): File "problem2.py", line 31, in volume = int(input("Enter the volume threshold: ")) EOFError: EOF when reading a line Stock: Netflix, Inc. (NFLX)

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

Recommended Textbook for

Foundations Of Cost Control

Authors: Daniel Traster

1st Edition

0132156555, 978-0132156554

More Books

Students also viewed these Accounting questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago