《金融经济学 构建资产组合.docx》由会员分享,可在线阅读,更多相关《金融经济学 构建资产组合.docx(42页珍藏版)》请在第一文库网上搜索。
1、金融经济学实验报告2021年6月24日实验报告1构建资产组合一、实验目的1、掌握用Matlab计算资产期望收益率、收益率协方差、模拟资产组合前沿和构建投资组合的方法.2、掌握利用Matlab金融工具箱中的函数构建投资组合的方法。二、实验内容及要求1、搜集数据学生搜集6只以上股票和一个相应指数的40个交易日的日收盘价格数据以及活期存款利率。将数据整理为Excel表,命名为shiyanshuju.xls其中不存在缺失值,第一列为日期,第2至第7列为股票数据,第8列为指数数据,第10列为活期存款利率.2、做以下例子:【例3.1】data,Assets,raw = xlsreadCFAFTYhiyan
2、shuju.xlsx1,Sheet 1 B 1 :G41 ,);RetSeries, Retlntervals = tick2ret(data, ,Continuous1);ExpReturn, ExpCovariance, NumEffObs = ewstats(RetSeries)weights = exprnd(l,10000,6);total = sum(weights , 2);total = total(:,ones(6,l);W = weights./total;Erp=W*ExpReturn;Cov=W*ExpCovariance*W,;for i=l: 10000;var(:
3、j)=Cov(ij);endVar=(var);Sta=Var.A0.5;plot(Var, ErpJ.r);xlabelC资产组合收益率的方差);ylabelC资产组合的期望收益率)figure; plot(Sta, Erp,xlabelC资产组合收益率的标准差上ylabelC资产组合的期望收益率)ExpReturn = 1 x6-0.00060.00260.00230.00730.0031-0.0016ExpCovariance=6x60.00030.00010.00020.00010.0002-0.00000.00010.00070.00020.00010.00000.00010.000
4、20.00020.0033-0.00020.00090.00010.00010.0001-0.00020.0008-0.0001-0.00010.00020.00000.0009-0.00010.00160.0003-0.000()().00010.0001-0.00010.00030.0010NumEffObs = 392100.511.522.53傀产组合收差率的方差x 10。0.01 0015 0.02 0 025 0 03 0 035 0 04 0 045 0 05 0 055资产组合收益率的标准走【例3.2】data,Assets,raw = xIsreadCFAFTYXshiyan
5、shuju.xlsx/Sheetr/Bl :G4T);RetSeries, Retlntervals = tick2ret(data, /Continuous);ExpReturn, ExpCovariance, NumEffObs = ewstats(RetSeries)invV =inv(ExpCovariance);a=r*invV*ExpReturn,;b=ExpReturn:invV*ExpReturn,;c=I*invV*I;d=b*c-a 八 2;prelurn=inpul(请输入组合期望收益率廿)Wp=(b*invV*I-a*invV*ExpReturn,)/d+preturn
6、*(c*invV*ExpRetum,-a*invV*I)/dWpVar=c*(preturn-a/c)A2/d+ 1/cWpStde=(c*(preturn-a/c)A2/d+l/c)A0.5Ei-p=-().()()4:().0()001:().() 1;s2rp=(c*Erp.八 2-2*a*Erp+b)/d;srp=s2rp.A0.5;plot(s2rp,Erp,g-*);xlabeK资产组合的风险水平(方差);ylabelC资产组合的期望收益率);tilleC均值方差资产组合选择模型);hold onplot(WpVar,preturn,产);figure;plol(srp,Erp,g
7、-);xlabelC资产组合的风险水平(标准差力;ylabelC资产组合的期望收益率上titled均值方差资产组合选择模型);hold onplot(WpStde,pretum,r*);请输入组合期望收益率=0.006preturn = 0.0060Wp = 6xl-0.11280.20370.03980.65110.19660.0216WpVar = 4.1752e-04WpStde = 0.0204410.6资产组合的风险水平(方策)均值方差资产组合选择模M6 4 2 0*&之招察-40.010.0150.020.0250.03资产组合的风险水平(标准制)均(ft方差资产州合选样模型6 4
8、 2 0*s咨工 羽)0.035【例3.3】data,Assets,raw = xlsread(F:FTYshiyanshuju.xlsx7Sheet 1 ,B 1 :G41r);RelSeries, Retlntervals = tick2ret(data, 1/Continuous1);ExpReturn, ExpCovariance, NumEffObs = ewstats(RetSeries);p = Portfolio;p = p.setAssetMoments(ExpReturn, ExpCovariance);p =p.setBounds(-10,-10,-10,-10,-10,
9、-10,10,10,10,10,10,10);p = p.setEquality( 1,1,1,1,1,1 , 1);preturn=0.0050,0.0100,0.0200pweight =p.estimateFrontierByReturn(preturn);pweight =*for i= 1:6fprintf(% 10s%10f%10f%l Ofn,Assets i ,pweight(i,:);endprisk = p.estimatePortRisk(pweight)plot(prisk,preturn, r1)hold onp.plotFrontier(l 0000)preturn
10、 = 1 x30.00500.01000.0200ans =weight 二,青岛双星阳光股份沈阳化工滨海能源0.0031400.1896580.0343170.553465-0.5767070.2599360.061711L041622-1.7364020.4004940.1165002.017937南宁糖业0.1605970.3407070.700925平安银行0.058823 -0.127269 -0.499454prisk = 3x10.01790.03240.0658swnou o=OJt:od jo ueon【例3.4】data,Assets,raw = xlsread(F:FTY
11、shiyanshuju.xlsxVSheetr,Bl:G4r);RetSeries, Retlntervals = tick2ret(data J,Continuous);ExpReturn, ExpCovariance, NumEffObs = ewstats(RelSeries);p = Portfolio;p = p.setAssetMoments(ExpReturn, ExpCovariance);p =p.setBounds(-l 0,-10,-10,-10,-10,-10,10,10,10,10,10,10);p = p.setEquality(l, 1,1,1,1,1);a=r*
12、inv(ExpCovariance)*ExpReturn,;b= ExpReturn*inv(ExpCovariance)*ExpReturn,;c=r*inv(ExpCovariance)*I;Wmvp=inv(ExpCovariance)*I/cWd=inv(ExpCovariance)*ExpReturn7aPretmvp= a/cPretd= ExpReturn*Wdpriskmvp =( l/c)A0.5priskd =( Wd* ExpCovariance* Wd)A0.5plot(priskmvp,Pretmvp/*gr)hold onplot(priskd,Pretdhold
13、onp.p!otFrontier( 10000)Wmvp = 6x10.41160.14010.01500.20960.03370.1899Wd = 6xl-0.68370.27290.06681.13170.3739-0.1616Pretmvp = 0.0015Pretd = 0.0109priskmvp = 0.0130priskd = 0.0354swnou o=OJt:od jo ueon【例3.5】(data,Assets,raw = xlsread(F:FTYshiyanshuju.xlsxSheet 1 B 1:G41);RetSeries, Retlntervals = tic
14、k2ret(data, ,Continuous);ExpReturn, ExpCovariance, NumEffObs = ewstats(RetSeries)a=r*inv(ExpCovariance)*ExpReturn;b=ExpReturn*inv(ExpCovariance)*ExpReturn;c=I*inv(ExpCovariance)*I;d=b*c-aA2;Erp=-0.015:0.00001:0.025;pRisk=(c*Erp.A2-2*a*Erp+b)/d).A0.5;plot(pRisk,Erp;g-r);xlabelC资产组合的风险水平(标准差力;ylabelC资产组合的期望收益率);title。均值方差资产组合选择模型);pretum=input(请输入组合期望收率二)Wp=(b*inv(ExpCovariance)*I-a*inv(ExpCo