MATLAB金融計算試題_第1頁
MATLAB金融計算試題_第2頁
MATLAB金融計算試題_第3頁
MATLAB金融計算試題_第4頁
MATLAB金融計算試題_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、MATLAB金融計算試題(2014級研究生用)(上機操作使用)一、利率期限結構(20分) 已知國債面值是100美元,各期收益率為國債品種票息到期日當期收益3個月17-Apr-20131.156個月17-Jul-20131.182年1.7531-Dec-20141.685年3.0015-Nov-20172.9710年4.0015-Nov-20224.0130年5.37515-Feb-20414.92 試分析其利率期限結構。MATLAB命令: bonds=datenum('04/17/2013') 0 100; datenum('07/17/2013') 0 100

2、; datenum('12/31/2014') 0.0175 100; datenum('11/15/2017') 0.03 100; datenum('11/15/2022') 0.04 100; datenum('02/15/2041') 0.0537 100; yield=0.0115 0.0118 0.0168 0.0297 0.0401 0.0492' settle=datenum('01/17/2013'); %結算日 zerorates,curvedates=zbtyield(bonds,yi

3、eld,settle) datestr(curvedates) plot(zerorates)運行結果:zerorates = 0.0115 0.0118 0.0168 0.0302 0.0418 0.0550curvedates = 735341 735432 735964 737014 738840 745507ans =17-Apr-201317-Jul-201331-Dec-201415-Nov-201715-Nov-202215-Feb-2041二、期權定價(30分)若股票現在價格為$50,期權執(zhí)行價格為$52,無風險利率為0.1,股票波動標準差為0.4,期權的到期日為6個月,且若這

4、一賣權在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) 利用二項式期權定價(二叉樹(CRR)模型定價數值解)計算看漲看跌期權價格;MATLAB命令:price=50;strike=52;rate=0.1;tim

5、e=6/12;increment=1/12;volatility=0.4;flag=0;dividentrate=0;divident=2;exdiv=3.5;price,option=binprice(price,strike,rate,time,increment,volatility,flag,dividentrate,divident,exdiv)運行結果:得出二叉樹每個交點處的資產價格和期權價值.price = 50.0000 55.8985 62.5172 69.9441 76.2699 85.6054 96.0836 0 44.7755 50.0326 55.9315 60.54

6、20 67.9524 76.2699 0 0 40.1226 44.8084 48.0575 53.9398 60.5420 0 0 0 35.9790 38.1474 42.8167 48.0575 0 0 0 0 30.2809 33.9873 38.1474 0 0 0 0 0 26.9787 30.2809 0 0 0 0 0 0 24.0366option = 6.7016 3.9308 1.7652 0.4598 0 0 0 0 9.6686 6.2275 3.1393 0.9412 0 0 0 0 13.3762 9.5132 5.4560 1.9263 0 0 0 0 17.5

7、811 13.8526 9.1833 3.9425 0 0 0 0 21.7191 18.0127 13.8526 0 0 0 0 0 25.0213 21.7191 0 0 0 0 0 0 27.9634由結果可知,option第一行第一列就是看跌期權價格,該期權價格為6.7016元。MATLAB命令:price=50;strike=52;rate=0.1;time=6/12;increment=1/12;volatility=0.4;flag=1;dividentrate=0;divident=2;exdiv=3.5;price,option=binprice(price,strike,r

8、ate,time,increment,volatility,flag,dividentrate,divident,exdiv)運行結果:得出二叉樹每個交點處的資產價格和期權價值.price = 50.0000 55.8985 62.5172 69.9441 76.2699 85.6054 96.0836 0 44.7755 50.0326 55.9315 60.5420 67.9524 76.2699 0 0 40.1226 44.8084 48.0575 53.9398 60.5420 0 0 0 35.9790 38.1474 42.8167 48.0575 0 0 0 0 30.2809

9、 33.9873 38.1474 0 0 0 0 0 26.9787 30.2809 0 0 0 0 0 0 24.0366option = 4.9996 7.8792 12.0864 17.9441 25.1294 34.0369 44.0836 0 2.1193 3.6809 6.2599 10.3427 16.3840 24.2699 0 0 0.5473 1.0878 2.1622 4.2976 8.5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0由結果可知,option第一行第一列就是看漲期權價格,該期權價格為4

10、.9996元。 (3) 假設股票價格服從幾何布朗運動,試用蒙特卡洛模擬方法計算該期權價格。MATLAB命令:s0=50;K=52;r=0.1;T=0.5;sigma=0.4;Nu=1000;randn('seed',0); %定義隨機數發(fā)生器種子是0, %這樣保證每次模擬的結果相同nuT=(r-0.5*sigma2)*Tsit=sigma*sqrt(T)discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1)-K);%期權到期時的現金流eucall,varprice,ci=normfit(discpayoff)運行結果:nuT

11、= 0.0100sit = 0.2828eucall = 6.1478varprice = 10.2924ci = 5.5091 6.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 32 33.91 33.12 34.98 35.

12、3 35.5 34.65 35.46 35.95 35.39 37.67 36.64 36.77 36.85 36.59 35.81 35.18 35.76 36.66 38.35 38.26 38.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.0275 0.0020

13、0.0052 0.0278 -0.0066 0.0133 0.0597 -0.0233 0.0562 0.0091 0.0057 -0.0239 0.0234 0.0138 -0.0156 0.0644 -0.0273 0.0035 0.0022 -0.0071 -0.0213 -0.0176 0.0165 0.0252 0.0461 -0.0023 0.0021 0.0133 0.0623 -0.0068 -0.0071 0.0388盛達礦業(yè)MATLAB命令:TickSeries=13.07 12.88 13.19 12.98 12.78 12.49 12.73 12.51 12.97 13

14、.06 12.68 13.17 13.93 14.39 14.08 14.34 14.19 14.24 13.74 13.57 13.8 13.76 13.76 13.52 13.3 13.28 13.44 13.37 13.28 13.74 13.93 14.16 13.99 14.73 14.7'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天數');ylabel('收益率');title('盛達礦業(yè)對數收益率直方圖');運行結果:RetSeries = -0.0145 0.0

15、241 -0.0159 -0.0154 -0.0227 0.0192 -0.0173 0.0368 0.0069 -0.0291 0.0386 0.0577 0.0330 -0.0215 0.0185 -0.0105 0.0035 -0.0351 -0.0124 0.0169 -0.0029 0 -0.0174 -0.0163 -0.0015 0.0120 -0.0052 -0.0067 0.0346 0.0138 0.0165 -0.0120 0.0529 -0.0020恒逸石化MATLAB命令:TickSeries=9.43 9.14 8.99 8.67 8.6 8.42 8.49 8.4

16、 8.53 8.97 8.61 8.91 9.11 9.12 9.06 9.14 9.04 8.79 8.7 8.78 8.83 9.37 9.47 9.3 9.55 9.89 9.69 9.64 9.58 9.52 9.88 10.22 10.3 10.45 10.84'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天數');ylabel('收益率');title('恒逸石化對數收益率直方圖');運行結果:RetSeries = -0.0308 -0.0164 -0.0356 -

17、0.0081 -0.0209 0.0083 -0.0106 0.0155 0.0516 -0.0401 0.0348 0.0224 0.0011 -0.0066 0.0088 -0.0109 -0.0277 -0.0102 0.0092 0.0057 0.0612 0.0107 -0.0180 0.0269 0.0356 -0.0202 -0.0052 -0.0062 -0.0063 0.0378 0.0344 0.0078 0.0146 0.0373金宇車城MATLAB命令:TickSeries=10.9 11.17 11.32 11.32 11.22 11.08 11.27 11.19 1

18、1.31 11.52 11.25 11.78 12.07 12.11 12.15 12.29 12.45 12.87 12.77 12.63 12.56 12.71 12.71 12.5 12.15 12.23 12.12 12.48 12.6 12.87 12.9 13.33 13.5 13.5 13.42'RetSeries=tick2ret(TickSeries)bar(RetSeries)xlabel('天數');ylabel('收益率');title('金宇車城對數收益率直方圖');運行結果:RetSeries = 0.0248

19、 0.0134 0 -0.0088 -0.0125 0.0171 -0.0071 0.0107 0.0186 -0.0234 0.0471 0.0246 0.0033 0.0033 0.0115 0.0130 0.0337 -0.0078 -0.0110 -0.0055 0.0119 0 -0.0165 -0.0280 0.0066 -0.0090 0.0297 0.0096 0.0214 0.0023 0.0333 0.0128 0 -0.0059(2) 計算4種股票收盤價的協方差矩陣;MATLAB命令:A=31.63 13.07 9.43 10.932.17 12.88 9.14 11.1

20、731.58 13.19 8.99 11.3230.71 12.98 8.67 11.3230.77 12.78 8.6 11.2230.93 12.49 8.42 11.0831.79 12.73 8.49 11.2731.58 12.51 8.4 11.1932 12.97 8.53 11.3133.91 13.06 8.97 11.5233.12 12.68 8.61 11.2534.98 13.17 8.91 11.7835.3 13.93 9.11 12.0735.5 14.39 9.12 12.1134.65 14.08 9.06 12.1535.46 14.34 9.14 12.

21、2935.95 14.19 9.04 12.4535.39 14.24 8.79 12.8737.67 13.74 8.7 12.7736.64 13.57 8.78 12.6336.77 13.8 8.83 12.5636.85 13.76 9.37 12.7136.59 13.76 9.47 12.7135.81 13.52 9.3 12.535.18 13.3 9.55 12.1535.76 13.28 9.89 12.2336.66 13.44 9.69 12.1238.35 13.37 9.64 12.4838.26 13.28 9.58 12.638.34 13.74 9.52 1

22、2.8738.85 13.93 9.88 12.941.27 14.16 10.22 13.3340.99 13.99 10.3 13.540.7 14.73 10.45 13.542.28 14.7 10.84 13.42cov(A)運行結果:ans = 10.0608 1.4751 1.5687 2.3059 1.4751 0.3711 0.2270 0.3857 1.5687 0.2270 0.3682 0.3326 2.3059 0.3857 0.3326 0.5837(3) 若給出這4種股票預期收益率分別為0.3、0.25、0.2和0.15,且購買權重分別0.35、0. 25、0.2

23、5和0.15,求總資產的標準差和期望收益;MATLAB命令:ExpReturn=0.3,0.25,0.2,0.15;ExpCovariance= 10.0608 1.4751 1.5687 2.3059 1.4751 0.3711 0.2270 0.3857 1.5687 0.2270 0.3682 0.3326 2.3059 0.3857 0.3326 0.5837;PortWts=0.35 0.25 0.25 0.15;PortRisk,PortReturn=portstats(ExpReturn, ExpCovariance,PortWts)運行結果:PortRisk = 1.4659P

24、ortReturn = 0.2400(4) 求該資產組合有效前沿(有效前沿的個數選為5);MATLAB命令:ExpReturn=0.3 0.25 0.2 0.15;ExpCovariance=10.0608 1.4751 1.5687 2.3059 1.4751 0.3711 0.2270 0.3857 1.5687 0.2270 0.3682 0.3326 2.3059 0.3857 0.3326 0.5837;NumPorts=5;PortRink,PortReturn,PortWts=frontcon(ExpReturn,ExpCovariance,NumPorts)運行結果:PortR

25、ink = 0.5462 0.5820 1.1729 2.1585 3.1719PortReturn = 0.2247 0.2436 0.2624 0.2812 0.3000PortWts = -0.0000 0.4949 0.5051 0.0000 0 0.8712 0.1288 -0.0000 0.2475 0.7525 0 -0.0000 0.6237 0.3763 0 -0.0000 1.0000 0 0.0000 -0.0000(5) 無風險利率為0.35,借貸利率為0.5,投資者風險厭惡系數為3,求考慮無風險資產及借貸情況下的最優(yōu)資產配置。MATLAB命令:ExpReturn=0.

26、3 0.25 0.2 0.15;ExpCovariance=10.0608 1.4751 1.5687 2.3059 1.4751 0.3711 0.2270 0.3857 1.5687 0.2270 0.3682 0.3326 2.3059 0.3857 0.3326 0.5837;RisklessRate=0.035;BorrowRate=0.5;RiskAversion=3;PortRisk,PortReturn,PortWts=portopt(ExpReturn,ExpCovariance)RiskyRink, RiskyReturn, RiskyWts, RiskyFraction,

27、OverallRick, OverallReturn=portalloc(PortRisk,.PortReturn, PortWts, RisklessRate,BorrowRate, RiskAversion)運行結果:PortRisk = 0.5462 0.5534 0.5747 0.6084 0.9663 1.3864 1.8246 2.2704 2.7200 3.1719PortReturn = 0.2247 0.2331 0.2415 0.2498 0.2582 0.2666 0.2749 0.2833 0.2916 0.3000PortWts = -0.0000 0.4949 0.

28、5051 0.0000 0 0.6621 0.3379 -0.0000 0.0000 0.8294 0.1706 -0.0000 0 0.9966 0.0034 -0.0000 0.1638 0.8362 0 -0.0000 0.3311 0.6689 0 0.0000 0.4983 0.5017 0 -0.0000 0.6655 0.3345 0 -0.0000 0.8328 0.1672 0 0.0000 1.0000 0 0.0000 -0.0000RiskyRink = 0.5427RiskyReturn = 0.2302RiskyWts = -0.0000 0.6040 0.3960

29、 -0.0000RiskyFraction = 0.2209OverallRick = 0.1199OverallReturn = 0.0781(6)繪制這4種股票的最高價、最低價、收盤價和開盤價的燭型圖。海虹控股MATLAB命令:a=31.9 30.54 31.63 31.2932.35 30.71 32.17 31.332.6 31.56 31.58 32.0832 30.7 30.71 31.8231.59 30.45 30.77 30.5531.2 30 30.93 30.632.2 30.94 31.79 30.9432.18 31.52 31.58 31.7832.11 31.43

30、 32 31.633.91 31.91 33.91 32.135.57 32.5 33.12 32.8335.4 33.26 34.98 33.2635.57 34.28 35.3 34.9636.49 35.1 35.5 35.335.8 34.45 34.65 35.335.6 34.6 35.46 34.7536.35 35.33 35.95 35.6636.26 34.9 35.39 35.737.9 35 37.67 35.0137.66 36.42 36.64 37.338.29 36.3 36.77 36.6437.58 36 36.85 37.337.32 36.35 36.5

31、9 37.2536.89 35.8 35.81 36.5936.41 34.75 35.18 35.936.03 35.18 35.76 35.437.22 35.5 36.66 35.738.55 36.72 38.35 37.0538.65 38.08 38.26 38.4439.17 38.03 38.34 38.2539.2 38.07 38.85 38.541.49 39.08 41.27 39.0842.39 40.68 40.99 41.240.99 40.01 40.7 40.7542.6 40.59 42.28 40.69;candle(a(:,1),a(:,2),a(:,3

32、),a(:,4)candle(a(:,1),a(:,2),a(:,3),a(:,4),'r')title('海虹控股');運行結果:盛達礦業(yè)MATLAB命令:a=13.11 12.08 13.07 12.212.99 12.65 12.88 12.913.49 12.88 13.19 12.9913.27 12.88 12.98 13.113.1 12.77 12.78 12.9512.77 12.42 12.49 12.712.8 12.42 12.73 12.4212.77 12.32 12.51 12.7213.22 12.5 12.97 12.5113.

33、38 12.95 13.06 13.1513.27 12.46 12.68 12.9813.22 12.65 13.17 12.6814.12 13.22 13.93 13.2914.65 13.7 14.39 13.9514.84 14 14.08 14.3514.35 13.88 14.34 1414.34 13.92 14.19 14.1514.3 14 14.24 14.114.2 13.7 13.74 14.1413.76 13.5 13.57 13.513.9 13.4 13.8 13.514 13.71 13.76 13.7914.01 13.72 13.76 13.813.99

34、 13.5 13.52 13.9113.47 13.2 13.3 13.313.44 13.03 13.28 13.2713.45 13.18 13.44 13.2513.54 13.3 13.37 13.4513.41 13.09 13.28 13.3313.77 13.29 13.74 13.3414.05 13.72 13.93 13.814.23 13.81 14.16 13.9414.2 13.8 13.99 14.0814.8 13.93 14.73 13.9314.95 14.56 14.7 14.78;candle(a(:,1),a(:,2),a(:,3),a(:,4)cand

35、le(a(:,1),a(:,2),a(:,3),a(:,4),'r')title('盛達礦業(yè)');運行結果:恒逸石化MATLAB命令:a=9.6 8.75 9.43 9.049.64 9.1 9.14 9.359.16 8.86 8.99 9.089 8.65 8.67 8.998.85 8.58 8.6 8.588.85 8.38 8.42 8.638.54 8.3 8.49 8.438.57 8.34 8.4 8.58.57 8.4 8.53 8.429.31 8.53 8.97 8.539.38 8.41 8.61 8.78.97 8.63 8.91 8.639.21 8.85 9.11 8.919.25 8.97 9.12 9.119.3 9.01 9.06 9.139.15 8.8 9.14 9.059.27 8.95 9.04 9.19.09 8.74 8.79 9.048.86 8.61 8.7 8.78.85 8.63 8.78 8.728.93 8.25 8.83 8.49.66 8.82 9.37 8.8210.2 9.46 9.47 9.589.9 9.28 9.3 9.479.75 9.25 9.55 9.310.19 9.37 9.89 9.4

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論