问答交流

如何构建概念板块因子?

由snowspig创建,最终由snowspig 被浏览 72 用户

问题

参考大Jim的文章可以通过group(x,x)来构建行业因子,但是如果改为group(concept, xxx) 就提示concept不在列表中。要如何构建概念板块的因子

https://bigquant.com/wiki/doc/guang-yingxiong-1Gt5Ohr4XT

\

解答

以group_mean,举例,level2,level3均可以构建,构建表达式为:

group_mean(industry_sw_level2_0,return_0)

concept用衍生模块构建,但是这个字段是在数据表里可以找到的。自定义构建即可:

df_industry = DataSource('industry_CN_STOCK_A').read(start_date="2020-06-01", end_date="2020-06-30") df_raw = DataSource('bar1d_CN_STOCK_A').read(start_date="2020-06-01", end_date="2020-06-30") df = pd.merge(df_raw,df_industry,how='left',on=['date','instrument']) df[['date','concept','close']].groupby(['date','concept']).mean()

或者参考Meetup:https://bigquant.com/wiki/doc/gainian-bankuai-yinzi-4clWQvIv0M

标签

量化投资
评论
  • 您好,industry_CN_STOCK_A里面有concept字段可以用该字段去构建概念因子. ![{w:100}](/wiki/api/attachments.redirect?id=d4559f98-62b9-4ce7-85de-0438c990f060)
  • 是可以构建的,晚点我们给个例子
  • 试过concept 和level2 level3都没有返回值 \
  • 以group_mean,举例,level2,level3均可以构建,构建表达式为: group_mean(industry_sw_level2_0,return_0) concept用衍生模块构建,但是这个字段是在数据表里可以找到的。自定义构建即可: df_industry = DataSource('industry_CN_STOCK_A').read(start_date="2020-06-01", end_date="2020-06-30") df_raw = DataSource('bar1d_CN_STOCK_A').read(start_date="2020-06-01", end_date="2020-06-30") df = pd.merge(df_raw,df_industry,how='left',on=\['date','instrument'\]) df\[\['date','concept','close'\]\].groupby(\['date','concept'\]).mean()
  • 用衍生模块的话不方便超参了。要是能直接抽取最方便了