因子库¶
接口¶
因子库访问API
-
D.
features
(instruments, start_date='2005-01-01', end_date=None, fields=['close_0', 'close_1'], groupped_by_instrument=False, frequency='daily')¶ 统一的API,读取因子库数据
参数:
数据字段¶
字段名 | 描述 | 适用市场 |
---|---|---|
date | 交易日期 | A股,基金,期货,港股,美股 |
instrument | 证券代码 | A股,基金,期货,港股,美股 |
基本信息¶
字段名 | 描述 | 适用市场 |
---|---|---|
list_days_0 | 已经上市的天数,按自然日计算 | A股,港股,美股 |
list_board_0 | 上市板,主板:1,中小企业板:2,创业板:3 | A股 |
company_found_date_0 | 公司成立天数 | A股 |
st_status_0 | ST状态:0:正常股票,1:ST,2:*ST,11:暂停上市 | A股 |
industry_sw_level1_0 | 申万一级行业类别 | A股 |
industry_sw_level2_0 | 申万二级行业类别 | A股 |
industry_sw_level3_0 | 申万三级行业类别 | A股 |
in_sse50_0 | 是否属于上证50指数成份 | A股 |
in_csi300_0 | 是否属于沪深300指数成份 | A股 |
in_csi500_0 | 是否属于中证500指数成份 | A股 |
in_csi800_0 | 是否属于中证800指数成份 | A股 |
in_sse180_0 | 是否属于上证180指数成份 | A股 |
in_csi100_0 | 是否属于中证100指数成份 | A股 |
in_szse100_0 | 是否属于深证100指数成份 | A股 |
量价因子¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
open_$i | [0 .. 20] | 第前i个交易日的开盘价,当天为0 | A股,基金,期货,港股,美股 |
high_$i | [0 .. 20] | 第前i个交易日的最高价 | A股,基金,期货,港股,美股 |
low_$i | [0 .. 20] | 第前i个交易日的最低价 | A股,基金,期货,港股,美股 |
volume_$i | [0 .. 20] | 第前i个交易日的交易量 | A股,基金,期货,港股,美股 |
adjust_factor_$i | [0 .. 20] | 第前i个交易日的复权因子 | A股,基金,港股,美股 |
deal_number_$i | [0 .. 20] | 第前i个交易日的成交笔数 | A股 |
price_limit_status_$i | [0 .. 20] | 第前i个交易日的股价在收盘时的涨跌停状态,1表示跌停,2表示未涨跌停,3则表示涨停 | A股,基金 |
close_$i | [0 .. 120] | 第前i个交易日的收盘价 | A股,基金,期货,港股,美股 |
daily_return_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 第前i个交易日的收益,=close_i/close_(i+1) | A股,基金,期货,港股,美股 |
return_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的收益,=close_0/close_(i+1) | A股,基金,期货,港股,美股 |
rank_return_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的收益 (return_i) 排名,=从小到大排名序号/总数 | A股,基金,期货,港股,美股 |
amount_$i | [0 .. 120] | 第前i个交易日的交易额 | A股,基金,期货,港股,美股 |
rank_amount_$i | [0 .. 120] | 第前i个交易日的交易额百分比排名 | A股,基金,期货,港股,美股 |
avg_amount_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的平均交易额,0表示今日 | A股,基金,期货,港股,美股 |
rank_avg_amount_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的平均交易额,百分比排名 | A股,基金,期货,港股,美股 |
换手率因子¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
turn_$i | [0 .. 20] | 第前i个交易日的换手率 | A股,基金,港股,美股 |
rank_turn_$i | [0 .. 20] | 过去i个交易日的换手率 (turn_i) 排名,=从小到大排名序号/总数 | A股,基金,港股,美股 |
avg_turn_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的平均换手率,0表示今日 | A股,基金,港股,美股 |
rank_avg_turn_$i | [0 .. 20]; 30, 40, 50, 60, 70, 80, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360 | 过去i个交易日的平均换手率排名,=从小到大排名序号/总数 | A股,基金,港股,美股 |
估值因子¶
字段名 | 描述 | 适用市场 |
---|---|---|
market_cap_0 | 总市值 | A股,港股,美股 |
rank_market_cap_0 | 总市值,升序百分比排名 | A股,港股,美股 |
market_cap_float_0 | 流通市值 | A股,港股,美股 |
rank_market_cap_float_0 | 流通市值,升序百分比排名 | A股,港股,美股 |
pe_ttm_0 | 市盈率 (TTM) | A股,港股,美股 |
rank_pe_ttm_0 | 市盈率 (TTM),升序百分比排名 | A股,港股,美股 |
pe_lyr_0 | 市盈率 (LYR) | A股,港股,美股 |
rank_pe_lyr_0 | 市盈率 (LYR),升序百分比排名 | A股,港股,美股 |
pb_lf_0 | 市净率 (LF) | A股 |
rank_pb_lf_0 | 市净率 (LF),升序百分比排名 | A股 |
pb_mrq_0 | 市净率 (MRQ) | 港股,美股 |
rank_pb_mrq_0 | 市净率 (MRQ),升序百分比排名 | 港股,美股 |
ps_ttm_0 | 市销率 (TTM) | A股,港股,美股 |
rank_ps_ttm_0 | 市销率 (TTM),升序百分比排名 | A股,港股,美股 |
west_netprofit_ftm_0 | 一致预测净利润(未来12个月) | A股 |
west_eps_ftm_0 | 一致预测每股收益(未来12个月) | A股 |
west_avgcps_ftm_0 | 一致预测每股现金流(未来12个月) | A股 |
资金流¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
mf_net_amount_$i | [0 .. 20] | 第前i个交易日净主动买入额,= 买入金额 - 卖出金额 (包括超大单、大单、中单或小单) | A股 |
avg_mf_net_amount_$i | [0 .. 20] | 过去i个交易日平均净主动买入额 | A股 |
rank_avg_mf_net_amount_$i | [0 .. 20] | 过去i个交易日平均净主动买入额排名 | A股 |
mf_net_amount_main_0 | 主力净流入净额 | A股 | |
mf_net_pct_main_0 | 主力净流入占比 | A股 | |
mf_net_amount_xl_0 | 超大单净流入净额 | A股 | |
mf_net_pct_xl_0 | 超大单净流入占比 | A股 | |
mf_net_amount_l_0 | 大单净流入净额 | A股 | |
mf_net_pct_l_0 | 大单净流入占比 | A股 | |
mf_net_amount_m_0 | 中单净流入净额 | A股 | |
mf_net_pct_m_0 | 中单净流入占比 | A股 | |
mf_net_amount_s_0 | 小单净流入净额 | A股 | |
mf_net_pct_s_0 | 小单净流入占比 | A股 |
财务因子¶
字段名 | 描述 | 适用市场 |
---|---|---|
fs_publish_date_0 | 最近财报发布距今天数,按自然日计算,当天为0 | A股 |
fs_quarter_year_0 | 财报对应的年份 | A股 |
fs_quarter_index_0 | 财报对应的季度,取值 1/2/3/4,1表示第一季度,以此类推 | A股 |
fs_net_profit_0 | 归属母公司股东的净利润 | A股 |
fs_net_profit_ttm_0 | 归属母公司股东的净利润 (TTM) | A股 |
fs_net_profit_yoy_0 | 归属母公司股东的净利润同比增长率 | A股 |
rank_fs_net_profit_yoy_0 | 归属母公司股东的净利润同比增长率,升序百分比排名 | A股 |
fs_net_profit_qoq_0 | 归属母公司股东的净利润单季度环比增长率 | A股 |
rank_fs_net_profit_qoq_0 | 归属母公司股东的净利润单季度环比增长率,升序百分比排名 | A股 |
fs_deducted_profit_0 | 扣除非经常性损益后的净利润 | A股 |
fs_deducted_profit_ttm_0 | 扣除非经常性损益后的净利润 (TTM) | A股 |
fs_roe_0 | 净资产收益率 | A股 |
rank_fs_roe_0 | 净资产收益率,升序百分比排名 | A股 |
fs_roe_ttm_0 | 净资产收益率 (TTM) | A股 |
rank_fs_roe_ttm_0 | 净资产收益率 (TTM),升序百分比排名 | A股 |
fs_roa_0 | 总资产报酬率 | A股 |
rank_fs_roa_0 | 总资产报酬率,升序百分比排名 | A股 |
fs_roa_ttm_0 | 总资产报酬率 (TTM) | A股 |
rank_fs_roa_ttm_0 | 总资产报酬率 (TTM),升序百分比排名 | A股 |
fs_gross_profit_margin_0 | 销售毛利率 | A股 |
fs_gross_profit_margin_ttm_0 | 销售毛利率 (TTM) | A股 |
fs_net_profit_margin_0 | 销售净利率 | A股 |
fs_net_profit_margin_ttm_0 | 销售净利率 (TTM) | A股 |
fs_operating_revenue_0 | 营业收入 | A股 |
fs_operating_revenue_ttm_0 | 营业收入 (TTM) | A股 |
fs_operating_revenue_yoy_0 | 营业收入同比增长率 | A股 |
rank_fs_operating_revenue_yoy_0 | 营业收入同比增长率,升序百分比排名 | A股 |
fs_operating_revenue_qoq_0 | 营业收入单季度环比增长率 | A股 |
rank_fs_operating_revenue_qoq_0 | 营业收入单季度环比增长率,升序百分比排名 | A股 |
fs_free_cash_flow_0 | 企业自由现金流 | A股 |
fs_net_cash_flow_0 | 经营活动产生的现金流量净额 | A股 |
fs_net_cash_flow_ttm_0 | 经营活动现金净流量 (TTM) | A股 |
fs_eps_0 | 每股收益 | A股 |
rank_fs_eps_0 | 每股收益,升序百分比排名 | A股 |
fs_eps_yoy_0 | 每股收益同比增长率 | A股 |
rank_fs_eps_yoy_0 | 每股收益同比增长率,升序百分比排名 | A股 |
fs_bps_0 | 每股净资产 | A股 |
rank_fs_bps_0 | 每股净资产,升序百分比排名 | A股 |
fs_current_assets_0 | 流动资产 | A股 |
fs_non_current_assets_0 | 非流动资产 | A股 |
fs_current_liabilities_0 | 流动负债 | A股 |
fs_non_current_liabilities_0 | 非流动负债 | A股 |
fs_cash_ratio_0 | 现金比率 | A股 |
rank_fs_cash_ratio_0 | 现金比率,升序百分比排名 | A股 |
fs_common_equity_0 | 普通股权益总额 | A股 |
fs_cash_equivalents_0 | 货币资金 | A股 |
fs_account_receivable_0 | 应收账款 | A股 |
fs_fixed_assets_0 | 固定资产 | A股 |
fs_proj_matl_0 | 工程物资 | A股 |
fs_construction_in_process_0 | 在建工程 | A股 |
fs_fixed_assets_disp_0 | 固定资产清理 | A股 |
fs_account_payable_0 | 应付账款 | A股 |
fs_total_liability_0 | 负债合计 | A股 |
fs_paicl_up_capital_0 | 实收资本(或股本) | A股 |
fs_capital_reserves_0 | 资本公积金 | A股 |
fs_surplus_reserves_0 | 盈余公积金 | A股 |
fs_undistributed_profit_0 | 未分配利润 | A股 |
fs_eqy_belongto_parcomsh_0 | 归属母公司股东的权益 | A股 |
fs_total_equity_0 | 所有者权益合计 | A股 |
fs_gross_revenues_0 | 营业总收入 | A股 |
fs_total_operating_costs_0 | 营业总成本 | A股 |
fs_selling_expenses_0 | 销售费用 | A股 |
fs_financial_expenses_0 | 财务费用 | A股 |
fs_general_expenses_0 | 管理费用 | A股 |
fs_operating_profit_0 | 营业利润 | A股 |
fs_total_profit_0 | 利润总额 | A股 |
fs_income_tax_0 | 所得税 | A股 |
fs_net_income_0 | 净利润 | A股 |
股东因子¶
字段名 | 描述 | 适用市场 |
---|---|---|
sh_holder_avg_pct_0 | 户均持股比例 | A股 |
rank_sh_holder_avg_pct_0 | 户均持股比例,升序百分比排名 | A股 |
sh_holder_avg_pct_3m_chng_0 | 户均持股比例季度增长率 | A股 |
rank_sh_holder_avg_pct_3m_chng_0 | 户均持股比例季度增长率,升序百分比排名 | A股 |
sh_holder_avg_pct_6m_chng_0 | 户均持股比例半年增长率 | A股 |
rank_sh_holder_avg_pct_6m_chng_0 | 户均持股比例半年增长率,升序百分比排名 | A股 |
sh_holder_num_0 | 股东户数 | A股 |
rank_sh_holder_num_0 | 股东户数,升序百分比排名 | A股 |
技术分析因子¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
ta_sma_$i_0 | 5, 10, 20, 30, 60 | 收盘价的i日简单移动平均值 | A股,基金,期货,港股,美股 |
ta_ema_$i_0 | 5, 10, 20, 30, 60 | 收盘价的i日指数移动平均值 | A股,基金,期货,港股,美股 |
ta_wma_$i_0 | 5, 10, 20, 30, 60 | 收盘价的i日加权移动平均值 | A股,基金,期货,港股,美股 |
ta_ad_0 | 收集派发指标 | A股,基金,期货,港股,美股 | |
ta_aroon_down_$i_0 | 14, 28 | 阿隆指标aroondown,timeperiod=i | A股,基金,期货,港股,美股 |
ta_aroon_up_$i_0 | 14, 28 | 阿隆指标aroonup,timeperiod=i | A股,基金,期货,港股,美股 |
ta_aroonosc_$i_0 | 14, 28 | AROONOSC指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_atr_$i_0 | 14, 28 | ATR指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_bbands_upperband_$i_0 | 14, 28 | BBANDS指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_bbands_middleband_$i_0 | 14, 28 | BBANDS指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_bbands_lowerband_$i_0 | 14, 28 | BBANDS指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_adx_$i_0 | 14, 28 | ADX指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_cci_$i_0 | 14, 28 | CCI指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_macd_macd_12_26_9_0 | MACD | A股,基金,期货,港股,美股 | |
ta_macd_macdsignal_12_26_9_0 | MACD | A股,基金,期货,港股,美股 | |
ta_macd_macdhist_12_26_9_0 | MACD | A股,基金,期货,港股,美股 | |
ta_obv_0 | OBV指标 | A股,基金,期货,港股,美股 | |
ta_stoch_slowk_5_3_0_3_0_0 | STOCH (KDJ) 指标K值 | A股,基金,期货,港股,美股 | |
ta_stoch_slowd_5_3_0_3_0_0 | STOCH (KDJ) 指标D值 | A股,基金,期货,港股,美股 | |
ta_mfi_$i_0 | 14, 28 | MFI指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_rsi_$i_0 | 14, 28 | RSI指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_trix_$i_0 | 14, 28 | TRIX指标,timeperiod=i | A股,基金,期货,港股,美股 |
ta_sar_0 | SAR指标 | A股,基金,期货,港股,美股 | |
ta_mom_$i_0 | 10, 20, 30, 60 | MOM指标,timperiod=i | A股,基金,期货,港股,美股 |
ta_willr_$i_0 | 14, 28 | WILLR指标,timeperiod=i | A股,基金,期货,港股,美股 |
波动率¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
swing_volatility_$i_0 | 5, 10, 30, 60, 120, 240 | 振幅波动率,timeperiod=i | A股,基金,期货,港股,美股 |
rank_swing_volatility_$i_0 | 5, 10, 30, 60, 120, 240 | 振幅波动率,timeperiod=i,升序百分比排名 | A股,基金,期货,港股,美股 |
volatility_$i_0 | 5, 10, 30, 60, 120, 240 | 波动率,timeperiod=i | A股,基金,期货,港股,美股 |
rank_volatility_$i_0 | 5, 10, 30, 60, 120, 240 | 波动率,timeperiod=i,升序百分比排名 | A股,基金,期货,港股,美股 |
BETA值¶
字段名 | $i 取值 | 描述 | 适用市场 |
---|---|---|---|
beta_sse50_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证50),timeperiod=i | A股 |
rank_beta_sse50_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证50),timeperiod=i,升序百分比排名 | A股 |
beta_csi300_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(沪深300),timeperiod=i | A股 |
rank_beta_csi300_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(沪深300),timeperiod=i,升序百分比排名 | A股 |
beta_csi500_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证500),timeperiod=i | A股 |
rank_beta_csi500_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证500),timeperiod=i,升序百分比排名 | A股 |
beta_csi800_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证800),timeperiod=i | A股 |
rank_beta_csi800_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证800),timeperiod=i,升序百分比排名 | A股 |
beta_sse180_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证180),timeperiod=i | A股 |
rank_beta_sse180_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证180),timeperiod=i,升序百分比排名 | A股 |
beta_csi100_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证100),timeperiod=i | A股 |
rank_beta_csi100_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(中证100),timeperiod=i,升序百分比排名 | A股 |
beta_szzs_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证综指),timeperiod=i | A股 |
rank_beta_szzs_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(上证综指),timeperiod=i,升序百分比排名 | A股 |
beta_gem_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(创业板),timeperiod=i | A股 |
rank_beta_gem_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(创业板),timeperiod=i,升序百分比排名 | A股 |
beta_industry_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(所在行业),timeperiod=i | A股 |
rank_beta_industry_$i_0 | 5, 10, 30, 60, 90, 120, 180 | BETA值(所在行业),timeperiod=i,升序百分比排名 | A股 |
注解
所有数据,默认都是 np.float32
类型,空值或者缺失值默认是 np.NaN
注解
特征一般形式是 featurename_$i,比如 close_0
表示今日收盘价,close_7
表示向前倒退第7个交易日的收盘价。$i 一般用来表示第前几个交易日,具体见上表各特征定义,其中 [a .. b] 表示从a到b之间的整数值都可取。
示例代码¶
获取特征数据:
D.features(instruments=['000001.SZA'], start_date='2017-01-01', end_date='2017-01-07', fields=['close_1'])