不知道这个能不能满足
function calcvar
%calcvar terminal interface for VaR calculation.
%
% You can use the sample data (1, 2, 3) to try the program
%
% Copyright (c) 2004 by Flavio Bazzana
% Department of Computer and Management Sciences
% University of Trento
% 38100 - Trento ITALY
% flavio.bazzana@economia.unitn.it
clear
home
% Load data ----------------------------------------------------------------------------------------
file=input('Which data? (1, 2, 3) ');
if file==1 load('dati1');
elseif file==2 load('dati2');
else load('dati3');
end
dati=size(X,1)
% Type of return ------------------------------------------------------------------------
rendimento=input('Which return? (0 normal, 1 log) ');
[DX,DR,cambi,fattori,prezzi] = rendimenti(X,RF,RC,rendimento);
% Decay factor ----------------------------------------------------------------------------
lambda=input('Decay factor? (x<=1) ');
if lambda==1
[delta,dev,cor,C] = semplicecorr(DX,DR,legame);
else [delta,dev,cor,C] = ewmacorr(DX,DR,legame,lambda);
end
% Parameters ---------------------------------------------------------------------------------
t=input('Holding period? ');
p=input('Probability? ');
% VaR method ------------------------------------------------------------------------------------
a=0;
while a < 4;
a=input('VaR methods? (1 delta-normal, 2 historical simulation, 3 Monte Carlo, 4 average) ');
if a==1
[dvar,dvarp] = deltavar(delta,dev,cor,legame,valuta,cambi,vm,t,p);
dvar
elseif a==2
tipo=input('Mapping? (0 from risk factors, 1 from prices) ');
[svar] = simulvar(DR,RC,X,delta,valuta,legame,vm,t,p,tipo,rendimento)
elseif a==3
modello=input('Simulation model? (0 linear, 1 log) ');
l=input('Number of simulations? ');
[mvar] = montevar(delta,C,legame,valuta,cambi,fattori,prezzi,vm,t,p,modello,l,rendimento)
end
end
% Average VaR --------------------------------------------------------------------------
dati=input('How many data for VaR calculation? ');
giorni=input('How many days of VaR calculation? ');
datidelta=input('Mapping calculation? (0 over all X, 1 over the data only) ');
a=0;
while a < 4;
a=input('VaR methods? (1 delta-normal, 2 historical simulation, 3 Monte Carlo, 4 backtest) ');
if a==1
[dvar,media] = deltamedia(X,RF,RC,legame,valuta,vm,t,p,rendimento,dati,giorni,lambda,datidelta);
media
elseif a==2
tipo=input('Mapping? (0 from risk factors, 1 from prices) ');
[svar,media] = simulmedia(X,RF,RC,legame,valuta,vm,t,p,rendimento,dati,giorni,tipo,lambda,datidelta);
media
elseif a==3
modello=input('Simulation model? (0 linear, 1 log) ');
l=input('Number of simulations? ');
[mvar,media] = montemedia(X,RF,RC,legame,valuta,vm,t,p,rendimento,dati,giorni,modello,l,lambda,datidelta);
media
end
end
% Daily backtest --------------------------------------------------------------------
campione=input('Number of test? (Basilea = 250) ');
dati=input('How many data for VaR calculation? ');
datidelta=input('Mapping calculation? (0 over all X, 1 over the data only) ');
a=0;
while a < 4;
a=input('Backtest for? (1 delta-normal, 2 historical simulation, 3 Monte Carlo, 4 end) ');
if a==1
[dn,dvar,vp] = deltaback(X,RF,RC,legame,valuta,vm,p,rendimento,campione,dati,lambda,datidelta);
elseif a==2
tipo=input('Type of estimation? (0 from risk factors, 1 from prices) ');
[sn,svar,vp] = simulback(X,RF,RC,legame,valuta,vm,p,rendimento,tipo,campione,dati,lambda,datidelta);
elseif a==3
modello=input('Simulation model? (0 linear, 1 log) ');
l=input('Number of simulations? ');
[mn,mvar,vp] = monteback(X,RF,RC,legame,valuta,vm,p,rendimento,campione,dati,modello,l,lambda,datidelta);
end
end