deledeleboy的知识库

如何构建Halpha、wgt_return_Nm等动量因子

由deledeleboy创建,最终由deledeleboy 被浏览 8 用户

一、问题

{w:100}{w:100}

二、因子说明

本样例以Month=1为例,即22天

1、return_Nm 个股最近N个月的收益率

    close / m_lag(close, 1*22) as return_1m,

2、wgt_return Nm 个股最近N个月内用每日换手率乘以每日收益率求算数平均值, N=1,3,6,12

    m_avg(change_ratio*turn,1*22) as wgt_return_1m,

3、HAlpha 个股22天收益与上证综指回归的截距项

with index_ret as (
  select 
  	date,
  	change_ratio as index_return,
  	instrument as index_code
  from cn_stock_index_bar1d
  where instrument = '000001.SH'
)
SELECT
    -- 上证综指收益率
    index_return,
    index_code,    
	m_regr_intercept(change_ratio,index_return,22*1) as HAlpha,
FROM cn_stock_bar1d d
join index_ret using (date)

4、exp_wgt_return_Nm

个股最近N个月内用每日换手率乘以函数exp(-x_i/N/4)再乘以每日收益率求算数平均值,x_i为该日距离截面日的交易日个数

采用Python动态生成SQL的方式实现,最终拼接成一个完整的SQL查询

    m_lag(turn,0)*m_lag(change_ratio,0)*exp(-0/1/4)+m_lag(turn,1)*m_lag(change_ratio,1)*exp(-1/1/4)+...+m_lag(turn,21)*m_lag(change_ratio,21)*exp(-21/1/4) as exp_wgt_return_1m

三、新版策略源码

https://bigquant.com/codesharev2/55d02284-0e7d-451b-96f6-186acc58e5c3

\

四、原版视频

https://www.bilibili.com/video/BV1pT411A713?share%5Fsource=copy%5Fweb&vd%5Fsource=2e7dc1240ea373ea6eba1134af8dd086

\

{link}