Trouble Downloading Stock Data (Financial Analysis Capstone)

( Financial Analysis Capstone )

I’m having all kinds of trouble using Pandas DataReader to download financial data from Yahoo! I’ve read multiple blog posts and the Github readme for yfinance, but when I run my code it returns:

Enter names separated by commas: 

…instead of the expected stock_data table.

My code is very simple:

#IMPORT PACKAGES
import pandas as pd
import numpy as np
from pandas_datareader import data as pdr
import yfinance as yf
yf.pdr_override()
import matplotlib.pyplot as plt
%matplotlib inline

#LOAD ADJUSTED CLOSINGS
symbols = yf.Ticker("msft appl goog")
start_date = "2008-01-01"
end_date = "2020-04-01"
stock_data = pdr.get_data_yahoo(tickers = symbols, start = start_date, end = end_date)

print(stock_data)

The following code is from a previous Jupyter Notebook project (Visualizing Tech Stocks). This code didn’t work either, it just returned the same prompt above.

#IMPORT PACKAGES
import pandas as pd
import numpy as np
import pandas_datareader as web
import matplotlib.pyplot as plt
%matplotlib inline

#LOAD ADJUSTED CLOSINGS
symbols = ["MSFT", "AMZN", "AAPL", "GOOG", "FB"]
start_date = "2019-01-01"
end_date = "2019-07-01"
stock_data = web.get_data_yahoo(symbols, start_date, end_date)

Can anyone point me in the right direction?

…so you start by giving it a string, and then change that to a list of strings? how are you choosing those? maybe you ought to read the documentation of the function you’re using? read the manual.

In any case, your code doesn’t seem to behave as you describe:

https://repl.it/repls/AliveWorstBudgetrange

1 Like

I have tried various methods (based on the blogs, Github manual, and previous projects) to pass in the stock symbols. Maybe I have an issue with PyChaem that’s causing the issue. The link you sent seems to work decently right, I can address those errors.