是什么原因导致试图让yahoo_fin返回报价清单的价格?

问题描述 投票:0回答:2

我有一个行情清单,我想通过运行以下代码来检索价格:

from yahoo_fin import stock_info as si
for x in watchlist:
    print(si.get_live_price(x))

运行此文件时出现以下错误:

文件“”,第1行,在runfile('C:/ Users / User / OneDrive / Documents / Stuff / fluff 2.py',wdir ='C:/ Users / User / OneDrive / Documents / Stuff']

文件“ D:\ Anaconda3 \ lib \ site-packages \ spyder \ utils \ site \ sitecustomize.py”,运行文件中的第705行execfile(文件名,命名空间)

文件“ D:\ Anaconda3 \ lib \ site-packages \ spyder \ utils \ site \ sitecustomize.py”,第102行,在execfile中exec(compile(f.read(),文件名,'exec'),命名空间)

文件“ C:/ Users / User / OneDrive / Documents / Stuff / fluff 2.py”,第46行,在打印(si.get_live_price(x))

文件“ D:\ Anaconda3 \ lib \ site-packages \ yahoo_fin \ stock_info.py”,行338,以get_live_pricedf = get_data(ticker,end_date = pd.Timestamp.today()+ pd.DateOffset(10))

文件“ D:\ Anaconda3 \ lib \ site-packages \ yahoo_fin \ stock_info.py”,行68,在get_data中temp =负载(需要)

ValueError:预期的对象或值

但是,当我直接指代股票时,它会正常运行:

print(si.get_live_price('tsla'))

348.8399963378906

什么可能导致此问题?这是由于我使用的HTML解析器与代码早期部分中与yahoo_fin使用的HTML解析器不同吗?

python-3.x anaconda spyder finance yahoo-finance
2个回答
0
投票

尝试一下,它为您提供了最近6个月的数据的完整数据框


0
投票

大约三天前出现相同的问题和错误。

© www.soinside.com 2019 - 2024. All rights reserved.