Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please LInk for CSV file: http://www.cpp.edu/~ukjayarathna/courses/s18/cs299/files/data/SP500_ind.csv Link for XML:http://www.cpp.edu/~ukjayarathna/courses/s18/cs299/files/data/SP500_symbols.xml You have just been hired as an analyst for an investment firm. Your first

in python please

image text in transcribed

LInk for CSV file: http://www.cpp.edu/~ukjayarathna/courses/s18/cs299/files/data/SP500_ind.csv

Link for XML:http://www.cpp.edu/~ukjayarathna/courses/s18/cs299/files/data/SP500_symbols.xml

You have just been hired as an analyst for an investment firm. Your first assignment is to analyze data for stocks in the S&P 500, The S&P 500 is a stock index that contains the 500 largest publicly traded companies You have been given two sources of data to work with. The first is an XML file that contains the Symbol (ticker), company name, sector, and industry for every stock in the S&P 500, as of summer 2016 The second is a CSV file that contains pricing information for stocks in the S&P 500 between August 2009 and August 2010. There is one row in the CSV file for every stock, on every date that the market was open high price, the day's low price, the day's closing price, and the volume traded that day Each row contains the date as a string, the stock's ticker, the day's opening price, the day's Provided Files SP500 ind.csv and SP500 symbols.xml Write a Python module in Lastname-299-A3.py that includes the functions from the following activities. . Read the.csv file into a DataFrame called "csv_data" and xml file to a dictionary called "xml_dict" in your python module Generate a list of unique symbol values from the csv_data and name the list "ticker" Complete the following functions in your python module def ticker find(xml dict, ticker) . . """This function takes in the xml dict and a the list that contains a Symbol (ticker). Return the name of the ticker Ex: for ticker "A", the function returns Agilent Technologies Inc def calc avg_open(csv_data, ticker) "This function takes in the csv data and a ticker. Return the average opening price for the stock as a float. def vwap(stock_dict, ticker) "This function takes in the csv data and a ticker. Return the volume weighted average price (VWAP) of the stock. In order to do this, first find the average price of the stock on each day. Then, multiply that price with the volume on that day. Take the sum of these values. Finally, divide that value by the sum of all the volumes. (hint: average price for each day (high +low +close)/3) Using the functions you have created 1. 2. Read the XML file and CSV file and Find the VWAP and average opening price associated with each of the tickers found Use ticker find with the xml dict and ticker to find the associated name of the stock. Display the data as in the example below. (Hint: Write a loop that takes the "tickers" from the list and display the name, average open and vwap values) American Express Co 39.92 39.72 No data in SP500 23.04 22.85 AutoZone Inc 169.52 167.22 To perform these calculations, you should call above functions in a logical order, with the appropriate parameters Note that stocks move in and out of the S&P 500. Some stocks may be represented in the CSV file, but not in the XML file (and vice-versa). Display "No data in SP500" for the names of these tickers 3. 4

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

ISBN: 061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago