英文:
How to get company earning announcements data API?
问题
我想获取实时收益公告数据的API。
我尝试过yfinance,但目前不起作用。
那么是否有其他替代的API?
大多数API需要付费,但我只是想为我的个人项目尝试一下,所以压力不大。
雅虎财经不再提供API吗?我听说yfinance不是雅虎财经的API。
我尝试过yfinance、yahooquery和其他API。
我想要实时收益公告数据的API。
英文:
I want to get real-time earning announcements data API.
I tried yfinance but it doesn't work currently.
So is there any other replacement API?
Most of API need to pay money, But I just want to try for my personal projects so it's little pressured
Does Yahoo Finance no longer offer API? I heard that yfinance is not yahoo finance API.
I tried yfinance, yahooquery, other API's
I want real-time earning announcements data api
答案1
得分: 1
Alphavantage: https://www.alphavantage.co/#page-top
Alphavantage拥有出色的金融信息API,最棒的部分是完全免费获取API密钥。
import requests
api_key = ''#你的API密钥
symbol = 'AAPL'# 股票/公司的标志
url = f'https://www.alphavantage.co/query?function=EARNINGS&symbol={symbol}&apikey={api_key}'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
earnings_announcements = data['quarterlyEarnings']
for announcement in earnings_announcements:
report_date = announcement['reportedDate']
eps_estimate = announcement['estimatedEPS']
eps_actual = announcement['reportedEPS']
fiscal_period = announcement['fiscalDateEnding']
print(f"Report Date: {report_date}")
print(f"EPS Estimate: {eps_estimate}")
print(f"EPS Actual: {eps_actual}")
print(f"Fiscal Period: {fiscal_period}")
print()
else:
print("获取盈利公告时发生错误。")
英文:
Alphavantage: https://www.alphavantage.co/#page-top
Alphavantage has an awesome API with finance information and best part is it is completely free to get an API key.
import requests
api_key = ''#your api key
symbol = 'AAPL'# symbol of stock/company
url = f'https://www.alphavantage.co/query?function=EARNINGS&symbol={symbol}&apikey={api_key}'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
earnings_announcements = data['quarterlyEarnings']
for announcement in earnings_announcements:
report_date = announcement['reportedDate']
eps_estimate = announcement['estimatedEPS']
eps_actual = announcement['reportedEPS']
fiscal_period = announcement['fiscalDateEnding']
print(f"Report Date: {report_date}")
print(f"EPS Estimate: {eps_estimate}")
print(f"EPS Actual: {eps_actual}")
print(f"Fiscal Period: {fiscal_period}")
print()
else:
print("Error occurred while fetching earnings announcements.")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论