Python date.today() 不适用于熊猫 pdr.get_data_yahoo)

问题描述

我正在尝试使用雅虎的熊猫股票阅读器库。我目前有以下代码

today=str(date.today())
print(today)
print(type(today))
start_date= '2020-01-01'
end_date = '2021-06-14'

stockData = pdr.get_data_yahoo(stock,start=start_date,end=today)

我得到 '2021-14-06' 和 输出

print(today)
print(type(today))

出于某种原因,在 get_data_yahoo() 函数中,当我使用 end=end_date 时它可以工作,但 end=today 在 6-11-2021 停止。两者完全相同,所以我很困惑为什么会发生这种情况。任何帮助,将不胜感激!谢谢!

解决方法

更新:这是因为股市在周末休市,所以没有这些日期的数据:(