MATLAB金融计算试题.docx

上传人:b****4 文档编号:24485474 上传时间:2023-05-28 格式:DOCX 页数:27 大小:58.09KB
下载 相关 举报
MATLAB金融计算试题.docx_第1页
第1页 / 共27页
MATLAB金融计算试题.docx_第2页
第2页 / 共27页
MATLAB金融计算试题.docx_第3页
第3页 / 共27页
MATLAB金融计算试题.docx_第4页
第4页 / 共27页
MATLAB金融计算试题.docx_第5页
第5页 / 共27页
点击查看更多>>
下载资源
资源描述

MATLAB金融计算试题.docx

《MATLAB金融计算试题.docx》由会员分享,可在线阅读,更多相关《MATLAB金融计算试题.docx(27页珍藏版)》请在冰豆网上搜索。

MATLAB金融计算试题.docx

MATLAB金融计算试题

MATLAB金融计算试题(2014级研究生用)

(上机操作使用)

一、利率期限结构(20分)

已知国债面值是100美元,各期收益率为

国债品种

票息

到期日

当期收益

3个月

17-Apr-2013

1.15

6个月

17-Jul-2013

1.18

2年

1.75

31-Dec-2014

1.68

5年

3.00

15-Nov-2017

2.97

10年

4.00

15-Nov-2022

4.01

30年

5.375

15-Feb-2041

4.92

试分析其利率期限结构。

MATLAB命令:

bonds=[datenum('04/17/2013')0100;

datenum('07/17/2013')0100;

datenum('12/31/2014')0.0175100;

datenum('11/15/2017')0.03100;

datenum('11/15/2022')0.04100;

datenum('02/15/2041')0.0537100];

yield=[0.01150.01180.01680.02970.04010.0492]';

settle=datenum('01/17/2013');%结算日

[zerorates,curvedates]=zbtyield(bonds,yield,settle)

datestr(curvedates)

plot(zerorates)

运行结果:

zerorates=

0.0115

0.0118

0.0168

0.0302

0.0418

0.0550

curvedates=

735341

735432

735964

737014

738840

745507

ans=

17-Apr-2013

17-Jul-2013

31-Dec-2014

15-Nov-2017

15-Nov-2022

15-Feb-2041

二、期权定价(30分)

若股票现在价格为$50,期权执行价格为$52,无风险利率为0.1,股票波动标准差为0.4,期权的到期日为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.8651

putprice=

5.3290

(2)利用二项式期权定价(二叉树(CRR)模型定价数值解)计算看涨看跌期权价格;

MATLAB命令:

price=50;

strike=52;

rate=0.1;

time=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.000055.898562.517269.944176.269985.605496.0836

044.775550.032655.931560.542067.952476.2699

0040.122644.808448.057553.939860.5420

00035.979038.147442.816748.0575

000030.280933.987338.1474

0000026.978730.2809

00000024.0366

option=

6.70163.93081.76520.4598000

09.66866.22753.13930.941200

0013.37629.51325.45601.92630

00017.581113.85269.18333.9425

000021.719118.012713.8526

0000025.021321.7191

00000027.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,rate,time,increment,volatility,flag,dividentrate,divident,exdiv)

运行结果:

得出二叉树每个交点处的资产价格和期权价值.

price=

50.000055.898562.517269.944176.269985.605496.0836

044.775550.032655.931560.542067.952476.2699

0040.122644.808448.057553.939860.5420

00035.979038.147442.816748.0575

000030.280933.987338.1474

0000026.978730.2809

00000024.0366

option=

4.99967.879212.086417.944125.129434.036944.0836

02.11933.68096.259910.342716.384024.2699

000.54731.08782.16224.29768.5420

0000000

0000000

0000000

0000000

由结果可知,option第一行第一列就是看涨期权价格,该期权价格为4.9996元。

(3)假设股票价格服从几何布朗运动,试用蒙特卡洛模拟方法计算该期权价格。

MATLAB命令:

s0=50;

K=52;

r=0.1;

T=0.5;

sigma=0.4;

Nu=1000;

randn('seed',0);%定义随机数发生器种子是0,

%这样保证每次模拟的结果相同

nuT=(r-0.5*sigma^2)*T

sit=sigma*sqrt(T)

discpayoff=exp(-r*T)*max(0,s0*exp(nuT+sit*randn(Nu,1))-K);%期权到期时的现金流

[eucall,varprice,ci]=normfit(discpayoff)

运行结果:

nuT=

0.0100

sit=

0.2828

eucall=

6.1478

varprice=

10.2924

ci=

5.5091

6.7865

三、搜集数据并计算画图(50分)

按照自己的研究生学号后两位数,在锐思金融数据库中搜集4种股票信息,包括最高价、最低价、收盘价和开盘价,数据个数2个月左右,建立数据表格。

要求使用MATLAB编程解决以下问题:

(1)将4种股票的收盘价格转化为收益率,并画出收益率直方图

海虹控股

MATLAB命令:

TickSeries=[31.6332.1731.5830.7130.7730.9331.7931.583233.9133.1234.9835.335.534.6535.4635.9535.3937.6736.6436.7736.8536.5935.8135.1835.7636.6638.3538.2638.3438.8541.2740.9940.742.28]';

RetSeries=tick2ret(TickSeries)

bar(RetSeries)

xlabel('天数');ylabel('收益率');

title('海虹控股对数收益率直方图');

运行结果:

RetSeries=

0.0171

-0.0183

-0.0275

0.0020

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

盛达矿业

MATLAB命令:

TickSeries=[13.0712.8813.1912.9812.7812.4912.7312.5112.9713.0612.6813.1713.9314.3914.0814.3414.1914.2413.7413.5713.813.7613.7613.5213.313.2813.4413.3713.2813.7413.9314.1613.9914.7314.7]';

RetSeries=tick2ret(TickSeries)

bar(RetSeries)

xlabel('天数');ylabel('收益率');

title('盛达矿业对数收益率直方图');

运行结果:

RetSeries=

-0.0145

0.0241

-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.439.148.998.678.68.428.498.48.538.978.618.919.119.129.069.149.048.798.78.788.839.379.479.39.559.899.699.649.589.529.8810.2210.310.4510.84]';

RetSeries=tick2ret(TickSeries)

bar(RetSeries)

xlabel('天数');ylabel('收益率');

title('恒逸石化对数收益率直方图');

运行结果:

RetSeries=

-0.0308

-0.0164

-0.0356

-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.911.1711.3211.3211.2211.0811.2711.1911.3111.5211.2511.7812.0712.1112.1512.2912.4512.8712.7712.6312.5612.7112.7112.512.1512.2312.1212.4812.612.8712.913.3313.513.513.42]';

RetSeries=tick2ret(TickSeries)

bar(RetSeries)

xlabel('天数');ylabel('收益率');

title('金宇车城对数收益率直方图');

运行结果:

RetSeries=

0.0248

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.6313.079.4310.9

32.1712.889.1411.17

31.5813.198.9911.32

30.7112.988.6711.32

30.7712.788.611.22

30.9312.498.4211.08

31.7912.738.4911.27

31.5812.518.411.19

3212.978.5311.31

33.9113.068.9711.52

33.1212.688.6111.25

34.9813.178.9111.78

35.313.939.1112.07

35.514.399.1212.11

34.6514.089.0612.15

35.4614.349.1412.29

35.9514.199.0412.45

35.3914.248.7912.87

37.6713.748.712.77

36.6413.578.7812.63

36.7713.88.8312.56

36.8513.769.3712.71

36.5913.769.4712.71

35.8113.529.312.5

35.1813.39.5512.15

35.7613.289.8912.23

36.6613.449.6912.12

38.3513.379.6412.48

38.2613.289.5812.6

38.3413.749.5212.87

38.8513.939.8812.9

41.2714.1610.2213.33

40.9913.9910.313.5

40.714.7310.4513.5

42.2814.710.8413.42]

cov(A)

运行结果:

ans=

10.06081.47511.56872.3059

1.47510.37110.22700.3857

1.56870.22700.36820.3326

2.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];

ExpCovariance=[10.06081.47511.56872.3059

1.47510.37110.22700.3857

1.56870.22700.36820.3326

2.30590.38570.33260.5837];

PortWts=[0.350.250.250.15];

[PortRisk,PortReturn]=portstats(ExpReturn,ExpCovariance,PortWts)

运行结果:

PortRisk=

1.4659

PortReturn=

0.2400

(4)求该资产组合有效前沿(有效前沿的个数选为5);

MATLAB命令:

ExpReturn=[0.30.250.20.15];

ExpCovariance=[10.06081.47511.56872.3059

1.47510.37110.22700.3857

1.56870.22700.36820.3326

2.30590.38570.33260.5837];

NumPorts=5;

[PortRink,PortReturn,PortWts]=frontcon(ExpReturn,ExpCovariance,NumPorts)

运行结果:

PortRink=

0.5462

0.5820

1.1729

2.1585

3.1719

PortReturn=

0.2247

0.2436

0.2624

0.2812

0.3000

PortWts=

-0.00000.49490.50510.0000

00.87120.1288-0.0000

0.24750.75250-0.0000

0.62370.37630-0.0000

1.000000.0000-0.0000

(5)无风险利率为0.35,借贷利率为0.5,投资者风险厌恶系数为3,求考虑无风险资产及借贷情况下的最优资产配置。

MATLAB命令:

ExpReturn=[0.30.250.20.15];

ExpCovariance=[10.06081.47511.56872.3059

1.47510.37110.22700.3857

1.56870.22700.36820.3326

2.30590.38570.33260.5837];

RisklessRate=0.035;

BorrowRate=0.5;

RiskAversion=3;

[PortRisk,PortReturn,PortWts]=portopt(ExpReturn,ExpCovariance)

[RiskyRink,RiskyReturn,RiskyWts,RiskyFraction,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.1719

PortReturn=

0.2247

0.2331

0.2415

0.2498

0.2582

0.2666

0.2749

0.2833

0.2916

0.3000

PortWts=

-0.00000.49490.50510.0000

00.66210.3379-0.0000

0.00000.82940.1706-0.0000

00.99660.0034-0.0000

0.16380.83620-0.0000

0.33110.668900.0000

0.49830.50170-0.0000

0.66550.33450-0.0000

0.83280.167200.0000

1.000000.0000-0.0000

RiskyRink=

0.5427

RiskyReturn=

0.2302

RiskyWts=

-0.00000.60400.3960-0.0000

RiskyFraction=

0.2209

OverallRick=

0.1199

OverallReturn=

0.0781

(6)绘制这4种股票的最高价、最低价、收盘价和开盘价的烛型图。

海虹控股

MATLAB命令:

a=[31.930.5431.6331.29

32.3530.7132.1731.3

32.631.5631.5832.08

3230.730.7131.82

31.5930.4530.7730.55

31.23030.9330.6

32.230.9431.7930.94

32.1831.5231.5831.78

32.1131.433231.6

33.9131.9133.9132.1

35.5732.533.1232.83

35.433.2634.9833.26

35.5734.2835.334.96

36.4935.135.535.3

35.834.4534.6535.3

35.634.635.4634.75

36.3535.3335.9535.66

36.2634.935.3935.7

37.93537.6735.01

37.6636.4236.6437.3

38.2936.336.7736.64

37.583636.8537.3

37.3236.3536.5937.25

36.8935.835.8136.59

36.4134.7535.1835

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 人文社科 > 文化宗教

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1