Question: Python Almost there. Now that you have functions to read the various files and add all the data into data structures you are ready compute

Python

Almost there. Now that you have functions to read the various files and add all the data into data structures you are ready compute the final value of the portfolio. Paste your code from the previous two parts of this prelab as you will need to call those functions to complete this part. Reminder of the data formats: The input file will be a CSV file with each row in the format "buy_or_sell,quantity,ticker,date" where buy_or_sell is either the string "buy" or "sell", quantity is an integer representing the number of shares traded, ticker is a string representing the ticker symbol being traded, and date is the date of the trade in the format YYYY-MM-DD. You may assume there are files named .csv for each ticker symbol that the company trades. Each row of these CSV files will be in the format "date,price,volume" where date is in the format YYYY-MM-DD, the price is a float, and volume is an integer representing the number of shares that were traded on that day by all traders (you will not need the trading volume for this prelab) Part 3: Write a function named "portfolio_value" that takes one parameter that is a string representing a filename that contains all the trades made by your company throughout the year and returns the total value of the portfolio on the date "2015-12-31". The total value is the sum of all the quantities of stock owned times the price for that stock at the end of the year.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!