ContextInfo.get_financial_data - 获取财务数据
ContextInfo.get_financial_data 是 QMT 内置 Python 中用于获取财务数据的接口。
提示
lookahead-risk
原型
ContextInfo.get_financial_data(fieldList, stockList, startDate, enDate, report_type = 'announce_time')
释义
ContextInfo.get_financial_data 是 QMT 内置 Python 中用于获取财务数据的接口。
研究:官方目录未明确;回测:官方目录未明确;模拟:官方目录未明确;实盘:官方目录未明确。
参数
| 参数 | 是否必填 | 官方原始定义 |
|---|---|---|
fieldList |
是 | fieldList |
stockList |
是 | stockList |
startDate |
是 | startDate |
enDate |
是 | enDate |
report_type |
否 | report_type='announce_time' |
返回值
函数根据stockList代码列表,startDate,endDate时间范围,返回不同的的数据类型。如下:
代码数量 | 时间范围 | 返回类型 =1 | =1 | pandas.Series (index = 字段) =1 | >1 | pandas.DataFrame (index = 时间, columns = 字段) >1 | =1 | pandas.DataFrame (index = 代码, columns = 字段) >1 | >1 | pandas.Panel (items = 代码, major_axis = 时间, minor_axis = 字段)
示例
示例返回值
# coding:gbk
def init(C):
pass
def handlebar(C):
#取总股本和净利润
fieldList = ['CAPITALSTRUCTURE.total_capital', '利润表.净利润']
stockList = ["000001.SZ","000002.SZ","430017.BJ"]
startDate = '20171209'
endDate = '20231204'
data = C.get_financial_data(fieldList, stockList, startDate, endDate, report_type = 'report_time')
print(data)
用法2
原型
内置python
ContextInfo.get_financial_data(tabname, colname, market, code, report_type = 'report_time', barpos)
与用法 1 可同时使用
释义
获取财务数据,方法2
详细说明
财务数据接口有两种用法,入参和返回值不同,具体如下
用法1
功能说明
获取财务数据,方法1
参数详细说明
| 字段名 | 类型 | 释义与用例 |
|---|---|---|
| fieldList | List(必须) | 财报字段列表:['ASHAREBALANCESHEET.fix_assets', '利润表.净利润'] |
| stockList | List(必须) | 股票列表:['600000.SH', '000001.SZ'] |
| startDate | Str(必须) | 开始时间:'20171209' |
| endDate | Str(必须) | 结束时间:'20171212' |
| report_type | Str(可选) | 报表时间类型,可缺省,默认是按照数据的公告期为区分取数据,设置为 'report_time' 为按照报告期取数据,' announce_time' 为按照公告日期取数据 |
使用提示
选择按照公告期取数和按照报告期取数的区别:
报告日期是指财务报告所覆盖的会计时间段,而公告日期是指公司向外界公布该报告的具体时间点
若指定report_type为report_time,则不会考虑财报的公告日期,可能会取到未来数据
若指定report_type为announce_time,则会按财报实际发布日期返回数据,不会取到未来数据
例:
返回值
函数根据stockList代码列表,startDate,endDate时间范围,返回不同的的数据类型。如下:
| 代码数量 | 时间范围 | 返回类型 |
|---|---|---|
| =1 | =1 | pandas.Series (index = 字段) |
| =1 | >1 | pandas.DataFrame (index = 时间, columns = 字段) |
| >1 | =1 | pandas.DataFrame (index = 代码, columns = 字段) |
| >1 | >1 | pandas.Panel (items = 代码, major_axis = 时间, minor_axis = 字段) |