gpt4 book ai didi

python - Alpha Vantage "KeyError: ' 时间序列(每日 )'"

转载 作者:太空宇宙 更新时间:2023-11-04 01:57:22 28 4
gpt4 key购买 nike

我正在尝试制作一个简单的 GUI,用于从 Alpha Vantage 收集几组历史股票数据。我收到此错误:

  File "d:\GIT\StockAI\main.py", line 34, in run
data = ts.get_daily(symbol=stock, outputsize='full')
File "C:\Users\benlu\Anaconda3\lib\site-packages\alpha_vantage\alphavantage.py", line 178, in _format_wrapper
data = call_response[data_key]
KeyError: 'Time Series (Daily)'

我不完全确定那是什么意思,我在谷歌搜索这个问题时遇到了一些问题。我认为这是我所缺少的相当简单的东西。此外,输出格式设置为 pandas,如果这很重要的话。这是(希望如此)所有相关代码:

stockList = ["AAPL", "AMZN", "GOOG", "GOOGL", "MSFT", "JPM", "JNJ", "BA"]

for stock in stockList:
data = ts.get_daily(symbol=stock, outputsize='full')
data[0].to_csv(stock + '.csv')

它似乎随机工作;它会收集一些 .csv 文件,然后看似随机地停止......任何人都可以帮助我吗?我将不胜感激!

最佳答案

根据我的经验,当超过免费套餐限制时会发生这种情况。您每分钟只能调用 API 5 次。该错误非常具有误导性,但它与免费套餐有关。

要解决此问题,您只需在 5 次调用后添加超时,或获取高级 API。

来自网站支持页面的信息:

Are there usage/frequency limits for the API service?

We are proud to provide free API service for our global community of users and recommend that you make API requests sparingly (up to 5 API requests per minute and 500 requests per day) to achieve the best server-side performance. If you would like to target a larger API call volume, please visit premium membership.

Note: If you are a student or educator, chances are that your school already has a data partnership with Alpha Vantage. If not, please ask your school/library administrator to contact partnerships@alphavantage.co for a special partnership plan for educational institutions.

关于python - Alpha Vantage "KeyError: ' 时间序列(每日 )'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56500547/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com