Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2: Use Pandas data-reader to retrieve adjusted closing price information from AphaVantage for the stocks on the list assembled in the previous question. Use

image text in transcribed
Question 2: Use Pandas data-reader to retrieve adjusted closing price information from AphaVantage for the stocks on the list assembled in the previous question. Use the Adjusted Close column to compute closing returns for each and save your results in a dataframe with dates as the row labels and tickers as the column labels Data should cover the period February 28, 2020 to March 27, 2020. (30 pts) In [8): # For some reason Alphavantage does not like this ticker, although it seems to be fine with BRK.b # so you will need to include an if statement that skips any tickers that cause problems for the AlphaVantage API. bad_tickers = ['BF.b'] In (11): import pandas_datareader.data as par import datetime import time In [16]: start - datetime.datetime (2020, 2, 28) end = datetime.datetime(2020. 3. 27) In ( ): Since the free version of Alphavantage accepts queries for only 5 tickers per minute, you will need to implement a delay after every 5 queries. Here is an example showing how that can be done. This assumes that each new set of stock returns is placed into a new column of the returns dataframe. if Len(returns.columns) 5 == @: time. sleep(60) Steps: . Convert Alphavantage code from Pandas 10 example to retrieve a series of adjusted close prices for a particular ticker and date range . Convert to returns Make a loop that does this for all stocks in your list, saving returns for each stock in a separate column Question 2: Use Pandas data-reader to retrieve adjusted closing price information from AphaVantage for the stocks on the list assembled in the previous question. Use the Adjusted Close column to compute closing returns for each and save your results in a dataframe with dates as the row labels and tickers as the column labels Data should cover the period February 28, 2020 to March 27, 2020. (30 pts) In [8): # For some reason Alphavantage does not like this ticker, although it seems to be fine with BRK.b # so you will need to include an if statement that skips any tickers that cause problems for the AlphaVantage API. bad_tickers = ['BF.b'] In (11): import pandas_datareader.data as par import datetime import time In [16]: start - datetime.datetime (2020, 2, 28) end = datetime.datetime(2020. 3. 27) In ( ): Since the free version of Alphavantage accepts queries for only 5 tickers per minute, you will need to implement a delay after every 5 queries. Here is an example showing how that can be done. This assumes that each new set of stock returns is placed into a new column of the returns dataframe. if Len(returns.columns) 5 == @: time. sleep(60) Steps: . Convert Alphavantage code from Pandas 10 example to retrieve a series of adjusted close prices for a particular ticker and date range . Convert to returns Make a loop that does this for all stocks in your list, saving returns for each stock in a separate column

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

Retirement Income Recipes In R From Ruin Probabilities To Intelligent Drawdowns

Authors: Moshe Arye Milevsky

1st Edition

3030514331, 9783030514334

More Books

Students also viewed these Accounting questions

Question

=+which it operates?

Answered: 1 week ago

Question

=+How should we organize a book to maximize learning and interest

Answered: 1 week ago