Python财务:get_data_yahoo不检索数据
大约一年前,我运行了此代码,而且运行良好。现在它已经停止工作了,我认为这与get_data_yahoo函数有关。这是我要运行的代码的一部分:
pd.options.display.width = 0
stocklist = si.tickers_sp500()
index_name = '^GSPC' # S&P 500: ^GSPC Dow Jones: ^DJI Nasdaq: ^IXIC
# Initiate stock index
n = -1
for stock in stocklist:
n += 1
# Set a time delay between each stock
time.sleep(0.25)
# Inform user which stock is being evaluated
print("\nPulling {} with Index {}".format(stock, n))
# Set 1-year time duration starting from 365 days ago today
start_date = datetime.datetime.now() - datetime.timedelta(days=365)
end_date = datetime.date.today()
# Download stock data for set time duration
# (Optional??) stock = [stock + '.AX' for stock in stocklist]
df = pdr.get_data_yahoo(stock, start=start_date, end=end_date)
现在这是没有返回数据。我想念什么?
I ran this code about a year ago and it was working fine. Now it has stopped working, and I think it has to do with the get_data_yahoo function. Here is part of the code I am trying to run:
pd.options.display.width = 0
stocklist = si.tickers_sp500()
index_name = '^GSPC' # S&P 500: ^GSPC Dow Jones: ^DJI Nasdaq: ^IXIC
# Initiate stock index
n = -1
for stock in stocklist:
n += 1
# Set a time delay between each stock
time.sleep(0.25)
# Inform user which stock is being evaluated
print("\nPulling {} with Index {}".format(stock, n))
# Set 1-year time duration starting from 365 days ago today
start_date = datetime.datetime.now() - datetime.timedelta(days=365)
end_date = datetime.date.today()
# Download stock data for set time duration
# (Optional??) stock = [stock + '.AX' for stock in stocklist]
df = pdr.get_data_yahoo(stock, start=start_date, end=end_date)
Now this is returning no data. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
库的语法可能已经改变。我更改了您的代码,并试图索取10股。 40岁以后,我自己停了下来。在我看来,没有必要经常滥用和要求数据。还将请求的深度减少了四天。如果您要求深度数据,您将遇到未交易的股票并且脚本会关闭的股票(我已经看到这样的问题)是很有可能的。
Probably the syntax of the library has changed. I changed your code and tried to request a few 10 shares. After 40, I stopped it myself. It seems to me that there is no need to abuse and request data often and not so much. And also reduced the depth of the request by four days. It is quite possible, if you request deep data, that you will come across a stock that is not traded and the script will shut down (I have seen questions like this).