基于sas系统金融计算随书光盘char_第1页
基于sas系统金融计算随书光盘char_第2页
基于sas系统金融计算随书光盘char_第3页
基于sas系统金融计算随书光盘char_第4页
基于sas系统金融计算随书光盘char_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/*创建数据集bonds03328datacompufin.bonds03328(label=' 年月日上交所只附息国债收盘价');inputname$10.enddate informatenddateyymmdd10.;formatenddateyymmdd10.;96国债196国债199国债197国债102国债101国债101国债102国债199国债102国债101国债101国债102国债102国债201国债2; 年月日为例)债券的现金流进行分解,产生不同债券在以后不同datafloat(keep=namec1-c37);setcompufin.bonds03328; /*edateyrdif=yrdif(sdate,edate,'30/360'); /*非整数年份数*//*以下ififfre=1thenifdif=0thendo; /*y为非整年份数dif为0时的现金流次数*/a=coupond;*a年付息频率为1*/elsedo;/*计算年付息频率为1,非整数年份数dif不为0时的现金流次数*/ /*y为非整数年份数不为0时的现金流次数*/ /*a年付息频率为1*/iffre=2thenifdif=0.5thendo;*计算年付息频率为2,非整数年份数dif为0.5y=yrdif*2;*y为非整数年份数dif为0.5*/a=coupond/2;/*a年付息频率为2时的现金流*/现金流

elseifdif>0.5thendo;*计算年付息频率为2,非整数年份数dif大于0.5y=int(yrdif)*2+2;*非整数年份数dif大于0.5*/elsedo;*计算年付息频率为2,非整数年份数dif小于0.5*/y=int(yrdif)*2+1;/*y非整数年份数dif小于0.5时的现金流次数*/arrayc{37}; doi=1toy;/*以下ififi<ythenc[i]=a; /*y*/elsec[i]=a+100;/*到期期数时的现金流*/doj=y+1to37;*大于到期期数而小于37时的现金流为0*/ 年月日以后各现金流对应的时刻(年份数)*/datatime(keep=namet1-t37);setcompufin.bonds03328;yrdif=yrdif(sdate,edate,'30/360');/*以下ififfre=1thenifdif=0then/

elsedo;*dif不等于0*/a=dif*a*/iffre=2thenifdif=0.5thenelseifdif>0.5thendo;elsedo;/*dif<0.5*/arrayt{37};doi=1to /*现金流对应的时刻,fredoj=y+1tot[j]=1;*剩余的期限赋值为1,方便NelsenSiegel模型的计算*/datafloat_time;mergefloattime;15.24dataregression(keep=nameabbccd1-d3); /*bbccd1d2d3分别对应5个参数的系数*/setfloat_time;arrayc{37};arrayt{37} doi=1to /**/ift[i]<5thendotd1=t[i]**3;td2=0;td3=0;end;elseift[i]<8thendotd1=t[i]**3-(t[i]-5)**3;td2=(t[i]-elsedotd1=t[i]**3-(t[i]-5)**3;td2=(t[i]-5)**3-(t[i]-8)**3;td3=(t[i]-8)**3;*t[i]>=8时*/dataa(keep=sumdu1);setcompufin.bonds03328end=end;ifend;);//*dataregression(keep=namevbbccd1-d3ww1);mergeregressioncompufin.bonds03328;;/ /*估计参数,并将参数的估计值直接输出到数据集Estimates中以备后面自动调用*/Odslistingclose;/*关闭LISTING*/OdsoutputParameterEstimates(match_allpersist=proc)=Estimates;procglmdata=regression;modelv=bbccd1d2d3/noint*nointweightw;Odslisting;*打开LISTINGDataa;SetIfparameter='bb'thencallsymput('bb',Estimate*bb为宏变量*/Ifparameter='cc'thencallsymput('cc',Estimate);Ifparameter='d1'thencallsymput('d1',Estimate);Ifparameter='d2'thencallsymput('d2',Estimate);Ifparameter='d3'thencallsymput('d3',Estimate);datachart(keep=tdrsrfr);/*t为时间,dr为贴现因子sr为即期利率fr为远期利率*/dot=0.05to20by0.05; /**/ift<=5thendo;else thenelse /*t>8sr=log(dr)/(-t);/*sr为连续即期利率*/fr=-log(dr1/dr);/*fr为连续远期利率*/procgplotdata=chart;symbolv='*'color=blue;plotsr*t;/*dataprice(keep=namelprice); setfloat_time;arrayc{37};arrayt{37} /*doi=1toift[i]<5 thensum=sum+(c[i]+c[i]*bb*t[i]+c[i]*cc*t[i]**2+c[i]*d1*t[i]**3);elseift[i]<8thenlprice=sum;/*lprice为理论价格*/15.2.5NELSEN-SIEGELdatabonds03328;setprocresetdeflib=work;usebonds03328;readallvar{priceintoprice*由SAS数据集bonds03328中变量price量pricereadallvar{du}intodu;*由久期的所有观测值创建向量du*/usefloat_time;readallvar('c1c37intofloat*由所有现金流值创建矩阵floatreadallvar('t1t37intotime*由现金流对应的时刻值创建矩阵time*/useregression;readallvar{w1}intowei*由所有权重w值创建向量wei*/storepricedufloattimewei;/**/prociml;resetloadpricedufloattime ,7);/*j( 为控制循环的次数*/dob1=-0.086to0.076by0.001;*b1为参数,[-0.0860.076]为b1*/dob2=-0.109to-0.098by0.001;dob0=0.086to0.094bydot1=9to12bydob3=0.042to0.054bydot2=2.2to4by0.2; y[i,7]=createyyyfromy;/*产生一个新的数据集,根据这个数据集的结果来排序,得到最小的appendfromy;procsortdata=yyy;bycol7;prociml;resetdeflib=work;loadfloattimepricedux={-0.079-0.1070.0930.04810.5storediflprice;create

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论