请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  数理科学 帖子:3121152 新帖:38

隔夜跳空因子的选股能力

不做外汇索罗斯发表于:8 月 7 日 18:00回复(1)

(1)研究思路
从交易行为来看,短期跳空缺口潜在反映了短期激进和股价操纵的投资行为,此类交易异动的因子具有负向alpha,通过引入隔夜涨跌幅的绝对值,并取过去一段区间的隔夜涨跌幅的均值作为隔夜跳空因子。
研究得出,过去具有较大的跳空缺口特点的股票未来收益更差,隔夜跳空因子的超额收益不够显著,但该因子有较好的规避风险能力。

(2)因子的构造
根据方正的研究,隔夜涨跌幅既不呈现反转也不呈现动量效应,而是过大或者过小都会具有负向收益,那么引入隔夜涨跌幅的绝对值来衡量隔夜跳空现象,可以合理猜想该因子具有负向收益。

Ft=|opent /closet -1-1|

其中,open_t表示第t日的开盘价,close(t-1)表示第t-1的收盘价。则Ft为第t日的跳空缺口。未来考察过去不同时间长度下的跳空缺口对资产收益的影响,采用过去N天Ft计算其算术平均值,那么有:

Ft=1/Nni=1Ft-i 1

隔夜跳空因子的研究——基于方正研报的研究¶

基于方正因子七十二变系列研报,对隔空跳空因子进行了复现和学习,主要是自学用的,同时做完也分享给大家。

从交易行为来看,短期跳空缺口潜在反映了短期激进和股价操纵的投资行为,此类交易异动的因子具有负向alpha,通过引入隔夜涨跌幅的绝对值,并取过去一段区间的隔夜涨跌幅的均值作为隔夜跳空因子。

根据方正的研究,隔夜涨跌幅既不呈现反转也不呈现动量效应,而是过大或者过小都会具有负向收益,那么引入隔夜涨跌幅的绝对值来衡量隔夜跳空现象,可以合理猜想该因子具有负向收益。

因子的构造方式为:隔夜跳空为abs(今天的开盘价/昨天收盘价-1),然后去过去10天的平均值作为隔夜跳空因子值。

import numpy as np
import pandas as pd
from jqdata import *
from jqfactor import *
import warnings  
warnings.filterwarnings('ignore') 

#设置研究日期
start="2016-7-1"
end="2019-7-1"
#调仓周期设置
period=(1,5,10)
#获取交易日历
df = get_price('000001.XSHG',start_date=start,end_date=end)
date_list=df.index
#研究股票池(以中证500为研究对象)
stock_index="000905.XSHG"

#计算因子值函数,返回index为stock,column为10日跳空因子值
def calf(stock_list,date):
    df=get_price(stock_list,end_date=date,count=10,frequency='daily',fields=['open', 'close'],fq="pre")
    ret=df["open"]/df["close"].shift(1)-1
    ret=ret.abs()
    ret=ret.mean()
    return ret

#建立空dataframe来接数据
factor=pd.DataFrame()
point=1
#计算中证500成分股每天的隔夜跳空因子值
for i in range(0,len(date_list)):   
    stocks=get_index_stocks("000905.XSHG",date=date_list[i])
    fac=calf(stocks,date_list[i])
    if point==1:
        factor=fac
        point=0
    else:
        factor=pd.concat([factor,fac],axis=1)
print(i)
    
729
#分成5组
quantiles=5
#把列名换成交易日
factor.columns=date_list
#把格式转置成合适形式
factor_df=factor.T
factor_df.head(5)
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
000006.XSHE 000008.XSHE 000009.XSHE 000012.XSHE 000021.XSHE 000025.XSHE 000027.XSHE 000028.XSHE 000030.XSHE 000031.XSHE 000039.XSHE 000049.XSHE 000050.XSHE 000060.XSHE 000061.XSHE 000062.XSHE 000066.XSHE 000078.XSHE 000088.XSHE 000089.XSHE 000090.XSHE 000099.XSHE 000156.XSHE 000158.XSHE 000301.XSHE 000400.XSHE 000401.XSHE 000417.XSHE 000418.XSHE 000426.XSHE 000488.XSHE 000501.XSHE 000513.XSHE 000517.XSHE 000519.XSHE 000528.XSHE 000536.XSHE 000537.XSHE 000541.XSHE 000543.XSHE ... 603169.XSHG 603188.XSHG 603198.XSHG 603225.XSHG 603228.XSHG 603233.XSHG 603328.XSHG 603355.XSHG 603369.XSHG 603377.XSHG 603444.XSHG 603486.XSHG 603501.XSHG 603515.XSHG 603517.XSHG 603528.XSHG 603555.XSHG 603556.XSHG 603567.XSHG 603568.XSHG 603569.XSHG 603589.XSHG 603650.XSHG 603658.XSHG 603659.XSHG 603698.XSHG 603699.XSHG 603712.XSHG 603766.XSHG 603799.XSHG 603806.XSHG 603816.XSHG 603866.XSHG 603868.XSHG 603877.XSHG 603883.XSHG 603885.XSHG 603888.XSHG 603899.XSHG 603939.XSHG
2016-07-01 0.004001 0.008467 NaN 0.005997 0.015962 NaN NaN 0.003103 0.003596 0.002096 NaN 0.004284 0.006214 NaN NaN 0.003894 0.019996 0.005727 0.002663 NaN 0.004602 0.004614 NaN 0.009168 NaN 0.003644 0.0 0.004125 0.001722 0.009046 0.005191 0.002338 0.003183 0.0 0.017030 0.002617 NaN NaN 0.004542 0.006258 ... 0.003706 0.003475 0.005618 NaN NaN NaN 0.005803 0.005155 NaN NaN NaN NaN NaN NaN NaN NaN 0.003966 NaN 0.003384 0.005073 NaN 0.008134 NaN NaN NaN 0.002448 0.005036 NaN 0.003733 NaN 0.010142 NaN NaN NaN NaN 0.003641 NaN NaN NaN NaN
2016-07-04 0.004636 0.009308 NaN 0.006578 0.015449 NaN NaN 0.003379 0.003594 0.002213 NaN 0.003634 0.007067 NaN NaN 0.003773 0.021630 0.004655 0.003179 NaN 0.004164 0.003966 NaN 0.008263 NaN 0.003082 0.0 0.004693 0.002058 0.019663 0.004666 0.002998 0.003967 0.0 0.018433 0.002608 NaN NaN 0.005045 0.005897 ... 0.003812 0.002989 0.007933 NaN NaN NaN 0.006000 0.005704 NaN NaN NaN NaN NaN NaN NaN NaN 0.004245 NaN 0.002811 0.004601 NaN 0.008707 NaN NaN NaN 0.002279 0.005151 NaN 0.004641 NaN 0.009957 NaN NaN NaN NaN 0.003983 NaN NaN NaN NaN
2016-07-05 0.003949 0.010115 NaN 0.006266 0.015637 NaN NaN 0.003571 0.003108 0.005194 NaN 0.004640 0.006407 NaN NaN 0.003116 0.021034 0.004023 0.002992 NaN 0.003700 0.004104 NaN 0.008135 NaN 0.002925 0.0 0.004971 0.002272 0.029973 0.004415 0.002900 0.005073 0.0 0.019595 0.002347 NaN NaN 0.005038 0.004284 ... 0.003633 0.003293 0.008093 NaN NaN NaN 0.005083 0.005525 NaN NaN NaN NaN NaN NaN NaN NaN 0.004057 NaN 0.002324 0.004458 NaN 0.007358 NaN NaN NaN 0.002563 0.006225 NaN 0.004610 NaN 0.008280 NaN NaN NaN NaN 0.003806 NaN NaN NaN NaN
2016-07-06 0.004260 0.009359 NaN 0.005807 0.016968 NaN NaN 0.003745 0.002870 0.005301 NaN 0.004968 0.006362 NaN NaN 0.003851 0.021683 0.003714 0.003676 NaN 0.003700 0.004924 NaN 0.007600 NaN 0.003141 0.0 0.005262 0.002123 0.029543 0.004151 0.003276 0.004903 0.0 0.020278 0.002561 NaN NaN 0.004758 0.003646 ... 0.004750 0.003478 0.007967 NaN NaN NaN 0.005174 0.005358 NaN NaN NaN NaN NaN NaN NaN NaN 0.003452 NaN 0.002376 0.004192 NaN 0.003775 NaN NaN NaN 0.003051 0.005955 NaN 0.004706 NaN 0.006659 NaN NaN NaN NaN 0.003826 NaN NaN NaN NaN
2016-07-07 0.005348 0.011968 NaN 0.006085 0.016359 NaN NaN 0.003084 0.003332 0.005770 NaN 0.005074 0.006770 NaN NaN 0.004037 0.022601 0.003072 0.002962 NaN 0.003262 0.005458 NaN 0.005985 NaN 0.003213 0.0 0.004945 0.001254 0.030587 0.004620 0.003560 0.005106 0.0 0.019206 0.002787 NaN NaN 0.004724 0.003778 ... 0.004657 0.003405 0.009356 NaN NaN NaN 0.005630 0.004788 NaN NaN NaN NaN NaN NaN NaN NaN 0.002570 NaN 0.002370 0.004522 NaN 0.006184 NaN NaN NaN 0.003845 0.006427 NaN 0.004855 NaN 0.005969 NaN NaN NaN NaN 0.003148 NaN NaN NaN NaN
#进行单因子分析
far = analyze_factor(factor=factor_df, weight_method='avg', industry='jq_l1', quantiles=quantiles, periods=period,max_loss=0.49)
# 打印信息比率(IC)相关表
far.plot_information_table(group_adjust=False, method='rank')
IC 分析
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
period_1 period_5 period_10
IC Mean -0.038 -0.062 -0.078
IC Std. 0.152 0.144 0.128
IR -0.251 -0.429 -0.604
t-stat(IC) -6.770 -11.586 -16.324
p-value(IC) 0.000 0.000 0.000
IC Skew 0.259 0.622 0.696
IC Kurtosis -0.169 0.748 0.902

可以看到因子的IC值为负,说明因子值与收益成负相关关系,跳空值越大的股票收益越低,反之收益越高。且第10组的IC和IR值最大。

下图把股票按因子值分成5组,第五组的负收益很显著,但其他第1组至第3组的收益区分度并不高。说明跳空因子具有较好的识别下跌风险,但是并没有很好的寻找超额收益的能力。

# 画各分位数平均收益图
far.plot_quantile_returns_bar(by_group=False, demeaned=0, group_adjust=False)
<Figure size 432x288 with 0 Axes>
# 打印换手率表
far.plot_turnover_table()
换手率分析
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
period_1 period_10 period_5
Quantile 1 Mean Turnover 0.165 0.554 0.407
Quantile 2 Mean Turnover 0.357 0.735 0.652
Quantile 3 Mean Turnover 0.385 0.762 0.685
Quantile 4 Mean Turnover 0.312 0.739 0.633
Quantile 5 Mean Turnover 0.136 0.589 0.393
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
period_1 period_5 period_10
Mean Factor Rank Autocorrelation 0.944 0.693 0.437
# 计算指定调仓周期的各分位数每日累积收益
df = far.calc_cumulative_return_by_quantile(period=1)
#进行数据展示
df.plot(figsize=(15,6))
<matplotlib.axes._subplots.AxesSubplot at 0x7f789b3c9860>
mdate_list=get_tradeday_list(start,end)
df = far.calc_cumulative_return_by_quantile(period=5)
#进行数据展示
df.plot(figsize=(15,6))
<matplotlib.axes._subplots.AxesSubplot at 0x7f789acaa9b0>
df = far.calc_cumulative_return_by_quantile(period=10)
#进行数据展示
df.plot(figsize=(15,6))
<matplotlib.axes._subplots.AxesSubplot at 0x7f7899c28a90>

以上三个图分布展示了持仓周期在为1、5、10的累计收益情况,可以看到第五组的区分度特别大,而其他四组的区分度不明显。

我们再把持仓周期延长看看效果怎样。

#进行单因子分析
far = analyze_factor(factor=factor_df, weight_method='avg', industry='jq_l1', quantiles=quantiles, periods=(15,20,30),max_loss=0.49)
# 画各分位数平均收益图
far.plot_quantile_returns_bar(by_group=False, demeaned=0, group_adjust=False)
<Figure size 432x288 with 0 Axes>

结果也是类似,第五组具有较高的负收益,而前面四组的区分度不高。隔夜跳空因子具有较好的识别风险能力,但是赚钱超额收益的能力一般。

全部回复

0/140

量化课程

    移动端课程