MATLAB金融计算试题_第1页
MATLAB金融计算试题_第2页
MATLAB金融计算试题_第3页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

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

文档简介

1、datestr(curvedates) plot(zerorates) 运行结果:zerorates =0.01150.01180.01680.03020.04180.0550curvedates =735341735432735964737014738840745507MATLA金融计算试题(2014级研究生用)(上机操作使用)、利率期限结构(20 分)已知国债面值是100美元,各期收益率为国债品种票息到期日当期收益3个月17-Apr-20131.156个月17-Jul-20131.182年1.7531-Dec-20141.685年3.0015-Nov-20172.9710年4.0015-N

2、ov-20224.0130年5.37515-Feb-20414.92试分析其利率期限结构。MATLAB命 令:bo nds=date num('04/17/2013') 0100;date num('07/17/2013') 0100;datenum('12/31/2014') 0.0175 100;datenum('11/15/2017') 0.03100;datenum('11/15/2022') 0.04100;datenum('02/15/2041') 0.0537 100;yield=0.

3、0115 0.0118 0.0168 0.0297 0.0401 0.0492' settle=date num('01/17/2013'); %结算日zerorates,curvedates=zbtyield(b on ds,yield,settle)0.055 ,1,1c1,0.05-0.045-0.04 -/-0.0350.030.0250.02-0.015-0.01 !1111cJ111.522.533.544.555.56ans = 17-Apr-201317-Jul-201331-Dec-201415-Nov-201715-Nov-202215-Feb-20

4、41二、期权定价(30分)若股票现在价格为$50,期权执行价格为$52,无风险利率为0.1,股票波动标准差为 期权的到期日为6个月,且若这一卖权在3.5月时有一次股息支付$2。(1) 使用Black-Scholes定价公式计算欧式卖权和买权的价值;MATLAB命 令:price=50;strike=52;rate=0.1;time=6/12;volatility=0.4;callprice,putprice=blsprice(price,strike,rate,time,volatility)运行结果:callprice =5.8651putprice =5.3290(2) 利用二项式期权定价

5、(二叉树(CRR模型定价数值解)计算看涨看跌期权价格MATLAB命 令:price=50;strike=52;rate=0.1;time=6/12;in creme nt=1/12;volatility=0.4;flag=0;divide ntrate=0;divide nt=2;exdiv=3.5;price,optio n=bi nprice(price,strike,rate,time,i ncreme nt,volatility,flag,divide ntrate,divide nt,exdiv)运行结果:得岀二叉树每个交点处的资产价格和期权价值price =50.0000 55.8

6、985 62.5172 69.9441 76.2699 85.6054 96.08360 44.7755 50.0326 55.9315 60.5420 67.9524 76.269900 40.1226 44.8084 48.0575 53.9398 60.5420000 35.9790 38.1474 42.8167 48.0575000030.2809 33.9873 38.147400000 26.9787 30.2809000000 24.0366optio n =6.70163.93081.76520.459800009.66866.22753.13930.94120000 13.

7、37629.51325.45601.926300 00 00 00 00 17.5811 13.8526 9.1833 3.94250021.7191 18.0127 13.8526000 25.0213 21.7191由结果可知,option第一行第一列就是看跌期权价格,该期权价格为6.7016 兀。000 0 27.9634MATLAB命令: price=50; strike=52;rate=0.1; time=6/12; in creme nt=1/12; volatility=0.4; flag=1;divide ntrate=0;divide nt=2;exdiv=3.5;price

8、,opti on=bin price(price,strike,rate,time,i ncreme nt,volatility,flag,divide ntrate,divide nt,exdiv)运行结果:得出二叉树每个交点处的资产价格和期权价值.price =50.0000 55.8985 62.5172 69.9441 76.2699 85.6054 96.08360 44.7755 50.0326 55.9315 60.5420 67.9524 76.269900 40.1226 44.8084 48.0575 53.9398 60.5420000 35.9790 38.1474 4

9、2.8167 48.0575000 030.2809 33.9873 38.1474000 00 26.9787 30.2809000 000 24.0366optio n =4.99967.879212.086417.9441 25.1294 34.0369 44.083602.1193 3.68096.2599 10.3427 16.3840 24.2699000.54731.08782.16224.29768.54200000000000000000000000000000由结果可知,option第一行第一列就是看涨期权价格,该期权价格为 4.9996元。(3) 假设股票价格服从几何布朗

10、运动,试用蒙特卡洛模拟方法计算该期权价格。MATLAB命令:s0=50;K=52;r=0.1;T=0.5;sigma=0.4; Nu=1000;randn( 'seed' ,0);%定义随机数发生器种子是0,%这样保证每次模拟的结果相同n uT=(r-0.5*sigmaA2)*Tsit=sigma*sqrt(T) discpayoff=exp(-r*T)*max(0,s0*exp( nuT+sit*ra ndn (Nu,1)-K);%期权到期时的现金流eucall,varprice,ci=no rmfit(discpayoff)运行结果:nuT =0.0100sit =0.28

11、28eucall =6.1478varprice =10.2924ci =5.50916.7865三、搜集数据并计算画图(50分)按照自己的研究生学号后两位数,在锐思金融数据库中搜集 4种股票信息,包括最高价、最低价、收盘价和开盘价,数据个数2个月左右,建立数据表格。要求使用MATLAB编程解决以下问题:(1) 将4种股票的收盘价格转化为收益率,并画出收益率直方图 海虹控股MATLAB命 令:TickSeries=31.63 32.17 31.58 30.71 30.77 30.93 31.79 31.58 3233.91 33.12 34.98 35.3 35.5 34.65 35.46 3

12、5.95 35.39 37.6736.64 36.77 36.85 36.59 35.81 35.18 35.76 36.66 38.35 38.2638.34 38.85 41.27 40.99 40.7 42.28'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天数');ylabel('收益率'); title('海虹控股对数收益率直方图');运行结果:RetSeries =0.0171-0.0183-0.02750.0020率 益 收海虹控股对数收益率直方图天数0.00520

13、.0278-0.00660.01330.0597-0.02330.05620.00910.0057-0.02390.02340.0138-0.01560.0644-0.02730.00350.0022-0.0071-0.0213-0.01760.01650.02520.0461-0.00230.00210.01330.0623-0.0068-0.00710.0388盛达矿业MATLAB命令:TickSeries=13.07 12.88 13.19 12.98 12.78 12.49 12.73 12.51 12.9713.06 12.68 13.17 13.93 14.39 14.08 14.

14、34 14.19 14.24 13.7413.57 13.813.76 13.76 13.52 13.313.28 13.44 13.37 13.2813.74 13.93 14.16 13.99 14.73 14.7'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天数);ylabel('收益率');title('盛达矿业对数收益率直方图');运行结果:RetSeries =-0.01450.02410.06-0.01590.05-0.01540.04-0.02270.01920.03-0

15、.01730.03680.0069率益收02-0.02910.03860.05770.0330-0.01-0.02-0.03-0.02150.01850510152025天数3035盛达矿业对数收益率直方图-0.04-0.01050.0035-0.0351-0.01240.0169-0.00290-0.0174-0.0163-0.00150.0120-0.0052-0.00670.03460.01380.0165-0.01200.0529-0.0020恒逸石化MATLAB命令:8.6 8.428.498.4 8.538.97TickSeries=9.43 9.148.998.678.919.1

16、19.129.069.149.048.798.7 8.788.839.479.3 9.559.899.699.649.589.529.8810.228.619.3710.310.45 10.84'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天数);ylabel('收益率'); title('恒逸石化对数收益率直方图);运行结果:RetSeries =-0.03080.08-0.0164-0.0356-0.0081-0.02090.0083-0.0106率益收0.0155-0.020.0516-0

17、.0401-0.040.03480.02240.0011-0.0605101520天数2530350.060.04恒逸石化对数 收益率 直方图020-0.00660.0088-0.0109-0.0277-0.01020.00920.00570.06120.0107-0.01800.02690.0356-0.0202-0.0052-0.0062-0.00630.03780.03440.00780.01460.0373金宇车城MATLAB命令:TickSeries=10.9 11.17 11.32 11.32 11.22 11.08 11.27 11.19 11.3111.52 11.25 11.

18、78 12.07 12.11 12.15 12.29 12.45 12.87 12.7712.63 12.56 12.71 12.71 12.512.15 12.23 12.12 12.48 12.612.87 12.913.33 13.513.513.42'RetSeries=tick2ret(TickSeries) bar(RetSeries)xlabel('天数);ylabel('收益率'); title('金宇车城对数收益率直方图);运行结果:RetSeries =0.02480.01340-0.0088-0.01250.0171-0.00710

19、.01070.0186-0.02340.04710.02460.00330.0033 0.0115 0.0130 0.0337-0.0078-0.0110-0.00550.0119 0 -0.0165 -0.02800.0066 -0.00900.02970.00960.02140.00230.03330.01280-0.0059(2)计算4种股票收盘价的协方差矩阵;MATLAB命 令:A=31.6313.07 9.4310.932.1712.889.1411.1731.5813.198.9911.3230.7112.988.6711.3230.7712.788.6 11.2230.9312.

20、498.4211.0831.7912.738.4911.2731.5812.518.4 11.1932 12.97 8.5311.3133.9113.068.9711.5233.1212.688.6111.2534.9813.178.9111.7835.313.939.1112.0735.514.399.1212.1134.6514.089.0612.1535.4614.349.1412.2935.9514.199.0412.4535.3914.248.7912.8737.6713.748.7 12.7736.6413.578.7812.6336.7713.88.8312.5636.8513.

21、769.3712.7136.5913.769.4712.7135.8113.529.3 12.535.1813.39.5512.1535.7613.289.8912.2336.6613.449.6912.1238.3513.379.6412.4838.2613.289.5812.638.3413.749.5212.8738.8513.939.8812.941.2714.1610.2213.3340.9913.9910.313.540.714.7310.4513.542.2814.710.8413.42cov(A)运行结果:ans =10.06081.47511.56872.30591.4751

22、0.37110.22700.38571.56870.22700.36820.33262.30590.38570.33260.5837(3) 若给出这4种股票预期收益率分别为0.3、0.25、0.2和0.15,且购买权重分别0.35、0. 25、0.25和0.15,求总资产的标准差和期望收益;MATLAB命令:ExpReturn=0.3,0.25,0.2,0.15;ExpCovaria nce= 10.06081.47511.56872.30591.4751 0.37110.22700.38571.5687 0.22700.36820.33262.3059 0.38570.33260.5837;

23、PortWts=0.35 0.25 0.25 0.15;PortRisk,PortReturn=portstats(ExpReturn, ExpCovaria nce,PortWts)运行结果:PortRisk =1.4659PortReturn =0.2400(4) 求该资产组合有效前沿(有效前沿的个数选为5);MATLAB命 令:ExpReturn=0.3 0.25 0.2 0.15;ExpCovaria nce=10.06081.47511.56872.30591.4751 0.37111.5687 0.22702.3059 0.3857NumPorts=5;0.22700.38570.

24、36820.33260.33260.5837PortR in k,PortRetur n,PortWts=fr ontcon (ExpReturn,ExpCovaria nce,NumPorts)运行结果:PortRi nk =0.5462 0.5820 1.17292.15853.1719PortReturn =0.22470.24360.2624 0.28120.3000PortWts =-0.0000 0.4949 0.50510.000000.87120.1288 -0.00000.24750.75250-0.00000.6237 0.37630-0.00001.0000 0 0.00

25、00 -0.00003,求考虑无风险(5) 无风险利率为0.35,借贷利率为0.5,投资者风险厌恶系数为资产及借贷情况下的最优资产配置。MATLAB命 令:ExpReturn=0.3 0.25 0.2 0.15;ExpCovaria nce=10.06081.47511.56872.30591.4751 0.37110.22700.38571.5687 0.22700.36820.33262.3059 0.38570.33260.5837;RisklessRate=0.035;BorrowRate=0.5;RiskAversio n=3;PortRisk,PortReturn,PortWts=

26、portopt(ExpReturn,ExpCovaria nee) RiskyRi nk, RiskyReturn, RiskyWts, RiskyFractio n,0 verallRick, OverallReturn=portalloc(PortRisk,.PortRetur n, PortWts, RisklessRate,BorrowRate, RiskAversio n) 运行结果:PortRisk =0.54620.55340.57470.60840.96631.38641.82462.27042.72003.1719PortReturn =0.22470.23310.24150

27、.24980.25820.26660.27490.28330.29160.3000PortWts =-0.00000.49490.50510.00000 10.6621 10.3379-0.00000.00000.82940.1706 -0.00000 10.9966 10.0034-0.00000.16380.83620-0.00000.33110.668900.00000.49830.50170-0.00000.66550.33450-0.00000.83280.167200.00001.0000 0 0.0000 -0.0000RiskyRi nk =0.5427RiskyReturn

28、=0.2302RiskyWts =-0.0000 0.6040 0.3960 -0.0000RiskyFract ion =0.2209OverallRick =0.1199OverallReturn =0.0781(6) 绘制这4种股票的最高价、最低价、收盘价和开盘价的烛型图。海虹控股MATLAB命令a=31.9 30.5431.6331.2932.35 30.7132.1731.332.631.5631.5832.0832 30.730.71 31.8231.59 30.45 30.77 30.5531.230 30.93 30.632.230.9431.7930.9432.1831.52

29、31.5831.7832.1131.4332 31.633.9131.9133.9132.135.5732.533.1232.8335.433.2634.9833.2635.5734.2835.334.9636.4935.135.535.335.834.4534.6535.335.634.635.4634.7536.3535.3335.9535.6636.2634.935.3935.737.935 37.67 35.0137.6636.4236.6437.338.2936.336.7736.6437.5836 36.85 37.337.3236.3536.5937.2536.8935.835.

30、8136.5936.4134.7535.1835.936.0335.1835.7635.437.22 35.536.66 35.738.5536.7238.3537.0538.6538.0838.2638.4439.1738.0338.3438.2539.238.0738.8538.541.4939.0841.2739.0842.3940.6840.9941.240.9940.0140.740.7542.640.5942.2840.69;can dle(a(:,1),a(:,2),a(:,3),a(:,4)can dle(a(:,1),a(:,2),a(:,3),a(:,4),'r&#

31、39;)title('海虹控股');运行结果:盛达矿业MATLAB命令:a=13.1112.08 13.07 12.212.9912.6512.8812.913.4912.8813.1912.9913.2712.8812.9813.113.112.7712.7812.9512.7712.4212.4912.712.812.4212.7312.4212.7712.3212.5112.7213.2212.512.9712.5113.3812.9513.0613.1513.2712.4612.6812.9813.2212.6513.1712.6814.1213.2213.9313.2

32、914.6513.714.3913.9514.84 14 14.08 14.3514.35 13.88 14.34 1414.3413.9214.1914.1514.314 14.24 14.114.213.713.7414.1413.7613.513.5713.513.913.413.813.514 13.71 13.76 13.7914.0113.7213.7613.813.9913.513.5213.9113.4713.213.313.313.4413.0313.2813.2713.4513.1813.4413.2513.5413.313.3713.4513.4113.0913.2813

33、.3313.7713.2913.7413.3414.0513.7213.9313.814.2313.8114.1613.9414.213.813.9914.0814.813.9314.7313.9314.9514.5614.714.78can dle(a(:,1),a(:,2),a(:,3),a(:,4)can dle(a(:,1),a(:,2),a(:,3),a(:,4),'r')title('盛达矿业');运行结果:恒逸石化MATLAB命令:a=9.6 8.759.439.049.649.1 9.149.359.168.868.999.089 8.658.678.998.858.588.6 8.588.858.388.428.638.548.3 8.498.438.578.348.4 8.510.35;'r')9.318.538.978.539.388.418.618.78.978.638.918.639.218.859.118.919.258.979.129.119.3 9.019.069.139.158.8 9.149.059.278.959.049.19.098.748.799.048.868.618.7 8.78.858.638.788.728.938.258.838.49.668.829.378.

温馨提示

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

最新文档

评论

0/150

提交评论