VaR and ESF in Matlab

clear;
clc;
data = xlsread('C:\Users\PGDM Test\Desktop\Gold_data.xlsx');
nif_price = data(:,2);
ret=price2ret(nif_price);
Method = input('What do you want to calculate : ','s');
switch Method
    case 'var'
        risk = quantile(ret,0.05)*100000;
        fprintf('VaR for 100000 exposure is %f\n',risk);
    case 'esf'
        new_ret = sort(ret);
        location = round(length(ret)*0.05);
        risk = mean(new_ret(1:location))*100000;
        fprintf('Expected Shortfall for 100000 exposure is %f\n',risk);
    otherwise
        disp('Not a valid Entry');
end

results matching ""

    No results matching ""