python - 学习使用 pandas datareader 绘制雅虎股价,但似乎不正确

标签 python pandas datareader

我正在学习 O'Reilly 类(class) - 面向开发人员的 Pandas 简介。

我使用雅虎股票价格绘制了图表。我必须修改给出的代码,因为它已经过时了。

这是 jupyter 笔记本: https://nbviewer.jupyter.org/github/jeremy886/pydata-notes/blob/master/ipython-notebooks/Time_Series.ipynb

请跳至底部查看图表。

我将我的图表与作者的图表以及 Google 的历史价格进行了比较,发现我的图表与其他图表不同。 (我认为作者的也与 Google 的不同)。

来自 Google 的价格信息:https://www.google.com.tw/search?q=yahoo+price&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=vHJkWNPuKvOm8weq5qrQBw

乍一看,pandas_datareader 源似乎不正确。例如,我得到的大多数收盘价约为 10 美元。昨天的价格是 12 美元,但 Google 的价格约为 38 美元。

请问这是什么问题?

  • pandas_datareader 不再值得信赖了吗
  • 或者有一些我不明白的调整
  • 或者我/作者的代码中有错误

谢谢,新年快乐。

最佳答案

您正在调用data.DataReader('F', 'yahoo', start, end)

来源:

def DataReader(name, data_source=None, start=None, end=None,
               retry_count=3, pause=0.001, session=None, access_key=None):
    """
    Imports data from a number of online sources.
    Currently supports Yahoo! Finance, Google Finance, St. Louis FED (FRED),
    Kenneth French's data library, and the SEC's EDGAR Index.
    Parameters
    ----------
    name : str or list of strs
        the name of the dataset. Some data sources (yahoo, google, fred) will
        accept a list of names.
    data_source: {str, None}
        the data source ("yahoo", "yahoo-actions", "yahoo-dividends",
        "google", "fred", "ff", or "edgar-index")

第一个参数是您感兴趣的数据集的名称,在您的例子中,'F' 代表福特。

data_source 参数是您从中获取数据的站点。在您的例子中,'yahoo'。这与股票价格不一样。如果您查看福特的股价,您会发现它们与您的股价相当。

如有疑问,请阅读文档。如果文档没有帮助,请阅读源代码 - https://github.com/pydata/pandas-datareader

关于python - 学习使用 pandas datareader 绘制雅虎股价,但似乎不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41372373/

相关文章:

python - 如何减少获取帧时的CPU使用率

python - 将数字串拆分为偶数和奇数整数列表

python - 检测 df 中的异常值

c# - Windows 应用商店应用程序 StreamSoket DataReader.LoadAsync() ObjectDisposedException

c# - 将查询结果显示为以逗号分隔的文字

asp.net - 在 ASP.NET (VB) 上使用 DataReader 返回上一行

python - "pythonic"方法将逗号分隔的整数字符串解析为整数列表?

python - 什么时候应该将函数的结果存储为 python 中的变量?

pandas - 从多个字典创建一个pandas DataFrame

python - 替换 DataFrame 中的值