A股股票小参数计算

来源:互联网 发布:网络的脆弱性 编辑:程序博客网 时间:2024/04/30 04:24
libname yu "E:\yugao\时间跨度相关\TXT";*sh600000数据测试;data test;  set yu.tar(rename=(var1=date                   var2=open                   var3=high                   var4=low  var5=close  var6=volume  var7=amount));   drop amount;run;*计算R参数,R(21)=C(t)/C(t-21),当i<21时,R=C(t)/C(t-i);proc expand data=test out=test_r1 method=none;   by id;   convert close = lag21_close / transformout = (lag 21);run;data test_r2;     set test_r1; by id; r=close/lag21_close; if first.id then close1=close;     retain close1;     if r=. then r=close/close1;     drop close1;run;*计算参数S(N*4.236,n,m),N窗口期,n移动平均天数,m再次移动平均天数,例如S(55,13,3)公式:S1=(C(t)-L(T))/(H(T)-L(T)),其中t当天,T:窗口期内     S2=MA13(S1)13天的移动平均 S3=MA3(S2) 3天地移动平均(最终参数);proc expand data=test out=test_s1 method=none;      by id;      convert close = h_close / transformin=(movmax 55 );      convert close = l_close / transformin=(movmin 55 );      run; data test_s2;   set test_s1;   s1=(close - l_close)/(h_close - l_close);   run;  proc expand data=test_s2 out=test_s3 method=none;   by id;   convert s1=s2  / transformout=(movave 13);   run;proc expand data=test_s3 out=test_s4 method=none;   by id;   convert s2=s / transformout=(movave 3);run;*计算参数B(13,55,3);*HP(t)=max(high(t),close(t-1))取最大值;*LP(t)=min(Low(t),close(t-1))取最小值 ;*BULL1=((Close-open)+(open-LP)-(HP-Close))/(HP-LP);*BULL2=SUM13(BULL1) 13天地求和;*BULL3=MA55(BULL2)  55天移动平均;*BULL=MA3(BULL3)   3天移动平均(最终参数);proc expand data=test out=test_b1 method=none;      by id;      convert close=lag_close / transformout=(lag 1 );  run;data test_b2;   set test_b1;   by id;   hp=max(of high lag_close);   lp=min(of low lag_close);   bull1=((close-open)+(open-lp)-(hp-close))/(hp-lp);run;proc expand data=test_b2 out=test_b3 method=none;   convert bull1=bull2 / transformout=( movsum 13 );run;proc expand data=test_b3 out=test_b4 method=none;   convert bull2=bull3 / transformout=( movave 55 );run;proc expand data=test_b4 out=test_b5 method=none;   convert bull3=bull / transformout=( movave 3 );run;*计算V1,V2参数*v(t)当天的成交量*计算v(t)的55天移动平均:MA55(v)*dif(t)= ABS(v(t)-MA55(v))*m(t)=v(t)/1.618*dif(t-1);proc expand data=test out=test_v11 method=none;   by id;   convert volume=v_ma55 / transformout=(movave 55);run;data test_v12;   set test_v11;   v_dif=abs(volume-v_ma55);    v_m=volume/(1.618*v_dif);run;*V2参数计算;*计算参数V2(N*4.236,n,m),N窗口期,n移动平均天数,m再次移动平均天数,例如v2(55,13,3)公式:v21=(C(t)-L(T))/(H(T)-L(T)),其中t当天,T:窗口期内     v22=MA13(S1)13天的移动平均 v23=MA3(S2) 3天地移动平均(最终参数);proc expand data=test out=test_v21 method=none;      by id;      convert volume = h_volume / transformin=(movmax 55 );      convert volume = l_volume / transformin=(movmin 55 );      run; data test_v22;   set test_v21;   v21=(volume - l_volume)/(h_volume - l_volume);      run;  proc expand data=test_v22 out=test_v23 method=none;   by id;   convert v21=v22  / transformout=(movave 13);   run;proc expand data=test_v23 out=test_v24 method=none;   by id;   convert v22=v2 / transformout=(movave 3);run;

原创粉丝点击