如何获取公司盈利公告数据API?

huangapple go评论79阅读模式
英文:

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.")

huangapple
  • 本文由 发表于 2023年6月22日 09:16:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76528084.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定