简体   繁体   English

"Pandas_DataReader 不适用于 Yahoo Finance API"

[英]Pandas_DataReader not working with Yahoo Finance API

I started working on a project a month ago to try and predict future stock prices using historical data.一个月前,我开始研究一个项目,尝试使用历史数据预测未来的股票价格。 The project was going fine and I decided to take a small break to upgrade my PC.项目进展顺利,我决定稍作休息来升级我的电脑。 Well, I tried checking out my code after finishing the computer but now I'm running into a bunch of errors concerning pulling data from Yahoo Finance API.好吧,我在完成计算机后尝试检查我的代码,但现在我遇到了一堆关于从 Yahoo Finance API 提取数据的错误。 My friend is working on the same project and he said he isn't encountering any issues in the code so I think there's something wrong with my code environment.我的朋友正在做同一个项目,他说他在代码中没有遇到任何问题,所以我认为我的代码环境有问题。 I'm not sure what to do since I'm pretty new to coding but I'm hoping someone can help me with the section of code below:我不知道该怎么做,因为我对编码很陌生,但我希望有人可以帮助我处理下面的代码部分:

import pandas_datareader as web
import datetime as dt

# Load Data

symbols = 'NIO'

start = dt.datetime(2012,1,1)
end = dt.datetime(2020,1,1)

data = web.DataReader(symbols, 'yahoo', start, end)

I don't know if it helps but yesterday I saw five questions for similar problem in module yfinance .我不知道它是否有帮助,但昨天我在yfinance模块中看到了五个类似问题的问题。

It seems Yahoo changed something on pages and it needs changes in modules. Yahoo似乎改变了页面上的一些东西,它需要改变模块。

For yfinance helps installing the newest version.对于yfinance帮助安装最新版本。

Maybe this module needs also newer version.也许这个模块还需要更新的版本。
If they didn't create newer version then you will have to wait some time for newer version.如果他们没有创建较新的版本,那么您将不得不等待一些时间来获得较新的版本。

I also used to download data through pandas_datareader for Yahoo!我也曾经通过 pandas_datareader 为 Yahoo! 下载数据! But I ran into the same issues a while ago, and it was never fixed.但是我不久前遇到了同样的问题,并且从未修复过。 So now, I just use the yfinance module.所以现在,我只使用 yfinance 模块。 It's a bit different, but here's the code I use as an example:这有点不同,但这是我用作示例的代码:

import yfinance as yf
start = '2014-01-01'
end = '2022-01-01'
symbol = 'XLE'
stock_data = yf.Ticker(symbol)
stock_data = stock_data.history(start=start, end=end) 
[['Open','High','Low','Close']]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM