⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simulback.m

📁 计算VaR的
💻 M
字号:
function [sn,svar,vp] = simulback(X,RF,RC,legame,valuta,vm,p,rendimento,tipo,campione,dati,lambda,datidelta)%SIMULBACK	baktesting for hystorical simulation VaR.%%	[sn,svar,vp] = simulback(X,RF,RC,legame,valuta,vm,p,rendimento,tipo,campione,dati,lambda,datidelta) %	calculates the number of outlier in portfolio backtesting for VaR with%	historical simulation method. Campione represents the number of simulations (for%	Basel is 250) and dati is the number of data used for VaR calculation.%	Lambda is the weight in EWMA volatility forecast.%   If Datidelta = 0 the mapping procedure is calculated over all X,%   = 1 only with defined data.%%	All data must be in columns.%%	Copyright (c) 2004 by Flavio Bazzana%   Department of Computer and Management Sciences%   University of Trento%   38100 - Trento ITALY%   flavio.bazzana@economia.unitn.itn=size(X,1);m=length(valuta);[DX,DR,cambi,fattori,prezzi] = rendimenti(X,RF,RC,rendimento);[deltax,dev,cor,C] = semplicecorr(DX,DR,legame);cp = vm./prezzi;for i=1:campione+1% VaR interval	X1=X(n-dati-i:n-i,:);	RF1=RF(n-dati-i:n-i,:);	RC1=RC(n-dati-i:n-i,:);	% calculation of simulvar over such interval		[DX,DR,cambi,fattori,prezzi] = rendimenti(X1,RF1,RC1,rendimento);	if lambda==1		[delta,dev,cor,C] = semplicecorr(DX,DR,legame);		else [delta,dev,cor,C] = ewmacorr(DX,DR,legame,lambda);	end	if datidelta==1		[svar(i)] = simulvar(DR,RC1,X1,delta,valuta,legame,vm,1,p,tipo,rendimento);		else [svar(i)] = simulvar(DR,RC1,X1,deltax,valuta,legame,vm,1,p,tipo,rendimento);	end% calculation of portfolio value		for j=1:m		if valuta(j)==0			k1(j)=1;			else k1(j)=cambi(valuta(j));		end	end	k2 = prezzi.*k1';	vp(i) = k2'*cp;end% calculation of the exceptionssn=0;for i=1:campione	if vp(i+1)-vp(i)<-svar(i)		sn=sn+1;	end	if vp(i+1)-vp(i)>svar(i)		sn=sn+1;	endendf=1:campione;plot(f,-svar(1:campione),'b',f,svar(1:campione),'b',f,diff(vp),'r')title('Backtesting of historical VaR simulation')xlabel('Sample')ylabel('VaR')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -