您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > 金融MATLAB实验报告三解析
1安徽财经大学金融证券实验室实验报告实验课程名称《金融MATLAB》开课系部金融学院班级学号姓名指导教师2015年**月**日2实验名称MATLAB金融数量分析学院学号姓名实验准备实验目的学会使用MATLAB金融工具箱进行金融数量分析,如:期权定价分析、投资组合绩效分析、收益和风险的计算、有效前沿的计算、固定收益证券的久期和凸度计算、利率的期限结构、技术指标计算等。实验设计方案使用MATLAB金融工具箱对下述6个主题进行数量分析,数据来源自行在网上搜寻,要求是2014年之后的数据。(可参照各章的例题)1.期权定价分析(第10章)2.收益、风险和有效前沿的计算(第12章)3.投资组合绩效分析(第13章)4.固定收益证券的久期和凸度计算(第17章)5.利率的期限结构(第18章)6.技术指标分析(第22章)本实验报告不指定具体的题目,请大家自行设定,同学相互之间不要出现雷同。3实验分析过程一、收益、风险和有效前沿的计算从Wind咨询金融终端分别下载三只股票(美好集团、石油化服和首开股份)从2013年年初至今的日收盘价价格,经过相关处理得出三只股票的收益率均值、标准差以及协方差矩阵等数据,如下表。现根据表格数据进行关于收益、风险和有效前沿计算。收益率均值收益率标准差美好集团0.00180.03120.00100.00040.0005石油化服0.00160.04110.00040.00170.0003首开股份0.00060.03610.00050.00030.0013协方差矩阵1.收益率和风险计算函数例1.假设等权重配置美好集团、石油化服、首开股份,计算资产组合的风险和收益。解:ExpReturn=[0.0018,0.0016,0.0006];ExpCovariiance=[0.0010,0.0004,0.0005;0.0004,0.0017,0.0003;0.0005,0.0003,0.0013];PortWts=1/3*ones(1,3);[PortRisk,PortReturn]=portstats(ExpReturn,ExpCovariance,PortWts)PortRisk=0.0170PortReturn=0.00132.有效前沿计算函数例2.(1)怎样配置美好集团、石油化服和首开股份,则资产组合为最优组合?解:ExpReturn=[0.0018,0.0016,0.0006];ExpCovariiance=[0.0010,0.0004,0.0005;0.0004,0.0017,0.0003;0.0005,0.0003,0.0013];NumPorts=10;[PortRisk,PortReturn,PortWts]=frontcon(ExpReturn,ExpCovariance,NumPorts)PortRisk=0.01370.01390.01440.01510.01580.01660.01750.01840.01940.02294PortReturn=0.00060.00080.00090.00100.00120.00130.00140.00150.00170.0018PortWts=00.04390.956100.17240.82760.02750.26780.70470.10320.30540.59140.17890.34300.47810.25460.38060.36470.33030.41830.25140.40600.45590.13810.48170.49350.02481.000000画图:frontcon(ExpReturn,ExpCovariance,NumPorts)5(2)例2中如果各个资产投资上限为50%,求解有效前沿?ExpReturn=[0.0018,0.0016,0.0006];ExpCovariiance=[0.0010,0.0004,0.0005;0.0004,0.0017,0.0003;0.0005,0.0003,0.0013];NumPorts=10;AssetBounds=[0,0,0;0.5,0.5,0.5];[PortRisk,PortReturn,PortWts]=frontcon(ExpReturn,ExpCovariance,NumPorts,[],AssetBounds)PortRisk=0.01560.01600.01640.01680.01730.01770.01820.01870.01920.0197PortReturn=0.00110.00120.00130.00130.00140.00140.00150.00160.00160.0017PortWts=0.11960.38040.50000.19670.35190.45140.23440.37060.39490.27220.38940.33850.30990.40810.28200.34760.42680.22560.38530.44560.16910.42300.46430.11260.46080.48310.05620.50000.500006frontcon(ExpReturn,ExpCovariance,NumPorts,[],AssetBounds)3.约束条件下有效前沿例3.例配置美好集团、石油化服、首开股份三个资产,美好集团最大配置60%,石油化服最大配置70%,首开股份最大配置50%,美好集团为资产集合A,石油化服、首开股份组成资产计划B,集合A的最大配置为70%,集合B的最大配置为50%,集合A的配置不能超过集合B的3倍,则如何配置?解:NumAssets=3;ExpReturn=[0.0018,0.0016,0.0006];ExpCovariiance=[0.0010,0.0004,0.0005;0.0004,0.0017,0.0003;0.0005,0.0003,0.0013];NumPorts=5;PVal=1;AssetMin=0;AssetMax=[0.6,0.7,0.5];GroupA=[100];GroupB=[011];GroupMax=[0.7,0.5];AtoBmax=3;7ConSet=portcons('PortValue',PVal,NumAssets,'AssetLims',...AssetMin,AssetMax,NumAssets,'GroupComparison',GroupA,NaN,...AtoBmax,GroupB,GroupMax);[PortRisk,PortReturn,PortWts]=portopt(ExpReturn,ExpCovariance,NumPorts,[],ConSet)PortRisk=0.01560.01650.01760.01870.0199PortReturn=0.00110.00130.00140.00160.0017PortWts=0.11960.38040.50000.24680.37680.37640.33460.42040.24500.42250.46400.11350.60000.40000画图portopt(ExpReturn,ExpCovariance,NumPorts,[],ConSet)8二、投资组合绩效分析从Wind咨询金融终端分别下载三只股票(华丽家族、华远地产、合肥城建)和一只指数(中证800)从2014年年初至今的日收盘价数据,加以处理整理。之后根据2013-2014年的数据,对华丽家族、华远地产、合肥城建、中证800进行投资组合绩效分析。中证800华丽家族华远地产合肥城建日期收盘价(元)收盘价(元)收盘价(元)收盘价(元)2013-01-042643.834.614.016.952013-01-072658.724.463.946.912013-01-082657.144.483.947.42013-01-092659.234.493.97.22013-01-102666.744.943.987.22013-01-112612.774.953.796.92013-01-142710.25.013.97.052013-01-152736.965.083.917.08解:1.读取数据[typ,desc,fmt]=xlsfinfo('HHHZ.xlsX');[data,textdate]=xlsread('HHHZ.xlsX');HHHZ=data;saveHHHZHHHZ2.三只股票和一只指数的精致曲线loadHHHZfigure;holdonplot(HHHZ(:,1)/HHHZ(1,1),'k')plot(HHHZ(:,2)/HHHZ(1,2),'r-.')plot(HHHZ(:,3)/HHHZ(1,3),'bo')plot(HHHZ(:,4)/HHHZ(1,4),'g--')xlabel('time')ylabel('price')legend('中证800’,’华丽家族','华远地产','合肥城建')93.Beta与Alpha计算以中证800作为市场收益,使用portbeta函数分别计算华丽家族、华远地产、合肥城建的beta值。过程如下:(1)betaj计算loadHHHZRate=price1ret(HHHZ);BSbeta=portbeta(Rate(:,4),Rate(:,1));(2)Alpha计算以中证800作为市场收益,使用portalpha函数分别计算华丽家族、华远地产、合肥城建的beta值。过程如下:loadHHHZRate=price2ret(HHHZ);zz800=Rate(:,1);hljz=Rate(:,2);hydc=Rate(:,3);hfcj=Rate(:,4);daynum=fix(length(Rate)/2);cash=(1+0.03)^(1/daynum)-1;cash=cash*ones(daynum,1);RatioHL2013=daynum*portalpha(hljz(1:daynum),zz800(1:daynum),cash,'capm')RatioHL2014=daynum*portalpha(hljz(daynum+1:2*daynum),zz800(daynum+1:2*daynum),cash,'capm')RatioHY2013=daynum*portalpha(hydc(1:daynum),zz800(1:daynum),cash,'capm')RatioHY2014=daynum*portalpha(hydc(daynum+1:2*daynum),zz800(daynum+1:2*daynum),cash,'capm')RatioHF2014=daynum*portalpha(hfcj(1:daynum),zz800(1:daynum),cash,'capm')RatioHF2013=daynum*portalpha(hfcj(daynum+1:2*daynum),zz800(daynum+1:2*daynum),cash,'capm')RatioHL2013=0.3119RatioHL2014=0.2903RatioHY2013=0.1122RatioHY2014=0.1566RatioHF2013=0.1046RatioHF2014=0.0315104.夏普比率计算华丽家族、华远地产、合肥城建的夏普比率loadHHHZRate=price2ret(HHHZ);hljz=Rate(:,2);hydc=Rate(:,3);hfcj=Rate(:,4);daynum=fix(length(Rate)/2);Cash=(1+0.03)^(1/daynum)-1;RatioHL2013=sharpe(hljz(1:daynum),Cash)RatioHL2014=sharpe(hljz(daynum+1:2*da
本文标题:金融MATLAB实验报告三解析
链接地址:https://www.777doc.com/doc-6019427 .html