温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

R语言A股股票小参数计算的方法

发布时间:2022-04-06 16:19:11 来源:亿速云 阅读:187 作者:iii 栏目:编程语言

这篇“R语言A股股票小参数计算的方法”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“R语言A股股票小参数计算的方法”文章吧。

libname yu "E:\yugao\时间跨度相关\TXT"; *sh700000数据测试; 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;

以上就是关于“R语言A股股票小参数计算的方法”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI