bt365娱乐官网&反转策略初探sas – yugao1986的专栏

MBAlib百科对bt365娱乐官网和加速策略作了晴天的解说:

动量/加速策略指的是价格看涨而买入成的东西的结成。,生者/赢家的买卖策略。它的次要步调是:

  决定目的股本权益百货商店作为买卖瞄准的延伸。

  其次,选择一段工夫作为演技评价期。,通常指使就职结成的体现期或排序期。。

  三。计算各样品在体现期的成品率。。

  (4)地面各样品在成形期的成品率显得庞大。,目的百货商店中掌握范本文章的上扬、递减次序等级,过后把它们掉进组。,朝内的,最大出席者组高地赢家结成。,出席者最低的的一组称为失败者结成。。

  体现期后或一段工夫后。,选择另一工夫浆糊。,作为赢家和输家的嫁的持续工夫。。

  一延续的或淬熄的时间。,不息反复 (1)行动。

  ⑦业绩评价。计算每个保养整套的公正地产品和t统计法量。,条件T统计法量象征动量/加速策略的产品是S,知情人表现,动量/反向战术是成的。,学院在动量/加速景象。,倒地亦反。

我试着逐渐应用SAS来应验关于运算。:股本权益的延伸是囫囵A股在柴纳。,体现期以P周表现。,结成拿住期用Q周表现。,这是P,Q仅占1。,2,3。随访t视察必要完成时。。

在这一点上,考验通知体系表现2000多股A股的每日通知。。

* 考验是好多股本权益的每日通知。,选择2009年至2012常年度通知
data test1;
   set test;
       year=年(日期);
       month=month(date);
       week=week(date);
   keep id date year month week close ; 
   if    2009<=year<=2012 then output;
run;
*计算两年期间股本权益的日线通知浆糊,剔除较短通知;
proc freq data=test1 noprint ;
   table id /out=test2(keep=id count)   ;
run;
data test3;
   merge test1 test2;
   by id;
   if count<360  then delete ;
   if id eq 滞后(ID) do;
   ret_1=log(close)-log(lag(close));
   end;
run;

proc sort data=test3;by id;run;
*计算每支股本权益的周累计进项;
proc sql;
   create table test4 as
      select *,
	         sum(ret_1) as sum_ret
		 from test3	
		 group by id,year,month,week;
quit;
*计算日均产品,对其举行排序,进而对2000多只股本权益举行分组;
proc sql;
   create table test5 as
      select distinct id,year,month,week,sum_ret
	     from test4;
quit;


*选定一考验时点,例如以2011年1月第一周开始,找到该时点前p周到通知,
进而按照前P周到累计产品举行排序,在这一点上p取1,2,3;
data test6;
   set test5;
   if id eq lag(id) then do;
      ret_lag1=lag(sum_ret);
      ret_lag2=lag(sum_ret)+lag2(sum_ret);
      ret_lag3=ret_lag2+lag3(sum_ret);
   end;
run;
*考虑lag函数产生缺失值的问题,我们的选取观测工夫点位2011年1月第一周;
data test7;
   set test6;
   if year=2011 & month=1 & week=1 then output;
run;

*对观测工夫点举行前P周到累计进项举行排序:升序:轮转策略;递减次序:bt365娱乐官网;
%macro rank(num);
%do i=1 %to #
proc rank data=test7 out=test7_&i group=14;
   var ret_lag&i;
   ranks group;
run;
data test_dong&i test_fan&i;
   set test7_&i;
   if group=0 then output test_fan&i;
   if group=13 then output test_dong&i;
run;

*从待选股本权益中选出动量结成股本权益,从观测日开始,计算持有结成内股本权益Q周的累计进项;

data new;
   set test6;
   if year<2011 then delete;
run;
*计算bt365娱乐官网体现期为1周,持有期为1,2,3周到进项,同理可以计算
体现期为2/3周到bt365娱乐官网;


data merge_d&i;
   merge test_dong&i(in=a) new(in=b);
   by id;
   if  a=1 & b=1 then output;
run;
proc expand data=merge_d&i out=d_&i;
   convert ret_lag1=ret1 / transform=(lead 2);
   convert ret_lag2=ret2 / transform=(lead 3);
   convert ret_lag3=ret3 / transform=(lead 4);
run;
data d_&i;
   set d_&i;
   if year=2011 & month=1 & week=1 then output;
run;

%end;
%mend;
%rank(3);

想出将下面指定遗传密码收到的结成和沪深300样品举行比对,反省其出席者。。接下来我们的必要计算上海和深圳300样品I的产品。,过后举行多样化比较地。。上海和深圳300样品通知必要先下载。。

上海、深圳300样品出席者计算
data sz399300_1;
   set sz399300;
   year=year(var1);
   month=month(var1);
   week=week(var1);
   ret=dif(log(var5));
   drop var: ;
run;
   
proc sql;
   create table sz399300_2 as
      select distinct year,month,week,
	                  和(RET) as sum_ret
	     from sz399300_1
		 group by year,month,week ;
quit;

data sz399300_3;
   set sz399300_2;
   ret_lag1=lag(sum_ret);
   ret_lag2=lag(sum_ret)+lag2(sum_ret);
   ret_lag3=ret_lag2+lag3(sum_ret);
run;

proc expand data=sz399300_3 out=sz399300_4;
   convert ret_lag1=ret1 / transform=(lead 2);
   convert ret_lag2=ret2 / transform=(lead 3);
   convert ret_lag3=ret3 / transform=(lead 4);
run;
data sz399300_4;
   set sz399300_4;
   if year=2011 & month=1 & week=1 then output;
run;


上海、深圳300与使就职结成进项的比较地
%macro diff_hs(num);
%do i= 1 %to #
proc sql;
   create table d&i_need as
      select distinct a.year,a.month,a.week,
	         mean() as ret1,
			 mean() as ret2,
			 mean() as ret3
	  from d_&i as a
	  join sz399300_4 as b
	  on a.year=b.year;
quit;

proc sql;
   create table f&i_need as
      select distinct a.year,a.month,a.week,
	         mean() as ret1,
			 mean() as ret2,
			 mean() as ret3
	  from f_&i as a
	  join sz399300_4 as b
	  on a.year=b.year;
quit;

%end;
%mend;

%diff_hs(3);

以下是体现期和保养期(P),q)以月表现的指定遗传密码。:

libname yu E:TMP
* 考验是好多股本权益的每日通知。,选择2009年至2012常年度通知
data test1;
   set YU.test;
       year=年(日期);
       month=month(date);
   keep id date year month  close ; 
   if    2009<=year<=2012 then output;
run;
*计算两年期间股本权益的日线通知浆糊,剔除较短通知;
proc freq data=test1 noprint ;
   table id /out=test2(keep=id count)   ;
run;
data test3;
   merge test1 test2;
   by id;
   if count<360  then delete ;
   if id eq 滞后(ID) do;
   ret_1=log(close)-log(lag(close));
   end;
run;

proc sort data=test3;by id;run;
*计算每支股本权益的月累计进项;
proc sql;
   create table test4 as
      select distinct id,year,month,
	         sum(ret_1) as sum_ret
		 from test3	
		 group by id,year,month;
quit;

*选定一考验时点,例如以2011年1月1日开始,找到该时点前p月到通知,
进而按照前P月到累计产品举行排序,在这一点上p取1,2,3,4,5,6;
data test5;
   set test4;
   if id eq lag(id) then do;
      ret_lag1=lag(sum_ret);
      ret_lag2=lag(sum_ret)+lag2(sum_ret);
      ret_lag3=ret_lag2+lag3(sum_ret);
	  ret_lag4=ret_lag3+lag4(sum_ret);
	  ret_lag5=ret_lag4+lag5(sum_ret);
	  ret_lag6=ret_lag5+lag6(sum_ret);
   end;
run;

*考虑lag函数产生缺失值的问题,我们的选取观测工夫点位2011年1月第一周;
data test6;
   set test5;
   if year=2011 & month=10  then output;
run;

*对观测工夫点举行前P周到累计进项举行排序:升序:轮转策略;递减次序:bt365娱乐官网;
%macro rank(num);
%do i=1 %to #
proc rank data=test6 out=test6_&i group=14;
   var ret_lag&i;
   ranks group;
run;
data test_dong&i test_fan&i;
   set test6_&i;
   if group=0 then output test_fan&i;
   if group=13 then output test_dong&i;
run;

*从待选股本权益中选出动量结成股本权益,从观测日开始,计算持有结成内股本权益Q周的累计进项;

data new;
   set test6;
   if year<2011 then delete;
run;
*计算bt365娱乐官网体现期为1周,持有期为1,2,3周到进项,同理可以计算
体现期为2/3周到bt365娱乐官网;


data merge_d&i;
   merge test_dong&i(in=a) new(in=b);
   by id;
   if  a=1 & b=1 then output;
run;
proc expand data=merge_d&i out=d_&i;
   convert ret_lag1=ret1 / transform=(lead 2);
   convert ret_lag2=ret2 / transform=(lead 3);
   convert ret_lag3=ret3 / transform=(lead 4);
   convert ret_lag4=ret4 / transform=(lead 5);
   convert ret_lag5=ret5 / transform=(lead 6);
   convert ret_lag6=ret6 / transform=(lead 7);
run;
data d_&i;
   set d_&i;
   if year=2011 & month=10  then output;
run;

data merge_f&i;
   merge test_fan&i(in=a) new(in=b);
   by id;
   if  a=1 & b=1 then output;
run;
proc expand data=merge_f&i out=f_&i;
   convert ret_lag1=ret1 / transform=(lead 2);
   convert ret_lag2=ret2 / transform=(lead 3);
   convert ret_lag3=ret3 / transform=(lead 4);
   convert ret_lag4=ret4 / transform=(lead 5);
   convert ret_lag5=ret5 / transform=(lead 6);
   convert ret_lag6=ret6 / transform=(lead 7);
run;
data f_&i;
   set f_&i;
   if year=2011 & month=10  then output;
run;
%end;
%mend;
%rank(6);

上海、深圳300样品出席者计算
data sz399300_1;
   set YU.sz399300;
   year=year(var1);
   month=month(var1);
   ret=dif(log(var5));
   drop var: ;
run;
   
proc sql;
   create table sz399300_2 as
      select distinct year,month,
	                  和(RET) as sum_ret
	     from sz399300_1
		 group by year,month ;
quit;

data sz399300_3;
   set sz399300_2;
   ret_lag1=lag(sum_ret);
   ret_lag2=lag(sum_ret)+lag2(sum_ret);
   ret_lag3=ret_lag2+lag3(sum_ret);
   ret_lag4=ret_lag3+lag4(sum_ret);
   ret_lag5=ret_lag4+lag5(sum_ret);
   ret_lag6=ret_lag5+lag6(sum_ret);
run;

proc expand data=sz399300_3 out=sz399300_4;
   convert ret_lag1=ret1 / transform=(lead 2);
   convert ret_lag2=ret2 / transform=(lead 3);
   convert ret_lag3=ret3 / transform=(lead 4);
   convert ret_lag4=ret4 / transform=(lead 5);
   convert ret_lag5=ret5 / transform=(lead 6);
   convert ret_lag6=ret6 / transform=(lead 7);
run;
data sz399300_4;
   set sz399300_4;
   if year=2011 & month=10  then output;
run;


%macro diff_hs(num);
%do i= 1 %to #
proc sql;
   create table d_need&i as
      select distinct a.year,a.month,
	         mean() as ret1,
			 mean() as ret2,
			 mean() as ret3,
	         mean() as ret4,
			 mean() as ret5,
			 mean() as ret6
	  from d_&i as a
	  join sz399300_4 as b
	  on a.year=b.year;
quit;

proc sql;
   create table f_need&i as
      select distinct a.year,a.month,
	         mean() as ret1,
			 mean() as ret2,
			 mean() as ret3,
			 mean() as ret4,
			 mean() as ret5,
			 mean() as ret6
	  from f_&i as a
	  join sz399300_4 as b
	  on a.year=b.year;
quit;

%end;
%mend;

%diff_hs(6);


data final_d9; 
   set d_need:;
run;
data final_f9;
   set f_need:;
run;
proc datasets library=work;
   delete d_: f_: merge_: Sz399300: test: new;
run;
quit;

条件在日本单位考验,可以稍为交替一下。:

E::考验国际A股通知,上海和深圳300样品SZ399 300通知
libname gao E:TMP
data test1;
   set gao.test;
   if id eq 滞后(ID) do;
      RIt = DIF(堵塞)/滞后(堵塞)
   end;
   if 年(日期)<2009 then delete; 
   keep id date ret close;
run;

*计算两年期间股本权益的日线通知浆糊,剔除较短通知;
proc freq data=test1 noprint ;
   table id /out=test2(keep=id count)   ;
run;
data test3;
   merge test1 test2;
   by id;
   if count<360  then delete ;
run;

*选定一考验时点,例如以2011年1月5日,计算前P日累计产品并举行排序,
在这一点上p取21,42;
proc expand data=test3 out=test4 method=none;
   by id;
   convert ret =ret_lag1 / transformout=(movsum 21);
   convert ret =ret_lag2 / transformout=(movsum 42);   
run;
*选定考验日;
data test5;
   set test4;
   if date="05jan2012"d then output;
run;

*以05jan2011日前21/42日累计产品举行排序,生产动量结成和加速结成;
%macro rank(num);
%do i=1 %to #
proc rank data=test5 out=test5_&i group=10;
   var ret_lag&i;
   ranks group;
run;
data test_dong&i test_fan&i;
   set test5_&i;
   if group=0 then output test_fan&i;
   if group=9 then output test_dong&i;
run;

*从待选股本权益中选出动量结成股本权益,从观测日开始,计算持有结成内股本权益Q日的累
计进项;

data new;
   set test4;
   if date<"05jan2012"d then delete;
run;
*计算bt365娱乐官网体现期为1,持有期为1,2,3进项,同理可以计算
体现期为2/3到bt365娱乐官网;

data merge_d&i;
   merge test_dong&i(in=a) new(in=b);
   by id;
   if  a=1 & b=1 then output;
run;
proc expand data=merge_d&i out=d_&i;
   convert ret_lag1=ret1 / transform=(lead 21);
   convert close=close21 / transform=(lead 21);
   convert ret_lag2=ret2 / transform=(lead 42);
   convert close=close42 / transform=(lead 42);

run;

data d_&i;
   set d_&i;
   if date="05jan2012"d  then output;
run;

data merge_f&i;
   merge test_fan&i(in=a) new(in=b);
   by id;
   if  a=1 & b=1 then output;
run;
proc expand data=merge_f&i out=f_&i;
   convert ret_lag1=ret1 / transform=(lead 21);
   convert close=close21 / transform=(lead 21);
   convert ret_lag2=ret2 / transform=(lead 42);
   convert close=close42 / transform=(lead 42);
run;
data f_&i;
   set f_&i;
   if date="05jan2012"d then output;
run;
%end;
%mend;
%rank(2);


上海、深圳300样品出席者计算

data sz399300_1;
   set gao.sz399300(rename=(var1=date var5=close));
   RIt = DIF(堵塞)/滞后(堵塞)
   drop var: ;
run;

proc expand data=sz399300_1 out=sz399300_2 method=none;
   convert ret =ret_lag1 / transformout=(sum 21);
   convert ret =ret_lag2 / transformout=(sum 42); 
run;

proc expand data=sz399300_2 out=sz399300_3;
   convert ret_lag1=ret1 / transform=(lead 21);
   convert close=close21 / transform=(lead 21);
   convert ret_lag2=ret2 / transform=(lead 42);
   convert close=close42 / transform=(lead 42);
run;
data sz399300_4;
   set sz399300_3;
   c0=close*300;
   c21=close21*300;
   C42=close42*300;
   if date="05jan2012"d  then output;
run;


%macro diff_hs(num);
%do i= 1 %to #
proc sql;
   create table d_need&i as
      select distinct a.date,
	         mean() as ret1,
			 mean() as ret2,
            (sum((ceil()/)*21) -c21)/c0 as r21,	
            (sum((ceil()/)*42) -c42)/c0 as r42

	  from d_&i as a
	  join sz399300_4 as b
	  on a.date=b.date;
quit;

proc sql;
   create table f_need&i as
      select distinct a.date,
	         mean() as ret1,
			 mean() as ret2,
            (sum((ceil()/)*21) -c21)/c0 as r21,	
            (sum((ceil()/)*42) -c42)/c0 as r42
	  from f_&i as a
	  join sz399300_4 as b
	  on a.date=b.date;
quit;

%end;
%mend;

%diff_hs(2);



data final_d1; 
   set d_need:;
run;
data final_f1;
   set f_need:;
run;

发表评论

电子邮件地址不会被公开。 必填项已用*标注

`