%This code is used to calculate multihorizon hedge based on VAR
clear all; clc;
tic;
data=load('data.txt');
spot=data(:,1);
futures=data(:,2);
windowlength=500;
h=1;  %%%h=horizon
samplelength=size(spot,1);
for i=1:samplelength-windowlength
    hedgeratio(i,:)=VARratio(spot(i:i+windowlength-1),futures(i:i+windowlength-1));
end
ratio=hedgeratio(1:samplelength-windowlength+1-h);
toc;
