You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could not make ystockquote to work no matter what I tried. Instead I used yahoo's yfinance package which has a straightforward api.
I'm recording the updated code here in case someone encounters the same problem.
import yfinance as yf
import pandas as pd
n_observations = 100 # we will truncate the the most recent 100 days.
stocks = ["AAPL", "GOOG", "TSLA", "AMZN"]
enddate = "2022-02-19"
startdate = "2021-07-01"
stock_closes = pd.DataFrame()
for stock in stocks:
x = yf.download(stock, startdate, enddate)
stock_closes[stock] = x['Close']
I could not make ystockquote to work no matter what I tried. Instead I used yahoo's yfinance package which has a straightforward api.
I'm recording the updated code here in case someone encounters the same problem.
import yfinance as yf
import pandas as pd
n_observations = 100 # we will truncate the the most recent 100 days.
stocks = ["AAPL", "GOOG", "TSLA", "AMZN"]
enddate = "2022-02-19"
startdate = "2021-07-01"
stock_closes = pd.DataFrame()
for stock in stocks:
x = yf.download(stock, startdate, enddate)
stock_closes[stock] = x['Close']
stock_closes
stock_returns = stock_closes.pct_change().iloc[1:, :]
stock_return = stock_returns.iloc[-n_observations:,:]
The text was updated successfully, but these errors were encountered: