|
主函数调用
%get the data from the excel file
%Data.xls保存的是没有"%"的涨幅,2005.06.01-2011.06.24;
%X为什么只取了2006到2011年的呢?那就是因为滑动窗口大小为366,预测每个第366的数据。
clc;
clear all;
Data=xlsread('Data.xls');
Data=Data/100;
X=xlsread('NUM.xls');
%
alpha=1-0.95;
year=365;
X=X(1:length(Data)-year);
[VaR1 CVaR1]=fun(Data,alpha,year,1);
% [VaR2 CVaR2]=fun(Data,alpha,year,2);
[VaR3 CVaR3]=fun(Data,alpha,year,3);
% [VaR4 CVaR4]=fun(Data,alpha,year,4);
h=figure(1);
set(h,'color','w');
plot(X,VaR1,'b-*');
hold on;
% plot(X,VaR2,'r-*');
plot(X,VaR3,'m-*');
% plot(X,VaR4,'y-*');
xlabel('06/06/2006--24/06/2011');
legend('VaR-HS','VaR-NORM','VaR-CN','VaR-CF',2);%2表示在左上角
hold off;
h=figure(2);
set(h,'color','w')
plot(X,CVaR1,'b-*');
hold on;
% plot(X,CVaR2,'r-*');
plot(X,CVaR3,'m-*');
% plot(X,CVaR4,'y-*');
% xlabel('06/06/2006--24/06/2011');
% xlabel('06/06/2006--24/06/2011');
legend('CVaR-HS','CVaR-NORM','CVaR-CN','CVaR-CF',2);
hold off;
|