
function ratio=BRratio(spot,futures)  %Basis regression ratio
length=size(spot,1);
%First, construct basis
z=log(spot)-log(futures);
z=z(2:end);
%Second, construct the return series
for i=2:length
    spotret(i-1,:)=log(spot(i))-log(spot(i-1));
    futuresret(i-1,:)=log(futures(i))-log(futures(i-1));
end
%Second, estimate the ohr
retlen=size(spotret,1);
beta=regress(spotret(2:end),[ones(retlen-1,1) futuresret(2:end) z(1:end-1)]);
ratio=beta(2);
