python exercise

0 comments

Exercise 1

You work for an investment firm as an analyst. One day, your boss came to you and ask you to pull out the following data and do the following tasks on the data.

  1. Download Google, Bank of America, Walgreen stock price data from ‘yahoo’ using the DataReader with a start date of January 1, 2000.
  1. Add a column to the data frame containing the 100-day moving average of the adjusted closing prices for each stock. Call this column Mv_Avg.
  1. Add another column that is the ratio of the adjusted closing price to the moving average, with the ratio lagged one day for each stock. Call this column Indicator.
  1. Add another column containing the return calculated as the percentage change in the adjusted closing price for each stock. Call this column Ret.

Exercises Hint:

use D[‘Adj Close’].pct_change() to compute the percentage change.

Exercise 2

In the excel file “Yahoo Ticker Symbols – September 2017”, there are all the stocks traded in the world in 2017, documented on Yahoo Finance. Design a way to collect all U.S. exchange traded stocks and get the daily price and trading volumes for 2017.

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}