金融计算实验作业答案.docx
- 文档编号:5953767
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:30
- 大小:77.13KB
金融计算实验作业答案.docx
《金融计算实验作业答案.docx》由会员分享,可在线阅读,更多相关《金融计算实验作业答案.docx(30页珍藏版)》请在冰豆网上搜索。
金融计算实验作业答案
1.命令:
typebank.txt
t0=ascii2fts('bank.txt',1,1,1)
t0=t0.CLOSE
typeindex.txt
x0=ascii2fts('index.txt',1,1,1)
divdata=[0.5;0.5]
divdates={'24-Feb-15';'30-Apr-15'}
d0=fints(divdates,divdata,{'dividends'},'u','Inc')
dadj1=d0
dadj1.dates=dadj1.dates-1
dadj2=d0
dadj2.dividends=0
dadj2=fillts(dadj2,'linear','31-Dec-14')
dadj2('31-Dec-14')=0
dadj3=[dadj1;dadj2]
dadj3=fillts(dadj3,'linear',t0.dates)
t0.Spot=t0.CLOSE-fts2mat(dadj3(datestr(t0.dates)))
tret=(t0.Spot-lagts(t0.Spot,1))/lagts(t0.Spot,1)
tret=chfield(tret,'Spot','Return')
x0.Const=1
dcommon=intersect(tret.dates,x0.dates)
regts0=[tret(datestr(dcommon)),x0(datestr(dcommon))]
finte_regts0=find(all(isfinite(fts2mat(regts0)),2))
regts1=regts0(finte_regts0)
DataMartix=fts2mat(regts1)
XCoeff=DataMartix(:
2:
3)\DataMartix(:
1)
RetPred=DataMartix(:
2:
3)*XCoeff
tret.PrecReturn(datestr(regts1.dates))=RetPred
subplot(2,1,1);plot(t0);title('股票即期价格和收盘价格')
subplot(2,1,2);plot(tret);title('股票的实际和预测的收益率')
datestr(d0.dates,2)
t0(datestr(d0.dates))
tdr=d0./fts2mat(t0.CLOSE(datestr(d0.dates)))
2.运行结果:
typebank.txt
t0=ascii2fts('bank.txt',1,1,1)
t0=t0.CLOSE
t0=
desc:
DATECLOSEHIGHLOWOPENVOLUMETURNOVER
freq:
Unknown(0)
'dates:
(78)''CLOSE:
(78)'
'05-Jan-2015'[4.4200]
'06-Jan-2015'[4.5600]
'07-Jan-2015'[4.5400]
'08-Jan-2015'[4.3300]
'09-Jan-2015'[4.4700]
'12-Jan-2015'[4.4000]
'13-Jan-2015'[4.4400]
'14-Jan-2015'[4.5900]
'15-Jan-2015'[4.8700]
'16-Jan-2015'[4.9800]
'19-Jan-2015'[4.4800]
'20-Jan-2015'[4.4500]
'21-Jan-2015'[4.8900]
'22-Jan-2015'[4.8400]
'23-Jan-2015'[4.8400]
'26-Jan-2015'[4.7800]
'27-Jan-2015'[4.6300]
'28-Jan-2015'[4.5500]
'29-Jan-2015'[4.4000]
'30-Jan-2015'[4.4000]
'02-Feb-2015'[4.1300]
'03-Feb-2015'[4.2800]
'04-Feb-2015'[4.1300]
'05-Feb-2015'[4.1300]
'06-Feb-2015'[4.0100]
'09-Feb-2015'[4.0300]
'10-Feb-2015'[4.1000]
'11-Feb-2015'[4.0700]
'12-Feb-2015'[4.0600]
'13-Feb-2015'[4.1100]
'16-Feb-2015'[4.0900]
'17-Feb-2015'[4.1000]
'25-Feb-2015'[4.0500]
'26-Feb-2015'[4.1400]
'27-Feb-2015'[4.1100]
'02-Mar-2015'[4.1100]
'03-Mar-2015'[3.9700]
'04-Mar-2015'[3.9100]
'05-Mar-2015'[3.8000]
'06-Mar-2015'[3.8300]
'09-Mar-2015'[4.0300]
'10-Mar-2015'[3.9300]
'11-Mar-2015'[4.0100]
'12-Mar-2015'[4.1800]
'13-Mar-2015'[4.1500]
'16-Mar-2015'[4.1800]
'17-Mar-2015'[4.2100]
'18-Mar-2015'[4.3300]
'19-Mar-2015'[4.2700]
'20-Mar-2015'[4.3800]
'23-Mar-2015'[4.4300]
'24-Mar-2015'[4.4400]
'25-Mar-2015'[4.3000]
'26-Mar-2015'[4.3100]
'27-Mar-2015'[4.3200]
'30-Mar-2015'[4.4600]
'31-Mar-2015'[4.3800]
'01-Apr-2015'[4.4100]
'02-Apr-2015'[4.3600]
'03-Apr-2015'[4.3700]
'07-Apr-2015'[4.4700]
'08-Apr-2015'[4.5300]
'09-Apr-2015'[4.4900]
'10-Apr-2015'[4.5600]
'13-Apr-2015'[4.6800]
'14-Apr-2015'[4.6300]
'15-Apr-2015'[4.7100]
'16-Apr-2015'[4.8000]
'17-Apr-2015'[4.9300]
'20-Apr-2015'[4.7400]
'21-Apr-2015'[4.7800]
'22-Apr-2015'[4.8600]
'23-Apr-2015'[4.8000]
'24-Apr-2015'[4.6600]
'27-Apr-2015'[5.0600]
'28-Apr-2015'[5.0600]
'29-Apr-2015'[4.9700]
'30-Apr-2015'[4.8400]
typeindex.txt
x0=ascii2fts('index.txt',1,1,1)
x0=
desc:
DATEMetric
freq:
Unknown(0)
'dates:
(78)''Metric:
(78)'
'05-Jan-2015'[3.3505e+03]
'06-Jan-2015'[3.3514e+03]
'07-Jan-2015'[3.3739e+03]
'08-Jan-2015'[3.2935e+03]
'09-Jan-2015'[3.2854e+03]
'12-Jan-2015'[3.2293e+03]
'13-Jan-2015'[3.2353e+03]
'14-Jan-2015'[3.2224e+03]
'15-Jan-2015'[3.3365e+03]
'16-Jan-2015'[3.3765e+03]
'19-Jan-2015'[3.1163e+03]
'20-Jan-2015'[3.1731e+03]
'21-Jan-2015'[3.3236e+03]
'22-Jan-2015'[3.3433e+03]
'23-Jan-2015'[3.3518e+03]
'26-Jan-2015'[3.3832e+03]
'27-Jan-2015'[3.3530e+03]
'28-Jan-2015'[3.3057e+03]
'29-Jan-2015'[3.2623e+03]
'30-Jan-2015'[3.2104e+03]
'02-Feb-2015'[3.1283e+03]
'03-Feb-2015'[3.2049e+03]
'04-Feb-2015'[3.1741e+03]
'05-Feb-2015'[3.1365e+03]
'06-Feb-2015'[3.0759e+03]
'09-Feb-2015'[3.0951e+03]
'10-Feb-2015'[3.1416e+03]
'11-Feb-2015'[3.1577e+03]
'12-Feb-2015'[3.1734e+03]
'13-Feb-2015'[3.2038e+03]
'16-Feb-2015'[3.2224e+03]
'17-Feb-2015'[3.2469e+03]
'25-Feb-2015'[3.2288e+03]
'26-Feb-2015'[3.2984e+03]
'27-Feb-2015'[3.3103e+03]
'02-Mar-2015'[3.3363e+03]
'03-Mar-2015'[3.2631e+03]
'04-Mar-2015'[3.2795e+03]
'05-Mar-2015'[3.2485e+03]
'06-Mar-2015'[3.2412e+03]
'09-Mar-2015'[3.3024e+03]
'10-Mar-2015'[3.2861e+03]
'11-Mar-2015'[3.2909e+03]
'12-Mar-2015'[3.3493e+03]
'13-Mar-2015'[3.3729e+03]
'16-Mar-2015'[3.4493e+03]
'17-Mar-2015'[3.5028e+03]
'18-Mar-2015'[3.5773e+03]
'19-Mar-2015'[3.5823e+03]
'20-Mar-2015'[3.6173e+03]
'23-Mar-2015'[3.6877e+03]
'24-Mar-2015'[3.6914e+03]
'25-Mar-2015'[3.6607e+03]
'26-Mar-2015'[3.6821e+03]
'27-Mar-2015'[3.6911e+03]
'30-Mar-2015'[3.7866e+03]
'31-Mar-2015'[3.7479e+03]
'01-Apr-2015'[3.8103e+03]
'02-Apr-2015'[3.8258e+03]
'03-Apr-2015'[3.8639e+03]
'07-Apr-2015'[3.9614e+03]
'08-Apr-2015'[3.9948e+03]
'09-Apr-2015'[3.9575e+03]
'10-Apr-2015'[4.0343e+03]
'13-Apr-2015'[4.1217e+03]
'14-Apr-2015'[4.1356e+03]
'15-Apr-2015'[4.0842e+03]
'16-Apr-2015'[4.1948e+03]
'17-Apr-2015'[4.2873e+03]
'20-Apr-2015'[4.2171e+03]
'21-Apr-2015'[4.2936e+03]
'22-Apr-2015'[4.3985e+03]
'23-Apr-2015'[4.4145e+03]
'24-Apr-2015'[4.3937e+03]
'27-Apr-2015'[4.5274e+03]
'28-Apr-2015'[4.4762e+03]
'29-Apr-2015'[4.4766e+03]
'30-Apr-2015'[4.4417e+03]
divdata=[0.5;0.5]
divdates={'24-Feb-15';'30-Apr-15'}
d0=fints(divdates,divdata,{'dividends'},'u','Inc')
d0=
desc:
Inc
freq:
Unknown(0)
'dates:
(2)''dividends:
(2)'
'24-Feb-2015'[0.5000]
'30-Apr-2015'[0.5000]
dadj1=d0
dadj1.dates=dadj1.dates-1
dadj2=d0
dadj2.dividends=0
dadj2=fillts(dadj2,'linear','31-Dec-14')dadj2('31-Dec-14')=0
dadj3=[dadj1;dadj2]
dadj3=fillts(dadj3,'linear',t0.dates)
dadj3=
desc:
FilledInc||FilledInc
freq:
Unknown(0)
'dates:
(81)''dividends:
(81)'
'31-Dec-2014'[0]
'23-Feb-2015'[0.5000]
'24-Feb-2015'[0]
'29-Apr-2015'[0.5000]
'30-Apr-2015'[0]
'05-Jan-2015'[0.0463]
'06-Jan-2015'[0.0556]
'07-Jan-2015'[0.0648]
'08-Jan-2015'[0.0741]
'09-Jan-2015'[0.0833]
'12-Jan-2015'[0.1111]
'13-Jan-2015'[0.1204]
'14-Jan-2015'[0.1296]
'15-Jan-2015'[0.1389]
'16-Jan-2015'[0.1481]
'19-Jan-2015'[0.1759]
'20-Jan-2015'[0.1852]
'21-Jan-2015'[0.1944]
'22-Jan-2015'[0.2037]
'23-Jan-2015'[0.2130]
'26-Jan-2015'[0.2407]
'27-Jan-2015'[0.2500]
'28-Jan-2015'[0.2593]
'29-Jan-2015'[0.2685]
'30-Jan-2015'[0.2778]
'02-Feb-2015'[0.3056]
'03-Feb-2015'[0.3148]
'04-Feb-2015'[0.3241]
'05-Feb-2015'[0.3333]
'06-Feb-2015'[0.3426]
'09-Feb-2015'[0.3704]
'10-Feb-2015'[0.3796]
'11-Feb-2015'[0.3889]
'12-Feb-2015'[0.3981]
'13-Feb-2015'[0.4074]
'16-Feb-2015'[0.4352]
'17-Feb-2015'[0.4444]
'25-Feb-2015'[0.0078]
'26-Feb-2015'[0.0156]
'27-Feb-2015'[0.0234]
'02-Mar-2015'[0.0469]
'03-Mar-2015'[0.0547]
'04-Mar-2015'[0.0625]
'05-Mar-2015'[0.0703]
'06-Mar-2015'[0.0781]
'09-Mar-2015'[0.1016]
'10-Mar-2015'[0.1094]
'11-Mar-2015'[0.1172]
'12-Mar-2015'[0.1250]
'13-Mar-2015'[0.1328]
'16-Mar-2015'[0.1563]
'17-Mar-2015'[0.1641]
'18-Mar-2015'[0.1719]
'19-Mar-2015'[0.1797]
'20-Mar-2015'[0.1875]
'23-Mar-2015'[0.2109]
'24-Mar-2015'[0.2188]
'25-Mar-2015'[0.2266]
'26-Mar-2015'[0.2344]
'27-Mar-2015'[0.2422]
'30-Mar-2015'[0.2656]
'31-Mar-2015'[0.2734]
'01-Apr-2015'[0.2813]
'02-Apr-2015'[0.2891]
'03-Apr-2015'[0.2969]
'07-Apr-2015'[0.3281]
'08-Apr-2015'[0.3359]
'09-Apr-2015'[0.3438]
'10-Apr-2015'[0.3516]
'13-Apr-2015'[0.3750]
'14-Apr-2015'[0.3828]
'15-Apr-2015'[0.3906]
'16-Apr-2015'[0.3984]
'17-Apr-2015'[0.4063]
'20-Apr-2015'[0.4297]
'21-Apr-2015'[0.4375]
'22-Apr-2015'[0.4453]
'23-Apr-2015'[0.4531]
'24-Apr-2015'[0.4609]
'27-Apr-2015'[0.4844]
'28-Apr-2015'[0.4922]
t0.Spot=t0.CLOSE-fts2mat(dadj3(datestr(t0.dates)))
t0=
desc:
DATECLOSEHIGHLOWOPENVOLUMETURNOVER
freq:
Unknown(0)
'dates:
(78)''CLOSE:
(78)''Spot:
(78)'
'05-Jan-2015'[4.4200][4.3737]
'06-Jan-2015'[4.5600][4.5044]
'07-Jan-2015'[4.5400][4.4752]
'08-Jan-2015'[4.3300][4.2559]
'09-Jan-2015'[4.4700][4.3867]
'12-Jan-2015'[4.4000][4.2889]
'13-Jan-2015'[4.4400][4.3196]
'14-Jan-2015'[4.5900][4.4604]
'15-Jan-2015'[4.8700][4.7311]
'16-Jan-2015'[4.9800][4.8319]
'19-Jan-2015'[4.4800][4.3041]
'20-Jan-2015'[4.4500][4.2648]
'21-Jan-2015'[4.8900][4.6956]
'22-Jan-2015'[4.8400][4.6363]
'23-Jan-2015'[4.8400][4.6270]
'26-Jan-2015'[4.7800][4.5393]
'27-Jan-2015'[4.6300][4.3800]
'28-Jan-2015'[4.5500][4.2907]
'29-Jan-2015'[4.4000][4.1315]
'30-Jan-2015'[4.4000][4.1222]
'02-Feb-2015'[4.1300][3.8244]
'03-Feb-2015'[4.2800][3.9652]
'04-Feb-2015'[4.1300][3.8059]
'05-Feb-2015'[4.1300][3.7967]
'06-Feb-2015'[4.0100][3.6674]
'09-Feb-2015'[4.0300][3.6596]
'10-Feb-2015'[4.1000][3.7204]
'11-Feb-2015'[4.0700][3.6811]
'12-Feb-2015'[4.0600][3.6619]
'13-Feb-2015'[4.1100][3.7026]
'16-Feb-2015'[4.0900][3.6548]
'17-Feb-2015'[4.1000][3.6556]
'25-Feb-2015'[4.0500][4.0422]
'26-Feb-2015'[4.1400][4.1244]
'27-Feb-2015'[4.1100][4.0866]
'02-Mar-2015'[4.1100][4.0631]
'03-Mar-2015'[3.9700][3.9153]
'04-Mar-2015'[3.9100][3.8475]
'05-Mar-2015'[3.8000][3.7297]
'06-Mar-2015'[3.8300][3.7519]
'09-Mar-2015'[4.0300]
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 金融 计算 实验 作业 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)