You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python YFinance盈利日历API失效,无法获取财报日期求助

获取股票下一个财报日期的Python方案失效问题

我之前用这段Python代码获取股票下一个财报日期:

obj = yf.Ticker('TSLA')
cal = obj.calendar
next_earnings_date = cal.iloc[0][0]

最近发现这个API失效了,于是尝试了以下几种方案:

方案一:使用pandas_datareader和yfinance的earnings属性

import pandas_datareader as web
import pandas as pd
 
df = web.DataReader('AAPL', data_source='yahoo', start='2011-01-01', end='2021-01-12')
df.head()

import yfinance as yf
aapl = yf.Ticker("AAPL")
print(aapl.earnings)

方案二:使用yahoo_fin库

import yahoo_fin.stock_info as si

for ticker_symbol in ['IMGN', 'DIDI']:
    print('Symbol:', ticker_symbol)
    try:
        tickerEarnings = si.get_next_earnings_date(ticker_symbol)
        print('Earnings:', tickerEarnings)
    except Exception as ex:
        print('[Exception]', ex)
        print('Earnings: skiping this symbol')
import yahoo_fin.stock_info as si

    for ticker_symbol in ['IMGN', 'DIDI']:
        print('Symbol:', ticker_symbol)
        try:
            tickerEarnings = si.get_next_earnings_date(ticker_symbol)
            print('Earnings:', tickerEarnings)
        except Exception as ex:
            print('[Exception]', ex)
            print('Earnings: skiping this symbol')

部分尝试出现如下错误,据此判断相关API已失效:

data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"]
TypeError: string indices must be integers

内容的提问来源于stack exchange,提问作者Mike C.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 07:55:18