yahooquery Skill
Comprehensive access to Yahoo Finance data via the yahooquery Python library. This library provides programmatic access to nearly all Yahoo Finance endpoints, including real-time pricing, fundamentals, analyst estimates, options, news, and premium research.
Core Classes
1. Ticker (Company-Specific Data)
The primary interface for retrieving data about one or more securities.
CODEBLOCK0
2. Screener (Predefined Stock Lists)
Access to pre-built screeners for discovering stocks by criteria.
CODEBLOCK1
3. Research (Premium Subscription Required)
Access proprietary research reports and trade ideas.
CODEBLOCK2
Ticker Class: Data Modules
The Ticker class exposes dozens of data endpoints via properties and methods.
📊 Financial Statements
- -
.income_statement(frequency='a', trailing=True) - Income statement (annual/quarterly) - INLINECODE3 - Balance sheet
- INLINECODE4 - Cash flow statement
- INLINECODE5 - Combined financials + valuation measures
- INLINECODE6 - EV/EBITDA, P/E, P/B, P/S across periods
📈 Pricing & Market Data
- -
.price - Current pricing, market cap, 52-week range - INLINECODE8 - Historical OHLC
-
period:
1d,
5d,
1mo,
3mo,
6mo,
1y,
2y,
5y,
10y,
ytd,
max
-
interval:
1m,
2m,
5m,
15m,
30m,
60m,
90m,
1h,
1d,
5d,
1wk,
1mo,
3mo
- -
.option_chain - Full options chain (all expirations)
🔍 Analysis & Estimates
- -
.calendar_events - Next earnings date, EPS/revenue estimates - INLINECODE35 - Actual vs. estimated EPS (last 4 quarters)
- INLINECODE36 - Historical quarterly/annual earnings and revenue
- INLINECODE37 - Analyst estimates for upcoming periods
- INLINECODE38 - Buy/Sell/Hold rating changes over time
- INLINECODE39 - Recent analyst upgrades/downgrades
🏢 Company Fundamentals
- -
.asset_profile - Address, industry, sector, business summary, officers - INLINECODE41 - Executives with compensation details
- INLINECODE42 - Condensed company information
- INLINECODE43 - Forward P/E, profit margin, beta, shares outstanding
- INLINECODE44 - Financial KPIs (ROE, ROA, debt-to-equity, margins)
👥 Ownership & Governance
- -
.insider_holders - List of insider holders and positions - INLINECODE46 - Recent buy/sell transactions by insiders
- INLINECODE47 - Top institutional holders
- INLINECODE48 - Top mutual fund holders
- INLINECODE49 - Ownership summary (institutional %, insider %, float)
🌍 ESG & Ratings
- -
.esg_scores - Environmental, Social, Governance scores and controversies - INLINECODE51 - Analyst consensus (Strong Buy → Strong Sell)
📰 News & Insights
- -
.news() - Recent news articles - INLINECODE53 - Bullish/bearish technical patterns
💰 Funds & ETFs Only
- -
.fund_holding_info - Top holdings, bond/equity breakdown - INLINECODE55 - Historical performance and returns
- INLINECODE56 /
.fund_bond_ratings - Bond maturity and credit ratings - INLINECODE58 - P/E, P/B, P/S for equity holdings
📊 Other Modules
- -
.summary_detail - Trading stats (day high/low, volume, avg volume) - INLINECODE60 - Enterprise value, trailing P/E, forward P/E
- INLINECODE61 - Performance relative to a benchmark index
- INLINECODE62 - Security type, exchange, market
Global Functions
CODEBLOCK3
Configuration & Keyword Arguments
The Ticker, Screener, and Research classes accept these optional parameters:
Performance & Reliability
- -
asynchronous=True - Make requests asynchronously (for multiple symbols) - INLINECODE67 - Number of concurrent workers (when async)
- INLINECODE68 - Number of retry attempts
- INLINECODE69 - Exponential backoff between retries
- INLINECODE70 - HTTP codes to retry
- INLINECODE71 - Request timeout in seconds
Data Format & Validation
- -
formatted=False - If True, returns data with {raw, fmt, longFmt} structure - INLINECODE75 - Validate symbols on instantiation (invalid →
.invalid_symbols) - INLINECODE77 - Regional data/news (france, germany, canada, etc.)
Network & Auth
- -
proxies={'http': 'http://proxy:port'} - HTTP/HTTPS proxy - INLINECODE79 - Custom user agent string
- INLINECODE80 - SSL certificate verification
- INLINECODE81 /
password='...' - Yahoo Finance Premium login
Advanced (Shared Sessions)
- -
session=... / crumb=... - Share auth between Research and Ticker instances
Best Practices
1. Async for Multiple Symbols
CODEBLOCK4
2. Handling DataFrames
Most financial methods return
pandas.DataFrame. Convert for JSON output:
CODEBLOCK5
3. Historical Data - 1-Minute Intervals
Yahoo limits 1-minute data to 7 days per request. For 30 days:
CODEBLOCK6
4. Premium Users: Combining Research + Ticker
r = Research(username='...', password='...')
reports = r.reports(sector='Technology', investment_rating='Bullish')
# Reuse session for Ticker
tickers = Ticker('AAPL', session=r.session, crumb=r.crumb)
data = tickers.asset_profile
Common Use Cases
Portfolio Analysis
CODEBLOCK8
Screening & Discovery
CODEBLOCK9
Options Analysis
CODEBLOCK10
Earnings Calendar
tickers = Ticker('AAPL MSFT NVDA')
calendar = tickers.calendar_events
# Shows next earnings date + analyst estimates
Reference Documentation
Full API docs at: INLINECODE88
- -
index.md - Overview of classes and functions - INLINECODE90 - Detailed breakdown of all Ticker methods
- INLINECODE91 - Screener class guide
- INLINECODE92 - Research class (Premium)
- INLINECODE93 - Complete list of configuration options
- INLINECODE94 - Global utility functions
- INLINECODE95 - Sharing sessions between Research and Ticker
Environment
- - Installation: INLINECODE96
- Dependencies: pandas, requests-futures, tqdm, beautifulsoup4, lxml
- Python Version: 3.7+
Notes
- - Yahoo Finance may rate-limit or block requests. Use
retry, backoff_factor, and status_forcelist for robustness. - Premium features (Research class) require a paid Yahoo Finance Premium subscription.
- Data accuracy and availability depend on Yahoo Finance's upstream data providers.
yahooquery 技能
通过 yahooquery Python 库全面访问雅虎财经数据。该库提供对几乎所有雅虎财经接口的程序化访问,包括实时定价、基本面数据、分析师预估、期权、新闻和高级研究。
核心类
1. Ticker(公司特定数据)
用于获取一只或多只证券数据的主要接口。
python
from yahooquery import Ticker
单个或多个代码
aapl = Ticker(AAPL)
tickers = Ticker(AAPL MSFT NVDA, asynchronous=True)
2. Screener(预定义股票列表)
访问预构建的筛选器,按条件发现股票。
python
from yahooquery import Screener
s = Screener()
screeners = s.available_screeners # 列出所有可用筛选器
data = s.getscreeners([daygainers, most_actives], count=10)
3. Research(需要高级订阅)
访问专有研究报告和交易思路。
python
from yahooquery import Research
r = Research(username=you@email.com, password=password)
reports = r.reports(reporttype=Analyst Report, reportdate=Last Week)
trades = r.trades(trend=Bullish, term=Short term)
Ticker 类:数据模块
Ticker 类通过属性和方法公开数十个数据接口。
📊 财务报表
- - .incomestatement(frequency=a, trailing=True) - 利润表(年度/季度)
- .balancesheet(frequency=a, trailing=True) - 资产负债表
- .cashflow(frequency=a, trailing=True) - 现金流量表
- .allfinancialdata(frequency=a) - 合并财务数据 + 估值指标
- .valuationmeasures - 各期间的 EV/EBITDA、市盈率、市净率、市销率
📈 定价与市场数据
- - .price - 当前价格、市值、52周范围
- .history(period=1y, interval=1d, start=None, end=None) - 历史 OHLC 数据
-
period: 1d、5d、1mo、3mo、6mo、1y、2y、5y、10y、ytd、max
-
interval: 1m、2m、5m、15m、30m、60m、90m、1h、1d、5d、1wk、1mo、3mo
- - .option_chain - 完整期权链(所有到期日)
🔍 分析与预估
- - .calendarevents - 下次财报日期、每股收益/营收预估
- .earninghistory - 实际与预估每股收益对比(最近4个季度)
- .earnings - 历史季度/年度收益和营收
- .earningstrend - 分析师对未来期间的预估
- .recommendationtrend - 买入/卖出/持有评级的随时间变化
- .gradings - 近期分析师上调/下调评级
🏢 公司基本面
- - .assetprofile - 地址、行业、板块、业务摘要、高管
- .companyofficers - 高管及其薪酬详情
- .summaryprofile - 精简公司信息
- .keystats - 远期市盈率、利润率、贝塔值、流通股数
- .financial_data - 财务关键绩效指标(ROE、ROA、负债权益比、利润率)
👥 所有权与治理
- - .insiderholders - 内部持股人列表及持仓
- .insidertransactions - 内部人近期买卖交易
- .institutionownership - 主要机构持有人
- .fundownership - 主要共同基金持有人
- .major_holders - 所有权摘要(机构%、内部人%、流通股%)
🌍 ESG 与评级
- - .esgscores - 环境、社会、治理评分及争议
- .recommendationrating - 分析师共识(强烈买入 → 强烈卖出)
📰 新闻与洞察
- - .news() - 近期新闻文章
- .technical_insights - 看涨/看跌技术形态
💰 仅限基金与 ETF
- - .fundholdinginfo - 前十大持仓、债券/股票分布
- .fundperformance - 历史表现和回报
- .fundbondholdings / .fundbondratings - 债券到期日和信用评级
- .fundequity_holdings - 股票持仓的市盈率、市净率、市销率
📊 其他模块
- - .summarydetail - 交易统计(当日高/低、成交量、平均成交量)
- .defaultkeystatistics - 企业价值、追踪市盈率、远期市盈率
- .indextrend - 相对于基准指数的表现
- .quote_type - 证券类型、交易所、市场
全局函数
python
import yahooquery as yq
搜索
results = yq.search(NVIDIA)
市场数据
market = yq.get
marketsummary(country=US) # 主要指数快照
trending = yq.get_trending(country=US) # 热门股票代码
工具函数
currencies = yq.get_currencies() # 支持的货币列表
exchanges = yq.get_exchanges() # 交易所列表
rate = yq.currency_converter(USD, EUR) # 汇率
配置与关键字参数
Ticker、Screener 和 Research 类接受以下可选参数:
性能与可靠性
- - asynchronous=True - 异步发起请求(用于多个代码)
- maxworkers=8 - 并发工作线程数(异步时)
- retry=5 - 重试次数
- backofffactor=0.3 - 重试之间的指数退避
- status_forcelist=[429, 500, 502, 503, 504] - 需要重试的 HTTP 状态码
- timeout=5 - 请求超时时间(秒)
数据格式与验证
- - formatted=False - 如果为 True,返回包含 {raw, fmt, longFmt} 结构的数据
- validate=True - 实例化时验证代码(无效代码 → .invalid_symbols)
- country=United States - 区域数据/新闻(法国、德国、加拿大等)
网络与认证
- - proxies={http: http://proxy:port} - HTTP/HTTPS 代理
- user_agent=... - 自定义用户代理字符串
- verify=True - SSL 证书验证
- username=you@email.com / password=... - 雅虎财经高级登录
高级(共享会话)
- - session=... / crumb=... - 在 Research 和 Ticker 实例之间共享认证
最佳实践
1. 多个代码使用异步
python
tickers = Ticker(AAPL MSFT NVDA TSLA, asynchronous=True)
prices = tickers.price # 返回以代码为键的字典
2. 处理 DataFrame
大多数财务方法返回 pandas.DataFrame。转换为 JSON 输出:
python
df = aapl.income_statement()
print(df.to
json(orient=records, dateformat=iso))
3. 历史数据 - 1分钟间隔
雅虎限制每次请求最多获取7天的1分钟数据。获取30天数据:
python
tickers = Ticker(AAPL, asynchronous=True)
df = tickers.history(period=1mo, interval=1m) # 自动发起4次请求
4. 高级用户:结合 Research + Ticker
python
r = Research(username=..., password=...)
reports = r.reports(sector=Technology, investment_rating=Bullish)
为 Ticker 重用会话
tickers = Ticker(AAPL, session=r.session, crumb=r.crumb)
data = tickers.asset_profile
常见用例
投资组合分析
python
portfolio = Ticker(AAPL MSFT NVDA, asynchronous=True)
summary = portfolio.summary_detail
earnings = portfolio.earnings
history = portfolio.history(period=1y)
筛选与发现
python
s = Screener()
gainers = s.get
screeners([daygainers], count=20)