《金融经济学构建资产组合.docx》由会员分享,可在线阅读,更多相关《金融经济学构建资产组合.docx(37页珍藏版)》请在第一文库网上搜索。
1、金融经济学实验报告2023年6月24日实验报告1构建资产组合一、实验目的1、掌握用UaUab计算资产期望收益率、收益率协方差、模拟资产组合前沿和构建投资组合的方法.2、掌握利用Mauab金融工具箱中的函数构建投资组合的方法。二、实验内容及要求1、搜集数据学生搜集6只以上股票和一个相应指数的40个交易日的日收盘价格数据以及活期存款利率。将数据整理为EXCe1表,命名为ShiyanShUjU.x1S其中不存在缺失值,第一列为日期,第2至第7列为股票数据,第8列为指数数据,第10列为活期存款利率.2、做以下例子:【例3.1】data,Assets,raw=x1sread(FFTYshiyanshuj
2、u.x1sx,Sheet1,B1:G41);RetSeries,RetInterva1s=tick2ret(data,!,Continuous);ExpReturn,ExpCovariance,NumEffObs=ewstats(RetSeries)weights=exprnd(1,10000,6);tota1=sum(weights,2);tota1=tota1(,ones(6,1);W=weights./tota1;Erp=W*ExpRetum;Cov=W*ExpCovariance*W,;fori=1:10000;var(:,i)=Cov(i,i);endVar=(var);Sta=Va
3、r.0.5;p1ot(Var,Erp,.r);X1abeIc资产组合收益率的方差工y1abe1C资产组合的期望收益率上figure;p!ot(Sta,Erp,.g);X1abe1c资产组合收益率的标准差)y1abe1C资产组合的期望收益率)ExpReturn=16-0.00060.00260.00230.00730.0031-0.0016ExpCovariance=660.00030.00010.00020.00010.0002-0.00000.00010.00070.00020.00010.00000.00010.00020.00020.0033-0.00020.00090.00010.00
4、010.0001-0.00020.0008-0.0001-0.00010.00020.00000.0009-0.00010.00160.0003-0.00000.00010.0001-0.00010.00030.0010NumEffObs=39资产州台收&*的方牍XW30.0150.020.0250。300360.0400450.050.056资产1合收总率的标模茏【例3.21data,Assets,raw=xIsread(,FAFTYshiyanshuju.x1sx,Sheet1,B1:G41,);RetSeries,RetInterva1s=tick2ret(data,Continuous
5、);ExpReturn,ExpCovariance,NumEffObs=ewstats(RetSeries)invV=inv(ExpCovariance);a=*invV*ExpReturn,;b=ExpReturn*invV*ExpReturn;c=*invV*I;d=b*c-a2;PretUn=input(请输入组合期望收益率二,)Wp=(b*invV*I-a*invV*ExpReturn)d+preturn*(c*invV*ExpRcturn-a*invV*I)dWpVar=c*(pretum-ac)2d+1cWpStde=(c*(preturn-ac)2d+1c)0.5Erp=-0.0
6、04:0.00001:0.01;s2rp=(c*Erp.2-2*a*Erp+b)d;srp=s2rp.0.5;pIot(s2rp,Erp,g-);X1abe1c资产组合的风险水平(方差);y1abe1C资产组合的期望收益率);tiHeC均值方差资产组合选择模型);ho1donp!ot(WpVar,preturn,r*);figure;pIot(srp,Erp);X1abe1c资产组合的风险水平(标准差。y1abe1C资产组合的期望收益率上tit1eC均值方差资产组合选择模型);ho1donp1ot(WpStde,pretumr*);请输入组合期望收益率=0.006preturn=0.0060W
7、p=61-0.11280.20370.03980.65110.19660.0216WpVar=4.I752e-04WpStde=0.02040.0150020.0250030.035贵产ft1台的风险水平(标准计)XW3均做方总资产Wifr选界模展6420Assisi费产用令的风H水平(方期)x10310XiCra均8一方整一产BI化选界段中【例3.3】data,Assets,raw=x1sreadCF:FTYXshiyanshuju.x1sx,1Sheet,B1:G4T);RetSeries,RetInterva1s=tick2ret(data,Continuous);ExpReturn,E
8、xpCovariance,NumEffObs=ewstats(RetSeries);p=Portfo1io;p=p.setAssetMoments(ExpReturn,ExpCovariance);p=p.setBounds(-10,-10,-10,-IOr10,-10,10,10,10,10,10,10);p=p.setEqua1ity(1,1,1,1,1,1,1);prcturn=0.0050,0.0100,0.0200pweight=p.estimateFrontierByRetum(preturn);,pweight=fori=1:6fprintf(,%IOs%10f%10f%1Ofn
9、,Assetsi,pweight(i,:);endprisk=p.estimatePortRisk(pweight)p1ot(prisk,preturn,*r)ho1donp.p1otFrontier(10000)preturn=130.00500.01000.0200ans=pweight=,青岛双星0.003140-0.576707-1.736402阳光股份0.1896580.2599360.400494沈阳化工0.0343170.0617110.116500滨海能源0.5534651.0416222.017937南宁糖业0.1605970.3407070.700925平安银行0.0588
10、23-0.127269-0.499454prisk=310.01790.03240.0658EfficientFrontier0.14111111【例3.4】data,Assets,raw=xIsread(,FAFTYshiyanshuju.x1sxSheet1,B1:G41);RetSeries,RetInterva1s=tick2ret(data,Continuous);ExpReturn,ExpCovariance,NumEffObs=eWstats(RetSeries);p=Portfo1io;p=p.setAssetMoments(ExpReturn,ExpCovariance);p
11、=p.setBounds(-10,-10,-10,-10,-10,-10,10,10,10,10,10,10);p=p.setEqua1ity(1,1,1,1,1,1,1);I=1;1;1;1;1;1;a=*inv(ExpCovariance)*ExpReturn;b=ExpReturn*inv(ExpCovariance)*ExpReturn;c=*inv(ExpCovariance)*I;Wmvp=inv(ExpCovariance)*IcWd=inv(ExpCovariance)*ExpRcturn7aPretmvp=a/cPretd=ExpReturn*Wdpriskmvp=(1c)0
12、.5priskd=(Wd*ExpCovariance*Wd)0.5p1ot(priskmvp,Pretmvp,*g)ho1donp1ot(priskd,Pretd,*r,)ho1donp.p1otFrontier(10000)Wmvp=610.41160.14010.01500.20960.03370.1899Wd=61-0.68370.27290.06681.13170.3739-0.1616Pretmvp=0.0015Pretd=0.0109priskmvp=0.0130priskd=0.0354EfficientFrontier0.140.120.10.080.060.04SUJ2eO-
13、PgJQdJO cws【例3.51data,Assets,raw=x1sreadCF:FTYXshiyanshuju.x1sx,1Sheet,B1:G4T);RetSeries,RetInterva1s=tick2ret(data,Continuous);ExpReturn,ExpCovariance,NumEffObs=ewstats(RetSeries)a=*inv(ExpCovariance)*ExpReturn;b=ExpRetum*inv(ExpCovariance)*ExpReturn;c=*inv(ExpCovariance)*I;d=b*c-a2;Erp=-0.015:0.00
14、001:0.025;pRisk=(c*Erp.A2-2*a*Erp+b)/d).A0.5;pIot(pRisk,Erp,g-);X1abe1e资产组合的风险水平(标准差力;y1abe1C资产组合的期望收益率上出加(,均值方差资产组合选择模型);PretUm=input(请输入组合期望收率=)Wp=(b*inv(ExpCovariance)*1-a*inv(ExpCovariance)*ExpReturn)d+preturn*(c*inv(ExpCovariance)*ExpReturn-a*inv(ExpCovariance)*I)dprisk=(c*preturn2-2*a*pretum+b)d).0.5ho1donp1ot(prisk,preturn,r*);text(prisk,preturn;一前沿资产组合p,);s1ope=d*prisk(c*pr