Using Hurst Exponent for VaR Scaling
In this script we will demonstrated how Hurst exponent can be used for VaR scaling. The P&L data can be found in the P&L.xls spreadsheet. This data should be imported first.
Contents
Import P&L data
The data can be imported using xlsread command. Pls, change directory accordingly.
[~, ~, raw] = xlsread('\\Wil-homedrive03\c66144$\Desktop\P&L.xls','Sheet1'); raw = raw(2:end,:);
Calculating R/S Statistic
pnl = cell2mat(raw); clearvars raw; N=length(pnl); for n=2:N % Calculate R statistic Deviation=cumsum(pnl(1:n))-cumsum(ones(n,1))*sum(pnl(1:n))/n; R(n-1)=max(Deviation)-min(Deviation); % Calculate S statistic S(n-1)=sqrt(sum(pnl(1:n).^2)/n-(sum(pnl(1:n))/n)^2); % Calculate R/S statistic Q(n-1)=R(n-1)/S(n-1); time(n-1)=n; end
Estimating Hurst Exponent
The Hurst exponent is derived by plotting as a function of
and fitting a straight line. The slope of the line gives
.
plot(log(time),log(Q),'bo') hold on fit=polyfit(log(time),log(Q),1); H=fit(1) plot(log(time),polyval(fit,log(time)),'r-',log(time),.5*log(time),'g--','LineWidth',2) legend('R/S','Hurst Line', 'Normal Line','Location','North')
H = 0.5853

Calculating 10-day P&L (Non-Overlapping)
We will calculate sliding 10-day P&L first and then pick P&L corresponding to non-overlapping intervals.
pnl_ovlp_10=movsum(pnl,10); pnl_non_ovlp_10=zeros(1,120)'; for i=1:(N/10) pnl_non_ovlp_10(i)=pnl_ovlp_10(6+10*(i-1)); end
Comparing Hurst and Normal Scaling
Sample quantile corresponding to based on 1-day horizon can be scaled up using standard
assumption to a 10-day VaR. Alternatively, one can use Hurst exponent. The Hurst exponent results appear to be more accurate. This is just one realization of the P&L process and is used for demonstrational purposes only. Eventhough the Hust exponent appear to be close to 0.5, the scalors differ by more than 20% (
).
m=100; VaR10DayNO=zeros(1,m); %Unscaled non-overlapping 10-day VaR VaR10DayO=zeros(1,m); %Unscaled overlapping 10-day VaR NSVaR10Day=zeros(1,m); %Normal-scaled 10-day VaR HSVaR10Day=zeros(1,m); %Hurst-scaled 10-day VaR quantiles=zeros(1,m); normalerror=zeros(1,m); hursterror=zeros(1,m); overlaperror=zeros(1,m); for i=1:m VaR10DayNO(i)=quantile(pnl_non_ovlp_10,(i+10)/(10*m)); VaR10DayO(i)=quantile(pnl_ovlp_10,(i+10)/(10*m)); NSVaR10Day(i)=sqrt(10)*quantile(pnl,(i+10)/(10*m)); HSVaR10Day(i)=10^H*quantile(pnl,(i+10)/(10*m)); quantiles(i)=1-(i+10)/(10*m); normalerror(i)=(NSVaR10Day(i)-VaR10DayNO(i))*100/VaR10DayNO(i); hursterror(i)=(HSVaR10Day(i)-VaR10DayNO(i))*100/VaR10DayNO(i); overlaperror(i)=(VaR10DayO(i)-VaR10DayNO(i))*100/VaR10DayNO(i); end figure subplot(2,2,1) % Comparing Hurst-scaled 10-day VaR to unscaled non-overlapping 10-day VaR hold on plot(quantiles,VaR10DayNO,'or',quantiles,HSVaR10Day,'*y') legend('VaR','HuVaR','Location','South') ylim([min([min(VaR10DayNO),min(HSVaR10Day),min(NSVaR10Day)]),max([max(VaR10DayNO),max(HSVaR10Day),max(NSVaR10Day)])]) subplot(2,2,2) % Comparing Normal-scaled 10-day VaR to unscaled non-overlapping 10-day VaR hold on plot(quantiles,VaR10DayNO,'or',quantiles,NSVaR10Day,'*g') legend('VaR','NoVaR','Location','South') ylim([min([min(VaR10DayNO),min(HSVaR10Day),min(NSVaR10Day)]),max([max(VaR10DayNO),max(HSVaR10Day),max(NSVaR10Day)])]) subplot(2,2,3) % Comparing the errors for the two scaling approaches hold on plot(quantiles,hursterror,'oy',quantiles,normalerror,'og') legend('Hurst error, %','Normal error, %','Location','North') subplot(2,2,4) % Comparing the VaRs for the two scaling approaches hold on plot(quantiles,HSVaR10Day,'*y',quantiles,NSVaR10Day,'*g') legend('HuVaR','NoVaR','Location','South') ylim([min([min(VaR10DayNO),min(HSVaR10Day),min(NSVaR10Day)]),max([max(VaR10DayNO),max(HSVaR10Day),max(NSVaR10Day)])])

Comparing The Overlapping and Non-Overlapping VaRs
figure subplot(1,2,1) hold on plot(quantiles,VaR10DayNO,'or',quantiles,VaR10DayO,'ob') legend('Non-Overlapping VaR','Overlapping VaR','Location','South') subplot(1,2,2) hold on plot(quantiles,overlaperror,'or') legend('VaR Error due to Overlap, %','Location','North')
