get_fundamentals – 获取财务数据
get_fundamentals
get_fundamentals(
security,
table,
fields=None,
date=None,
start_year=None,
end_year=None,
report_types=None,
merge_type=None,
is_dataframe=False
)
使用场景
该函数可在 研究、回测、交易模块 使用。
接口说明
获取 财务三大报表数据、日频估值数据、各项财务能力指标数据。
注意事项
网络限制:HTTP 在线获取,可能因网络拥堵导致应答失败,返回空数据时请重试,策略中需增加保护机制。流量限制:
每秒调用 ≤ 100 次;单次最大 500 条;每条定义:1 只股票 × 1 张表 × 1 个字段,最大 5 万条。
非 PIT 数据:
、
growth_ability、
profit_ability、
eps、
operating_ability 五张表 非 PIT 数据;按日期请求时,若该期财报未发布,返回
debt_paying_ability。
None
科创板存托凭证(如九号公司 )无财务报表披露信息。
689009.SS
参数
| 参数 | 类型 | 说明 |
|---|---|---|
|
/ |
股票代码 |
|
|
表名,见下表 |
|
|
指定返回字段 |
|
/ |
查询日期,与 / 互斥 |
/ |
|
查询年份区间,与 互斥 |
|
|
财报类型: 一季报, 半年报, 三季报, 年报 |
|
|
数据版本: 首次发布; 最新发布 |
|
|
返回 , 返回 (仅 Python 3.5 按年份查询) |
表名与内容
| 表名 | 内容 |
|---|---|
|
估值数据 |
|
资产负债表 |
|
利润表 |
|
现金流量表 |
|
成长能力指标 |
|
盈利能力指标 |
|
每股指标 |
|
营运能力指标 |
|
偿债能力指标 |
返回值
| 场景 | Python 版本 | 返回类型 | 索引 |
|---|---|---|---|
| 按日期查询 | 3.11 / 3.5 | |
股票代码 |
| 按年份查询 | 3.11 | |
股票代码 + 会计日期 |
| 按年份查询 | 3.5 | |
股票代码 → 会计日期 |
各表使用示例
1.
valuation – 估值数据
valuation
stocks = ['600570.SS', '000001.SZ']
data = get_fundamentals(
stocks, 'valuation',
date='2018-04-24',
fields=['total_value', 'pe_dynamic', 'turnover_rate', 'pb']
)
2.
balance_statement – 资产负债表
balance_statement
data = get_fundamentals('600570.SS', 'balance_statement',
fields='total_assets', date='20160628')
3.
income_statement – 利润表
income_statement
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'income_statement',
fields=['operating_revenue', 'net_profit'],
date='20160628')
4.
cashflow_statement – 现金流量表
cashflow_statement
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'cashflow_statement',
fields=['net_cash_flows_operating'],
date='20160628')
5.
growth_ability – 成长能力指标
growth_ability
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'growth_ability',
start_year='2013', end_year='2015')
6.
profit_ability – 盈利能力指标
profit_ability
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'profit_ability',
fields=['roe', 'roa'], date='20160628')
7.
eps – 每股指标
eps
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'eps',
fields=['basic_eps', 'diluted_eps'],
date='20160628')
8.
operating_ability – 营运能力指标
operating_ability
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'operating_ability',
fields=['inventory_turnover_days'],
date='20160628')
9.
debt_paying_ability – 偿债能力指标
debt_paying_ability
stocks = ['600000.SS', '600570.SS']
data = get_fundamentals(stocks, 'debt_paying_ability',
fields=['current_ratio'],
date='20160628')
完整示例
import time
def initialize(context):
g.security = '600570.SS'
set_universe(g.security)
def before_trading_start(context, data):
# 按年份查询,需 sleep 防止流控
funda_data = get_fundamentals(
g.security, 'balance_statement',
fields='total_assets',
start_year='2011', end_year='2020', report_types='1')
time.sleep(1)
funda_data = get_fundamentals(
g.security, 'balance_statement',
fields='total_assets',
start_year='2010', end_year='2020', report_types='2')
各表字段明细
以下仅展示字段名与说明,完整类型见原文。
valuation – 估值数据
valuation
固定返回:,
trading_day,
total_value自选返回:
secu_code,
float_value,
naps,
pb,
pe_dynamic, …
turnover_rate
balance_statement – 资产负债表
balance_statement
固定返回:,
secu_code,
secu_abbr,
company_type,
end_date自选返回:
publ_date,
cash_equivalents,
total_assets,
shortterm_loan, …
total_current_assets
income_statement – 利润表
income_statement
固定返回:,
secu_code,
secu_abbr,
company_type,
end_date自选返回:
publ_date,
basic_eps,
net_profit,
operating_revenue, …
total_operating_revenue
cashflow_statement – 现金流量表
cashflow_statement
固定返回:,
secu_code,
secu_abbr,
company_type,
end_date自选返回:
publ_date,
net_operate_cash_flow,
invest_cash_paid, …
net_finance_cash_flow
growth_ability – 成长能力
growth_ability
固定返回:,
secu_code,
secu_abbr,
publ_date自选返回:
end_date,
operating_revenue_grow_rate,
net_profit_grow_rate, …
basic_eps_yoy
profit_ability – 盈利能力
profit_ability
固定返回:,
secu_code,
secu_abbr,
publ_date自选返回:
end_date,
roe,
roa,
net_profit_ratio, …
gross_income_ratio
eps – 每股指标
eps
固定返回:,
secu_code,
secu_abbr,
publ_date自选返回:
end_date,
basic_eps,
diluted_eps,
naps, …
net_operate_cash_flow_ps
operating_ability – 营运能力
operating_ability
固定返回:,
secu_code,
secu_abbr,
publ_date自选返回:
end_date,
inventory_turnover_rate, …
current_assets_turnover_rate
debt_paying_ability – 偿债能力
debt_paying_ability
固定返回:,
secu_code,
secu_abbr,
publ_date自选返回:
end_date,
current_ratio,
quick_ratio, …
debt_equity_ratio


















暂无评论内容